1
1

Compare commits

...

3021 Commits

Author SHA1 Message Date
fb7c003e99 Simple CSV mesh loading for tests.
File paths are crude and preliminary.
2017-08-28 08:21:57 +01:00
caded470a6 Fix neighbor conflict checks for Poisson disk distribution.
The cell size is chosen as r/sqrt(3) (i.e. max. 1 sample per cell),
which means that the influence of each cell extends beyond the 1st
neighbor. a 5x5x5 box (except the center and corners) needs to be
examined to find collisions.
2017-08-26 15:32:09 +01:00
d9a4945bb2 Added a 1-cell margin to the grid dimensions to simplify neighbor lookups. 2017-08-26 12:41:58 +01:00
188874af2f Separate step for mesh sample generators to bind them to a specific mesh. 2017-08-26 12:13:52 +01:00
e3033693f9 Initial implementation of Poisson disk sampling on meshes.
This is still buggy (uneven sample coverage) and needs changes to the
sampling system for better threading support.

The implementation is based on

Bowers, John, et al. "Parallel Poisson disk sampling with spectrum analysis on surfaces." ACM Transactions on Graphics (TOG). Vol. 29. No. 6. ACM, 2010.
2017-08-25 09:19:49 +01:00
ef67e13bdb Thread-safe implementation of the volume bounding-box raycast sampler. 2017-08-23 09:44:00 +01:00
9e8a41aadf Include other sample generators in tests.
Volume bbray method is currently excluded because the implementation
is not yet thread-safe.
2017-08-23 09:07:45 +01:00
8b607d77e5 New gtests for the mesh sampling system.
This should test general functionality and consistency of different methods
for generating samples. In particular it shoud ensure that threaded variants
produce the same samples as unthreaded variants when using the same generator
and seeds.
2017-08-22 18:49:01 +01:00
0d4fa23414 Use a consistent number of RNG steps in both sample generation and skipping.
This is to ensure that threaded generator usage creates the exact same results
as the non-threaded base version. Further improvements and testing will be
needed.
2017-08-21 06:42:59 +01:00
e3b80d6202 Multithreading support for the mesh sampling library.
Samples can be generated either one-by-one using the existing "make_sample"
function (which uses a default context), or use the more efficient batch
generation functions. These optionally support threading via the task scheduler
now.
2017-08-20 18:50:58 +01:00
ead00baab1 Fix hair follicle array write/read. 2017-08-19 12:26:02 +01:00
45f0f3dc04 Merge branch 'blender2.8' into strand_editmode 2017-08-19 12:02:03 +01:00
0d67f8d5c4 Removed unused shaders in the draw modes module. 2017-08-19 08:56:04 +01:00
9a262ed47e Cleanup: remove unneeded include
Complicated using GPU_matrix from PyAPI.
2017-08-19 17:16:24 +10:00
5720890cf8 Eevee: Bloom: Add Bloom Color
Moar artistic control yay!
2017-08-19 02:40:02 +02:00
63f70ef14d Eevee: Bloom: Add Clamp setting
It's purpose is to limit the amount of light that spread across the screen.

Not entierly sure if it's very usefull, but it sure help to avoid to drown the screen in bloom.
2017-08-19 02:39:16 +02:00
2abc21ace5 Eevee: Fix problem with GPU_texture_generate_mipmap
This function was called to recreate the lower mip level of the probe texture. But this is not it's usage and it introduced a stall.

This patch add cubemap mipmap level regeneration in eevee_effects.c
2017-08-19 01:20:09 +02:00
a702ff4c03 CMake: Boost no longer needed for Audaspace references either 2017-08-18 19:07:39 +02:00
438b3f95a1 Implement control strands generation for basic hair types along surface normals.
The default hair group type uses vertex normals to generate guide strands automatically.
2017-08-18 16:13:34 +01:00
Dalai Felinto
036f43f3cd Eevee: Convert metallic nodes into princinpled nodes
And wipe metallic out of the map.
2017-08-18 17:08:23 +02:00
Dalai Felinto
e8f0ee157b Swap Eevee material output with (Cycles) Material Output
Since we started supporting the (Cycles) Material Output old files
stopped working. There is no reason to keep the original Eevee material
otuput anymore.

It includes doversion for old files.
2017-08-18 17:00:45 +02:00
Dalai Felinto
8ab6e8aad6 Expose Transparency BSDF for Eevee UI 2017-08-18 16:59:13 +02:00
Dalai Felinto
2dad2aa9b7 Uniform Buffer Objects: More complete padding solution
Move floats around when needed to accomodate vec3 arrays efficiently.

With this we use slightly less memory when possible. Basically vec3s are not
treated as vec4 unless we have no float to use for padding).

Reviewers: fclem, sergey

Differential Revision: https://developer.blender.org/D2800
2017-08-18 16:42:58 +02:00
659be38760 Eevee: Rework GTAO
This includes big improvement:
- The horizon search is decoupled from the BSDF evaluation. This means using multiple BSDF nodes have a much lower impact when enbaling AO.
- The horizon search is optimized by splitting the search into 4 corners searching similar directions to help which GPU cache coherence.
- The AO options are now uniforms and do not trigger shader recompilation (aka. freeze UI).
- Include a quality slider similar to the SSR one.
- Add a switch for disabling bounce light approximation.
- Fix problem with Bent Normals when occlusion get very dark.
- Add a denoise option to that takes the neighbors pixel values via glsl derivatives. This reduces noise but exhibit 2x2 blocky artifacts.

The downside : Separating the horizon search uses more memory (~3MB for each samples on HD viewport). We could lower the bit depth to 4bit per horizon but it produce noticeable banding (might be fixed with some dithering).
2017-08-18 15:09:43 +02:00
25789f24f2 Eevee: Add some utils functions 2017-08-18 15:07:17 +02:00
2018df9939 Eevee: MinmaxZ: Avoid unecessary conversions. 2017-08-18 15:07:17 +02:00
91ab64f38f GPU_texture : Add RG8 format. 2017-08-18 15:07:17 +02:00
95b1b7756d Eevee: Fix some problem with Glass & Diffuse BSDF with SSR
Diffuse was not outputing the right normal. (this is not a problem with SSR actually)

Glass did not have proper ssr_id and was receiving environment lighting twice.
Also it did not have proper fresnel on lamps.
2017-08-18 15:07:17 +02:00
Dalai Felinto
f4bd416b34 Fix ubo vec3 alignment issue
This fixes the Principled shader in Eevee, among other nodes.

Basically before we were treating all the vec3 as vec4 as far as memory
goes. We now only do it when required (aka, when the vec3 is not
followed by a float).

We can be even smarter about that and move the floats around to provide
padding for the vec3s. However this is for a separate patch.

That said, there seems to be some strong consensus in corners of the
internet against using vec3 at all [1]. Basically even if we get all the
padding correct, we may still suffer from poor driver implementations in
some consumer graphic cards.

It's not hard to move to vec4, but I think we can avoid doing it as much
as possible. By the time 2.8 is out hopefully most drivers will be
implementing things correctly.

[1] - https://stackoverflow.com/questions/38172696
2017-08-18 12:21:02 +02:00
6fe38bf1cc PyAPI: Gawain checks for range
Raise error on vert-buffer data overflow.
Also exception on attempting to fill data thats already on the GPU.
2017-08-18 18:58:52 +10:00
aae0737f57 CMake: Boost no longer needed for Audaspace 2017-08-18 18:17:29 +10:00
0c57d85941 Fix building w/o Audaspace 2017-08-18 18:16:13 +10:00
986267300b Audaspace: Moving audaspace 1.3 into extern.
Deleting the old internal audaspace.

Major changes from there are:
- The whole library was refactored to use C++11.
- Many stability and performance improvements.
- Major Python API refactor:
 - Most requested: Play self generated sounds using numpy arrays.
 - For games: Sound list, random sounds and dynamic music.
 - Writing sounds to files.
 - Sequencing API.
 - Opening sound devices, eg. Jack.
- Ability to choose different OpenAL devices in the user settings.
2017-08-18 08:24:12 +02:00
d0dad02604 Cleanup: use lowercase prefix for local API's
Also some minor corrections.
2017-08-18 08:58:26 +10:00
cb67873ac5 PyAPI: Iniital gawain API for Python
Wraps vertex-format, vertex-buffer and batch's (enough for drawing).

Doesn't yet expose index-buffers or shaders.
2017-08-18 08:45:41 +10:00
73df38a879 RNA: don't register manipulator properties by name
Matching behavior for operators.
2017-08-18 07:50:31 +10:00
4d93323b8a Gawain: name struct's
Needed to reference without first including headers.
2017-08-17 20:37:37 +10:00
Dalai Felinto
8644fce3b7 Fix blenderplayer 2017-08-17 11:56:24 +02:00
264d0cc6a0 Merge branch 'master' into blender2.8 2017-08-16 19:10:18 -03:00
4b6c482d69 DwM: use batch select for vertex paint mode 2017-08-17 07:13:02 +10:00
7c96f613e4 DwM: Use Batch's for drawing selection
Use mesh batch cache for mesh selection.
Note that we could create the batches and free immediately
so they don't take up memory.

This resolves a problem where selection was limited
to immediate-mode buffer size.
2017-08-17 06:34:02 +10:00
Dalai Felinto
a4068d0083 Fix zombie manipulators when deleting collection from outliner
ND_LAYER and ND_LAYER_CONTENT both need to trigger manipulators updates.
2017-08-16 12:50:00 +02:00
90aa02290a Cleanup: rename GPU gawain functions
Were using Batch_ prefix still
2017-08-16 20:32:42 +10:00
Dalai Felinto
6bca0dcf7b Fix T52415: Copy/Pasting a mesh immediately crashes blender
Since the paste object is pasted in the active collection, and not on
its original one, we need to flush/calculate the new collection base
settings (visibility, selectability, ...).

DEG_id_tag_update() for the scene now. Though it may be better to tag
only the object specific IDs in the future.
2017-08-16 12:14:31 +02:00
Dalai Felinto
2b95617b15 Update code comments from DAG_id_tag_update to DEG_id_tag_update 2017-08-16 12:00:45 +02:00
846c11c8cf Gawain: remove GWN_batch_discard_all
Use ownership flags instead.
2017-08-16 19:51:46 +10:00
Dalai Felinto
18ce2bfac6 Depsgraph/Layers: Keep original visibility when doing full scene copy
Originally we were not respecting the original visibility flags of the
collections. However this is required for Copy-on-write (CoW).

Remember to update the svn lib tests folder. I had to update some of the
json files there.

Also adding a new unittest for this particular issue:
Test render_layer_scene_copy_f
2017-08-16 10:35:26 +02:00
dbd300ab20 DwM: use gawain ownership flags for mesh drawing 2017-08-16 17:47:58 +10:00
4f97be617c Gawain: add ownership flag to Gwn_Batch
Flag ownership for each index array & vbo's
so we don't have to manually keep track of this and use the right free call.

Instead this can be passed on creation.

See D2676
2017-08-16 17:42:05 +10:00
1b462e5a51 Pass EvaluationContext instead of bContext
2.8x branch added bContext arg in many places,
pass eval-context instead since its not simple to reason about what
what nested functions do when they can access and change almost anything.

Also use const to prevent unexpected modifications.

This fixes crash loading files with shadows,
since off-screen buffers use a NULL context for rendering.
2017-08-16 12:46:04 +10:00
b68b26c265 Attempt to fix GLSL errors on Blender startup.
I couldn't reproduce either, but calling min() with different argument
data types and indexing vectors with an index not known at compile time
seem likely to cause problems.

Ref T52404, T52404.
2017-08-15 18:52:25 +02:00
84d33023ab Merge branch 'master' into blender2.8 2017-08-15 18:51:25 +02:00
d56fb5b09d Fix missing clear of Object->drawdata listbase in new copying code. 2017-08-15 17:13:09 +02:00
5426d7134d Fix remaining issues with new Scene copying.
Some idprops were not correctly merged from source into destination.
2017-08-15 17:09:31 +02:00
c8b3f13c9e Bring new IDP_MergeGroup() on par with other copying logic.
We now have to support more complex copying types, which are controlled
by flags, so all copying logic will need to take those at some point (at
least, all potentially dealing with IDs).
2017-08-15 16:42:20 +02:00
cf2f6a986c Fix building with OCIO after recent gawain files renamings. 2017-08-15 16:35:46 +02:00
42374984f1 Fix scene_collection_copy always afecting IDs usercount.
_copy_data() functions shall not do that at all anymore. Kept as option
for now even though that helper is only called from here...

Also moar varnames renaming to standard _src/_dst sufixes.
2017-08-15 16:23:53 +02:00
b6308d79e5 Cleanup: use 'gwn' prefix for gawain filenames
Looking up names project wide or setting breakpoints wasn't so.
Names like common.h or element.h are also too generic.
2017-08-16 00:25:47 +10:00
d9e253abce Correct last commit 2017-08-16 00:25:47 +10:00
119cbf8cf5 Cleanup: rename vars with proper _src/_dst postfixes in new Scene ID data copy func. 2017-08-15 16:05:07 +02:00
77497175fa Cleanup/refactor: no new general arg-less macros enforcing var names please!
We do have an history of those pieces of evil in our code, would be nice
to get fully rid of it, but at the very least let's not add more of them
in new code. :)
2017-08-15 15:59:38 +02:00
90d80ddaa2 Fix new Scene ID copying code.
Missed depsgraph_legacy new pointer to nullify when merged/adapted new
ID copying code to blender2.8.
2017-08-15 15:26:22 +02:00
3bca9f5fed Merge branch 'master' into blender2.8
# Conflicts:
#	source/blender/makesrna/intern/rna_render.c
2017-08-15 13:02:45 +02:00
3311505fd0 Manipulator: border editable only w/ selected camera
While this isn't really needed, active border was annoying.
2017-08-15 20:55:13 +10:00
Dalai Felinto
dd5e674a86 Fix blenderplayer 2017-08-15 10:18:38 +02:00
ed3c3992ad Error in last commit
Get/set mismatch, reading from pchan, writing to bone.
2017-08-15 17:42:59 +10:00
d3ba86de07 Manipulator: Add b-bone spline editing
This needs some improvements since
matching handles *exactly* is a bit involved.
2017-08-15 17:39:41 +10:00
ecfc0370e0 Manipulator: grab3d use own vars to store offset
Was complicating general use case, also support for transforming with matrix_space set.
Add matrix_space support for manipulator_window_project_2d too.
2017-08-15 17:13:32 +10:00
dfb890947d Manipulator: store initial-final matrix for reuse
Also take matrix_space into account when calculating final pixel size.
2017-08-15 13:46:09 +10:00
3ab46f4204 Merge branch 'master' into blender2.8 2017-08-14 17:07:30 +02:00
1b837226ce Store the scalp mesh as part of the hair drawing interface.
The scalp mesh is always needed for evaluating root positions anyway.
2017-08-14 08:46:10 +01:00
6faa4d77c1 Removed fiber drawing from the strand edit mode to simplify code.
For rendering hair fibers the edit mode should just use the underlying data.
2017-08-14 08:19:54 +01:00
b0717ad91e Hair drawing data based on the new DNA hair groups. 2017-08-14 07:58:02 +01:00
230be97284 Merge branch 'master' into blender2.8 2017-08-14 12:13:55 +10:00
eccaa6da26 GPU_framebuffer: Fix incorrect last level. 2017-08-13 15:21:47 +02:00
e3468d7ec2 Eevee: Optimize and improve GTAO Horizon search
This fix a bug when occluder are on the edge of the screen and occludes more than they should.

Grouped the texture fetches together and clamp the ray at the border of the screen.

Also add a few util functions.
2017-08-13 14:30:47 +02:00
82e0419cc0 Eevee: Fix the AO problem around object edges.
This was due to missing GL_TEXTURE_MAG_FILTER.
2017-08-13 14:30:47 +02:00
2087158d5b DRW: Make Cache timing global and not per object.
This is to fix some performance bottleneck.
2017-08-13 14:30:47 +02:00
22872857d4 Merge branch 'master' into blender2.8 2017-08-13 01:14:55 +10:00
57f1475b18 GPU_framebuffer: Fix performance issue on intel.
This should fixes the error message that a stall occured because of busy mipmap.

This happened on the minmax buffer generation and introduced a random 0.2ms latency.
I'm not sure of what was happening though.
2017-08-12 16:16:43 +02:00
b858b44f2e Eevee: Fix and opimize MinMaxZ generation. 2017-08-12 16:16:43 +02:00
76d0ab9750 Code cleanup: fix various compiler warnings. 2017-08-12 14:08:03 +02:00
f1a14740ba Merge branch 'master' into blender2.8 2017-08-12 14:01:54 +02:00
673c9dce08 Merge branch 'master' into blender2.8 2017-08-12 19:08:49 +10:00
ac17f29b2f Cleanup: quiet warnings 2017-08-12 14:07:26 +10:00
a60727080f Merge branch 'master' into blender2.8 2017-08-12 14:06:29 +10:00
9567529b8f Merge branch 'master' into blender2.8 2017-08-12 00:23:49 +10:00
d9323a537f Tweak maximum sizes of vertices/handle vertices
* 255 maximum seems excessive for F-Curve handle vertices; now reduced to 100

* Vertex Size is no longer restricted to the old 10px maximum size limit
  (used because Windows limited the maximum vertex size drivers needed to
  support)
2017-08-12 00:06:00 +12:00
8d42a26891 Fix: Muted strips in NLA draw with dotted borders again
It's more important that there is some form of feedback that the strips
are muted (i.e. dotted borders) than the fact that those dotted borders
may have slightly rounded corners. So, just use a regular sharp-cornered
rect when the strips need to be muted.
2017-08-12 00:05:59 +12:00
043b156c83 Code Cleanup: Use utility function here
There's no reason to manually iterate over items in a DLRBT_Tree,
as the structure is designed to be able to be safely casted down
to a ListBase and ListBase-like nodes..
2017-08-12 00:05:58 +12:00
fc016dca41 Revert C99 "cleanups" from rB09bfc378895f 2017-08-12 00:05:58 +12:00
329cd762c3 Nla Drawing: Fix strip outlines being drawn too thick 2017-08-12 00:05:57 +12:00
12c2be8c02 GraphEdit Drawing: Make active F-Curve slightly thicker 2017-08-12 00:05:56 +12:00
572745cc89 GraphEdit Keyframe Drawing: Tweak styling of handles
* Reduce interior fill opacity - These should *not* be shaded
* Adjust thickness of lines to match the old chunkiness more
2017-08-12 00:05:56 +12:00
00d10977c8 Eevee: SSR: Change clamp default. 2017-08-11 12:59:32 +02:00
d9f2e4c4c5 Eevee: Refraction: Fix low roughness artifact. 2017-08-11 12:53:17 +02:00
91fd0a487d Store pointer into the hair follicle array in hair groups directly.
This creates a dependency of the hair groups on the validity of the pattern,
so care has to be taken to always update the groups when the pattern changes.
2017-08-11 08:57:04 +01:00
e7df5f8528 Split off hair drawing code into a separate file. 2017-08-11 08:17:03 +01:00
317b8d9669 Transform: Snap used multiple eval contexts
Changes for 2.8x to use EvaluationContext caused some confusion

- Would use scene layer passed from snap context.
- Would generate duplis from Main eval context.
- Would take context argument and use it to create another eval context.

Adding context args all over and filling in a new eval-context
for every ray-cast test isn't ideal either.

Remove the context argument since the purpose of
SnapObjectContext is to avoid this kind of confusion.
Store the EvaluationContext once and re-use.
2017-08-11 11:23:39 +10:00
d1328feeb1 Merge branch 'master' into blender2.8 2017-08-11 10:33:39 +10:00
c4201e57f3 Eevee: Re: Fix NaN
This should be faster and apparently more stable.
2017-08-11 01:26:05 +02:00
aa575a3152 Eevee: SSR Clamp color when blurring buffers.
This effectivly reduce firefly bleeding all over the place.
We still need the clamp in the resolve pass because the level 0 has not been clamped.
NOTE: I did not clamped each sample individually for performance BUT I did not profile it to know how much it cost.
2017-08-11 01:26:05 +02:00
0665f58a57 Eevee: Fix NaN
This was surely cause by float overflow. Limit roughness in this case to limit the brdf intensity.
Also compute VH faster.

Add a sanitizer to the SSR pass for investigating where NANs come from. Play with the roughness until you see where the black pixel is / comes from.
2017-08-11 01:26:05 +02:00
a8e1a7ba6d Fix MSVSC error
The array must have any initialization value
2017-08-10 17:41:47 +02:00
48a0fd6de8 Fix after last merge. 2017-08-10 16:04:01 +02:00
4a4c6da0f8 Merge branch 'master' into blender2.8 2017-08-10 15:57:59 +02:00
6e2f17ea02 Eevee: Refraction: Add "thickness" parameter.
This enables to fake a second refraction event. This is great to simulate thin planar objects such as glass panels.
2017-08-10 15:43:48 +02:00
896154d15d Eevee: Fix multiply blend mode. 2017-08-10 15:43:48 +02:00
2ba11d72a2 Object Mode Engine: Optimize outline passes.
Group texture fetches to hide latency. 3.2ms -> 2.2ms (constant time improvement, not depending on scene complexity)

Could optimize further with textureGather (require OpenGL 4.0).
2017-08-10 15:43:48 +02:00
7641f92710 Eevee: Refraction: Make it available for opaque materials.
Theses Materials are rendered after the SSR pass.
The only difference with previous method is that they have a depth prepass (less overdraw) and are not sorted.
2017-08-10 15:43:48 +02:00
7ef8a49ad5 DRW: Indent profiler timings. 2017-08-10 15:43:48 +02:00
723778b162 Eevee: Fix AO not working. 2017-08-10 15:43:48 +02:00
d16342e5fd Eevee: Add Screen Space Refraction.
For the moment the only way to enable this is to:
- enable Screen Space REFLECTIONS.
- enable Screen Space Refraction in the SSR parameters.
- enable Screen Space Refraction in the material tab.
2017-08-10 15:43:48 +02:00
98a7f1b335 Eevee: Refraction: Fix border artifacts. 2017-08-10 15:43:48 +02:00
f53fa8d148 Eevee: SSR: Fix cone footprint estimation. 2017-08-10 15:43:48 +02:00
0ab8b93fdd Eevee: SSR: Blur Mipmaps more.
Cost is negligeable (Only 0.02 ms more) and it improve stability.
2017-08-10 15:43:48 +02:00
99f37bf2a2 Eevee: SSR: Refine Raytrace Algorithm.
We track the previous ray position offseted by the thickness. If the sampled depth is between this value and the current ray position then we have a hit.
This fixes rays that are almost colinear with the view vector. Thickness is now only important for rays that are comming back to the camera.

As a consequence, this simplify a lot of things.

Also include some refactor.
2017-08-10 15:43:48 +02:00
292f5ab758 Eevee: Correct Mipmap texel alignment.
Since we are working with non power of 2 textures, the mipmap level UV does not line up perfectly.
This resulted in skewed filtering and bad sampling of the min/max depth buffer.
2017-08-10 15:43:47 +02:00
e0078cd953 Eevee: Add Refraction via probes. 2017-08-10 15:43:47 +02:00
aaa469a403 Eevee: Small code codestyle and fixes.
Rename get_specular_dominant_dir to get_specular_reflection_dominant_dir.
Add Zero length N check everywhere.
2017-08-10 15:43:47 +02:00
8e36089e41 Eevee: LUT generation.
We generate a 3D lut to precompute the btdf intensity.
I decided to use a 64*64*16 (N dot V, ior, roughness) because the btdf varies less with roughness than with IOR.
We also remap the ior to better use the space in the LUT.
2017-08-10 15:43:47 +02:00
4ec58659ad Eevee: Add precomputed BTDF LUT. 2017-08-10 15:43:47 +02:00
ba4ffe90cd Manipulator: add compositor corner-pin widgets 2017-08-10 21:07:06 +10:00
8c4ccab5fe Merge branch 'master' into blender2.8 2017-08-10 11:14:36 +02:00
464c045b31 Manipulator: grab3d option to align to view
Use for lamp-target, makes it easier to click on.
2017-08-10 16:35:45 +10:00
8520cb4af0 Manipulator: cage2d translate in 3D view support
Needed for moving image-empties.
2017-08-10 14:30:02 +10:00
5406109fbf Manipulator: add image-empty manipulator 2017-08-10 14:08:38 +10:00
d5289f9d80 Manipulator: apply cage2d scale before offset
Needed when offset takes factor into account.
2017-08-10 14:03:37 +10:00
535d917870 Manipulator: expose use_draw_offset_scale to RNA 2017-08-10 09:59:17 +10:00
1d6b99b157 Cleanup: don't abbreviate color w/ manipulator API 2017-08-10 09:59:12 +10:00
7cb65cc038 Manipulator: rename grab enum
We'll want some 3D shapes, so name existing shapes 2D
2017-08-10 09:44:42 +10:00
5fac99ca7a Manipulator: use offset-scale for lamp target 2017-08-09 23:49:27 +10:00
2f20b5242c Manipulator: disable cursor grabbing for 2D groups
We could make this a manipulator type flag,
for now disable for all 2D manipulators since its annoying for cage2d.
2017-08-09 23:39:08 +10:00
b4d44b98e8 Alembic: Adjusted unit test for Blender 2.8 to use scene layers. 2017-08-09 15:08:19 +02:00
6883f10f14 Merge branch 'master' into blender2.8 2017-08-09 15:08:06 +02:00
ed500ac8c7 Fix for previous commit
Accidentally got semicolon removed just before commit.
2017-08-09 15:00:47 +02:00
e00364c88e Fix strict compiler flags on 32bit Linux 2017-08-09 14:58:49 +02:00
2ec865035c Error in last commit 2017-08-09 22:55:18 +10:00
8403ec5160 Manipulator: Add function to calculate matrix
Each manipulator was doing this slightly differently,
use shared function which can optionally override each matrix.
2017-08-09 22:34:08 +10:00
b5e6a21f1d Cleanup: Quiet warning 2017-08-09 20:24:51 +10:00
3f644682b0 Manipulator: add sun-beam node manipulator 2017-08-09 18:08:10 +10:00
d186ab6560 Manipulator: grab3d - support for 2d views
Also internal changes so arrow3d matches grab3d's behavior.

Needed to add WM_MANIPULATOR_DRAW_OFFSET_SCALE flag so
we can optionally apply offset in worldspace or screen scaled values.
2017-08-09 18:07:55 +10:00
f0d4420cc0 Fix spin rotate axis
Also disable lamp-target for cameras (might enable later).
2017-08-09 18:02:10 +10:00
00f22403ac Manipulator: replace hard coded color w/ theme 2017-08-09 18:02:10 +10:00
fdb1c81117 Merge branch 'master' into blender2.8 2017-08-09 09:12:16 +02:00
8563494823 Merge branch 'master' into blender2.8
Conflicts:
	source/blender/modifiers/intern/MOD_meshsequencecache.c
2017-08-08 19:16:25 +02:00
e8b6bcd65c Merge branch 'master' into blender2.8
Conflicts:
	source/blender/depsgraph/intern/builder/deg_builder_relations.cc
	source/blender/editors/object/object_add.c
	source/blender/python/intern/bpy_app_handlers.c
2017-08-08 16:43:25 +02:00
cf8add42b8 Merge branch 'master' into blender2.8
Stupid git handles merges terribly when there are conflicts and branch
is modified buring merge process... :((((
2017-08-07 21:09:10 +02:00
e673c9dc93 Merge again... 2017-08-07 20:48:22 +02:00
41830cc432 Refactor ID copying (and to some extent, ID freeing).
This will allow much finer controll over how we copy data-blocks, from
full copy in Main database, to "lighter" ones (out of Main, inside an
already allocated datablock, etc.).

This commit also transfers a llot of what was previously handled by
per-ID-type custom code to generic ID handling code in BKE_library.
Hopefully will avoid in future inconsistencies and missing bits we had
all over the codebase in the past.

It also adds missing copying handling for a few types, most notably
Scene (which where using a fully customized handling previously).

Note that the type of allocation used during copying (regular in Main,
allocated but outside of Main, or not allocated by ID handling code at
all) is stored in ID's, which allows to handle them correctly when
freeing. This needs to be taken care of with caution when doing 'weird'
unusual things with ID copying and/or allocation!

As a final note, while rather noisy, this commit will hopefully not
break too much existing branches, old 'API' has been kept for the main
part, as a wrapper around new code. Cleaning it up will happen later.

Design task : T51804
Phab Diff: D2714
2017-08-07 20:34:36 +02:00
6fa838f6d3 List of 'Hair Groups' in hair patterns that will generate actual fibers for rendering.
Each group affects a subset of the hair follicles, so that multiple effects can be combined
without overlapping sample sets.
2017-08-07 18:04:30 +01:00
25b8eb4631 Merge branch 'master' into blender2.8 2017-08-07 17:48:14 +02:00
e7c6b244c9 Build: add scripts to build dependencies for Windows and macOS.
Note these are intended for platform maintainers, we do not intend to
support users making their own builds with these. For that precompiled
libraries from lib/ should be used.

Implemented by Martijn Berger, Ray Molenkamp and Brecht Van Lommel.

Differential Revision: https://developer.blender.org/D2753
2017-08-07 17:46:06 +02:00
8b73c9a437 Fix Cycles shadow catcher objects influencing each other.
Since all the shadow catchers are already assumed to be in the footage,
the shadows they cast on each other are already in the footage too. So
don't just let shadow catchers skip self, but all shadow catchers.

Another justification is that it should not matter if the shadow catcher
is modeled as one object or multiple separate objects, the resulting
render should be the same.

Differential Revision: https://developer.blender.org/D2763
2017-08-07 17:44:15 +02:00
dc213ca066 Fix Windows build errors with recent Cycles SIMD refactoring. 2017-08-07 17:44:15 +02:00
b282716c3a Merge branch 'master' into blender2.8 2017-08-07 16:16:43 +02:00
41e8bd9337 Merge branch 'blender2.8' of git.blender.org:blender into strand_editmode 2017-08-07 13:06:02 +01:00
77802b21a6 Operator for generating a hair follicle distribution. 2017-08-07 12:29:12 +01:00
8abe6745a4 DNA data + modifier for storing persistent hair data.
This stores basic hair follicle data, rather than full fiber caches
(which should only be generated for render data).

Note that deformation by strands will just be one possible way to generate
hair fibers, so strands should be kept separate from the hair follicle data somewhat.
2017-08-07 10:54:02 +01:00
53eb011e3d Prototype hair deformers for generated detail like clumping and curling.
Currently only clumping and curls are implemented. There is no proper input
for the parameters yet, these are just hardcoded atm. Eventually the hair system
should either define uniform values from hair system settings or enable per-fiber
values using a material or other node-based input.
2017-08-06 12:41:16 +01:00
459365443f Manipulator: experimental lamp positioning tool
- New manipulator tracks lamps to position under cursor.
- Works with multiple lamps, keeping relative offsets.
- Holding Ctrl moves the lamp.
- Access via manipulator or Shift-T.

Code could be improved, but like to get feedback from users.
2017-08-06 19:50:09 +10:00
48adef4444 Merge branch 'master' into blender2.8 2017-08-05 07:53:07 +10:00
796437247f Manipulator: fix cage2d cancel not resetting 2017-08-04 20:33:26 +10:00
a65a64cbca Manipulator: fix 2d overlay w/ Blender Render 2017-08-04 19:18:55 +10:00
801c20cebc Some optional timing for strand data buffer construction. 2017-08-04 08:41:20 +01:00
d7905dab6a Manipulator: add compositor crop manipulator 2017-08-04 16:45:33 +10:00
54cea98046 Manipulator: add manipulator space matrix
Render-border & crop-node 2d-cage manipulators where unreasonably
complicated to implement because there was no good way to define
the sub-region the manipulator was transforming in
(render border within the camera's frame for example).

Add matrix-space variable,
remove scale property from cage2d manipulator, use matrix instead.
2017-08-04 15:34:01 +10:00
0a3295953c Manipulator: fix check for custom function 2017-08-04 15:17:21 +10:00
2952798cd6 BLI_math: use const args for mul_m#_series 2017-08-04 15:05:02 +10:00
b156b968ae Manipulator: modal was drawing in wrong draw-step 2017-08-04 09:41:45 +10:00
7821bac08d Manipulator: remove unused draw step 2017-08-04 09:35:07 +10:00
caf1a5fc44 Manipulator: correct center-pivot clamping 2017-08-04 09:23:50 +10:00
e16e96433f Merge branch 'master' into blender2.8 2017-08-04 08:26:05 +10:00
9feec51214 Subdivision of hair fibers for smoother shading.
Subdivision works on the parent strands for efficiency. The fibers lengths
are based on the final subdivided length of parents, so no changes to the
shader are required.

This would be nicer with a tesselation shader, but this feature is not
available in Blender 2.8.
2017-08-03 20:27:33 +01:00
3b57504c09 error in last commit 2017-08-03 20:05:43 +10:00
c3eac16eb7 Manipulator: disallow negative scale when resizing 2017-08-03 20:04:22 +10:00
c8d02fce93 Manipulator: use matrix to convert view coords
Was doing this with property get/set but this made view operations
require refreshing manipulator properties.
Simplify by operating on properties in their own space.

Also disable clamping for now since it assumes pixel-space.
2017-08-03 19:45:56 +10:00
e92cf80a5c Fix for last commit
Missed check for non-camera view frame
2017-08-03 18:09:11 +10:00
fe8fcb4343 Manipulator: render border widget
Note there are issues clamping & updating,
will resolve as part of changes to cage2d widget.
2017-08-03 17:57:00 +10:00
e34ba9fb7a Use a 2D texture for the hair interpolation data instead of 1D for larger number of hairs.
It turns out that 1D textures have the same size limit on their 1 axis as 2D textures.
This limits the potential number of hair dramatically, even though the actual size of
the texture is very small. Using a 2D texture and wrapping the index avoids this problem.
2017-08-03 08:11:48 +01:00
c27446b5a0 Depsgraph: Fix wrong data type used for armature tag
Spotted by Ray aka LazyDodo, thanks!
2017-08-03 08:19:13 +02:00
4fada2e10f Manipulator: Use 2D manipulators in the 3D view
Also split update flag into draw-steps,
since drawing 3D manipulators was tagging 2D as being refreshed.
2017-08-03 15:12:47 +10:00
fc9da74942 Manipulator: use default for cage2d dimensions
Also minor cleanuup, assign new vars for manipulator group.
2017-08-03 11:28:26 +10:00
acde5bb669 Cleanup: split 3D view manipulators by type 2017-08-03 08:30:58 +10:00
be7de5f239 Cleanup: warnings 2017-08-03 08:08:47 +10:00
cd2bb7831d Cleanup: rename selectionbase -> select_id 2017-08-03 08:01:09 +10:00
c92457a87a Default settings for hair edit mode tool settings. 2017-08-02 22:35:57 +01:00
bf0f058954 Disable selection outline drawing on the object during hair edit mode. 2017-08-02 22:28:25 +01:00
ca67cdb73c Merge branch 'master' into blender2.8 2017-08-03 07:14:02 +10:00
e35f24fb28 Removed leftover hair fiber code from edit mode drawing (all in Eevee now). 2017-08-02 21:54:01 +01:00
e8ff620325 Moved the hair fiber shader from strand edit mode into Eevee.
This allows the shader to use proper lighting from the standard Eevee shaders.

The code for interpolating hair strands is in a glsl library file to facilitate
use in other engines later.
2017-08-02 21:40:52 +01:00
3e6f5f3643 GraphEdit Handle Drawing: Fix handle-vertex size regression (2.7 -> 2.8)
Keyframe handle vertices (the circles on the ends of the handles)
should always be larger than the central vertex. This brings back the
"outer" radius value from the old gluDisk(), and doubles it to get the
necessary diameter, to scale it properly.

TODO's:
- Get rid of all fills inside these circles
- Make the central vertex square-shaped again
2017-08-03 01:52:07 +12:00
440bce242d Keyframe Drawing: Fix 2.7 -> 2.8 regressions
* Outlines of keyframes were too thick and ugly

* Size differences between keyframe types was being swallowed
  by the pixel-fudge factor, leaving colour as the only distinguishing
  factor (bad!)
2017-08-03 01:25:55 +12:00
b569151ffb Manipulator: add area lamp manipulator 2017-08-02 19:22:35 +10:00
dc4ded855a Manipulator: Make cage2d usable in the 3D view 2017-08-02 19:22:29 +10:00
1b51c34e8b Manipulator: correct cage-2d scale update 2017-08-02 08:34:59 +10:00
4afc94080c Cleanup: prefer tuples over lists 2017-08-02 07:55:15 +10:00
c42c129393 Render: make Cycles and Evee support each other's output material nodes.
This changes the Cycles exporting and Cycles/Eevee UI code to support both
output material nodes, giving priority to the renderer native one. Still
missing is Eevee code to prefer the Eevee output node.
2017-08-01 19:13:41 +02:00
110d6832a8 Fix typo in 2d-cage manipulator 2017-08-01 21:22:17 +10:00
6341380fbf Cleanup: warnings 2017-08-01 17:24:30 +10:00
5709021f52 Correct previous commit, instance should be cleared
Clear instance in case creating creating new instance fails.

In practice this shouldn't happen,
but better not cause further errors if it does.
2017-08-01 17:17:38 +10:00
5ac9e587d4 PyRNA: Ensure changed types creates a new instance
Changing lamp type for eg needs to create a new instance.
2017-08-01 17:14:09 +10:00
3a438c675f Hair fiber (child hair) drawing during edit mode, with heavy GPU leveraging.
Hair drawing requires fairly large vertex buffers. Vertices also need to be interpolated
and displaced according to the control (parent) hairs and hair-style features like curling
and clumping.

Instead of doing this in advance on the CPU and uploading a large vertex buffer every frame,
this work can be done on the GPU for realtime display, because interpolation and displacement
are highly parallelizable. The vertex buffers then only need to be uploaded once (as long
as strand lengths remain the same). The vertex format can also be very lightweight, requiring
only a curve parameter and index (half the size needed for full positions).

For interpolating a buffer texture is used in the shader, which contains all information
about the control curves (parents) from which to interpolate final vertex positions.
2017-08-01 08:10:05 +01:00
a108d81af9 Merge branch 'master' into blender2.8 2017-08-01 15:00:49 +10:00
4c38d84e73 Cleanup: double promotion 2017-08-01 13:35:26 +10:00
8ddaa6a4e2 Merge branch 'master' into blender2.8 2017-08-01 10:38:36 +10:00
b71366801e Eevee: SSR: Change clamp to a real clamp and add Max Roughness.
Clamp will now works as in Cycles.

Max roughness limit ssr to a certain roughness level: for noise / performance tweaking.
2017-07-31 15:18:38 +02:00
1be1600c32 Eevee: Draw background after depth prepass.
Reduce overdraw. 0.4ms goes to 0.01ms if background is completely occluded.
2017-07-31 15:18:38 +02:00
683e31fd80 Eevee: SSR: Rewrote the raytracing algorithm.
It now uses a quality slider instead of stride.
Lower quality takes larger strides between samples and use lower mips when tracing rough rays.

Now raytracing is done entierly in homogeneous coordinate space. This run much faster.
Should be fairly optimized. We are still Bandwidth bound.

Add a line-line intersection refine.
Add a ray jitter between the multiple ray per pixel to fill some undersampling in mirror reflections.

The tracing now stops if it goes behind an object. This needs some work to allow it to continue even if behind objects.
2017-07-31 15:18:38 +02:00
39e1518d41 Fix glitch updating manipulator after undo
Running undo would notify manipulators to refresh,
but this still allowed for events in the queue to be handled,
where manipulators could be drawn for selection before
their refresh callback runs.

This made Python manipulators raise exceptions
about referencing invalid data (or crash).

Now tag manipulator update on file load (including undo)
and ensure the refresh callback runs
before drawing manipulator selection.

Also split manipulator map refresh flag in two since selection doesn't
perform the same operations as regular drawing.
2017-07-31 14:35:10 +10:00
3b15ff3fb4 Cleanup: use enum typedef for manipulator drawstep 2017-07-31 13:15:02 +10:00
538b191a03 Correct last commit, for-loop included NULL check 2017-07-31 11:39:17 +10:00
ac2b1663ef Cleanup: remove next/prev from manipulator map 2017-07-31 11:26:03 +10:00
18773f3f15 Fix manipulator Python API crash w/ undo
Split up manipulator free & unlink, so freeing window data doesn't
run callbacks that might use freed data.
2017-07-31 06:45:05 +10:00
0467443930 Fix manipulator keymap initialization
Update flag was cleared before being checked
when registering after load.
2017-07-31 04:47:24 +10:00
c90a3af879 Manipulator: Check we don't add multiple times 2017-07-30 15:47:57 +10:00
49c0ad1188 Revert "Fix manipulator handles getting added each refresh"
This reverts commit 122706db9c.

Would loose manipulators, will check for duplicates instead.
2017-07-30 15:38:32 +10:00
367ec386d1 BLI_memiter: minor cleanup 2017-07-30 14:23:08 +10:00
be97238308 DwM: use BLI_memiter for draw storage & iteration
This will only be noticeable for drawing many instances.

In contrived use-case with many instances, and `USE_PROFILE` disabled
this can close to double playback FPS.

The option to disable this is left in the code in case we want to
debug memory use.

See D2756 for details.
2017-07-30 02:26:36 +10:00
71388b094f DwM: add ability to disable the timer
This interferes with benchmarking draw times,
so this makes it easy to turn off.
2017-07-30 01:31:36 +10:00
913d8ec608 BLI_memiter: Small API for many small allocations
- Each allocation can be a different size
  (but should be smaller than the chunk size).
- Result can be looped over in order of allocation.
- Allocations are aligned to pointer size to avoid unaligned reads.
2017-07-30 00:08:17 +10:00
277dc47eea Remove volatile, causing issues w/ GCC/ubsan
Should remove from master since its workaround for Cygwin
but too close to release.
2017-07-29 08:58:11 +10:00
1ee11b5085 Merge branch 'master' into blender2.8 2017-07-29 08:49:34 +10:00
361acb6991 Cleanup: multistatement-macros warning 2017-07-29 08:21:01 +10:00
0e26707bce Merge branch 'master' into blender2.8 2017-07-29 06:44:04 +10:00
c558763ef5 Merge branch 'master' into blender2.8 2017-07-29 01:46:27 +10:00
e39dc48bd5 Fix crash when duplicating object
This fixes null pointer check fiasco.
2017-07-28 13:02:20 +02:00
50cc0aa0d1 Depsgraph: Re-use evaluated mesh across frames and remove time dependency from all CoW components
This commit is a work forward having less updates during playback, which speeds
things up a lot here. The idea is simple: stop update all copy-on-write
datablocks (which implies full re-evaluation actually) on frame change and
re-use existing evaluated meshes as much as possible.

This brings playback speed to 24 fps on the dino test scene here. Performance
drops down a lot when armature is animated tho, but that's because of need of
tangent space calculation which we can't do much about from just a dependency
graph.

Hopefully this doesn't make copy-on-write too unstable, quick tests here are
surviving fine.
2017-07-28 12:27:34 +02:00
9323182e73 Prevent crash when duplicating object which doesn't have evaluated base properties yet
This mainly happens when copy on write is enabled.
2017-07-27 16:29:45 +02:00
03d258d613 Copy on write: Prevent crash when duplicating object with particle system
Transform system was using global main, which might have been pointing to a
freed scene layer.
2017-07-27 16:28:16 +02:00
549f43e928 Depsgraph: Attempt to keep evaluated mesh when possible
Currently wouldn't make any difference, but required for upcoming work of
getting rid of time dependency for copy-on-write component.
2017-07-27 15:19:37 +02:00
6ef34525a1 Depsgraph: Cleanup, variable name 2017-07-27 15:19:37 +02:00
e90468e5a3 Depsgraph: Cleanup, use some utility functions to shorten construction code
Still some cleanup is possible.
2017-07-27 15:19:36 +02:00
cf38371155 Depsgraph: Create ID nodes on build-time expansion using node builder
This will allow us to do some builder-specific trickery when ID nodes are
requested to be created from build-time expansion.
2017-07-27 15:19:36 +02:00
55527d83e2 Depsgraph: Allow stealing copy-on-written pointer
This will become handy when we'll be re-using evaluated meshes for
objects after relations are updated.
2017-07-27 15:19:36 +02:00
3441af49bd Depsgraph: Fix possibly missing lamp update when lamp data changes 2017-07-27 15:19:36 +02:00
41a3aafd48 Depsgraph: Make it possible to use given pre-allocated ID as a copy 2017-07-27 15:19:36 +02:00
4c5537ed42 Copy on write: Make sure freeing evaluated mesh does not cause crash when re-evaluating the object 2017-07-27 15:19:36 +02:00
7d014bca91 DRW: Fix vertex buffer too large. 2017-07-27 14:51:44 +02:00
88b911aa9e Eevee: Fix probes interfeering with SSR. 2017-07-27 14:51:44 +02:00
05d73ec06f Eevee: Planar Reflection: only support mirror reflection if not using SSR. 2017-07-27 14:51:44 +02:00
c6a74edcf8 Eevee: Fix bloom once and for all.
... Hopefully ...
2017-07-27 14:51:44 +02:00
ec6170061e DRW: Add stats group to eevee and object mode. 2017-07-27 14:51:44 +02:00
5bfa3cf6e9 DRW: Revamp the performance debugging tool.
Old performance debug was doing queries for every frame even if not debugging perf.
Also, it did not record when a pass was draw multiple time, leading to incorect measurement.

New module also allows to group the timers to limit infos displayed.

Also fix the background CPU draw timer.
2017-07-27 14:51:44 +02:00
2b8f50e1d4 Depsgraph: Fix crash happening in copy-on-write of images
Was a threading conflict or so in the cache limiter, and in fact
we don't even want images to be copied.
2017-07-27 13:26:21 +02:00
Julian Eisel
980efaf4fd Fix button text overlapping with shortcut text in popups
The purpose of the keymap strings is probably for un-embossed menu items
like seen in most pulldowns. I can't see a reason for also adding that
string for regularly drawn buttons within popups, we don't add it
anywhere else in the UI either. So this commit makes sure shortcut
strings are only added to buttons that are drawn like pulldown-menu
items.
2017-07-27 12:28:16 +02:00
Julian Eisel
492b5d0bc3 Minor code style corrections 2017-07-27 12:28:16 +02:00
c72eb6288e Fix Label colors in popups 2017-07-27 12:28:16 +02:00
72e228a155 Fix: use click style if a pie was spawned by release or click event 2017-07-27 12:28:16 +02:00
f8bd6adee2 Depsgraph: Skip iterating over all ntree users on node tree parameter update
Also make sure drivers on node tree properties will work correctly for viewport.
2017-07-27 11:50:14 +02:00
b01d38ef7d Manipulator: remove names
They weren't used anywhere,
both C & Py manipulators better assign to vars (no lookup needed).
2017-07-27 07:43:15 +10:00
1f15c61ce1 stub update 2017-07-27 07:41:24 +10:00
11e95fcdd2 Merge branch 'master' into blender2.8 2017-07-27 07:35:44 +10:00
48e8a1a167 Fix crash in recent changes to instancing
Registrable classes already handled their own instancing,
changes to enable instancing everywhere conflicted.
2017-07-27 03:27:14 +10:00
6fe2a48d3e Last commit broke WITH_PYTHON_SAFETY
Re-enable BPY_id_release call with thats enabled.
2017-07-27 02:12:40 +10:00
0b5f056119 BPY_id_release was a nop, use RNA invalidate directly 2017-07-27 02:07:04 +10:00
723f2b292f Fix T52186: Crash on bevel
bContext is not always available in transform, so need to use explicit
scene and scene layer to create evaluation context from.
2017-07-26 16:33:44 +02:00
22342a7647 CLeanup: Use utility function in BKE 2017-07-26 16:33:44 +02:00
a01c1849e9 Depsgraph: Add utility function to initialize evaluation context from scene and layer 2017-07-26 16:33:44 +02:00
e99350aeaa Cleanup, line wraps 2017-07-26 16:33:44 +02:00
776c765400 Initialize time for evaluation context when creating from bContext 2017-07-26 16:33:44 +02:00
3ed5c9a610 PyAPI: Store PyInstances for ID's
This means once an ID is created,
it will keep using the same PyObject instance.

This has some advantages:
- Avoids unnecessary re-creation of instances on UI poll / redraw.
- Accessing free'd ID's gives an exception instead of crashing.
  (long standing annoyance!, though this only applies to ID's
   and not yet other data that uses the ID's - vertices for eg).
- Allows using instance comparison (a little faster).

Note that the instances won't be kept between undo.
2017-07-26 23:49:20 +10:00
40a45e393e PyAPI: Fix for instancing (Blender owns a reference)
Also set newly created values to the instance pointer.
2017-07-26 23:05:00 +10:00
80befca6e5 Manipulator: only check for highlight once
Was doing 2x lookups which is OK for click-select
but this runs on mouse-move and can become slow.

May enable this again if highlighting logic changes.

Also scale hotspot by pixelsize.
2017-07-26 20:54:37 +10:00
245a67386b blenderplayer stub update 2017-07-26 18:18:32 +10:00
2e83897f91 Cleanup: typedef enums
Manipulator enum types are easy to confuse, use typedefs.
2017-07-26 18:00:26 +10:00
54bc49e6f9 Manipulator: refactor/fix selection logic
- Cleanup array access, move into functions.
- Store allocated size to avoid realloc's on every add/remove.
- Make select editable from Python.
- Rename select callback to select_refresh
  (collided with select boolean).
- Call select_refresh when de-selecting as well as selection.
2017-07-26 08:34:09 +10:00
dee19b8cb7 FaceMaps: add select flag
For use by manipulators since they don't have their own persistent data
in the blend file.
2017-07-26 08:34:09 +10:00
3b84a0b3d2 Eevee: Fix post process with Ugly color.
This was cause by some post process not always sampling the highest mipmap.
But if there is no need for mipmapping (i.e. no SSR) these levels will be undefined.
So forcing all Post FX shader to sample level 0 fix this.
2017-07-25 22:07:35 +02:00
4fd70c99a5 Eevee: SSR: Add support for planar probes.
This add the possibility to use planar probe informations to create SSR.
This has 2 advantages:
- Tracing is less expensive since the hit is found much quicker.
- We have much less artifact due to missing information.

There is still area for improvement.
2017-07-25 22:07:35 +02:00
8c3ecc9651 Workaround for crash drawing face-maps after undo 2017-07-26 05:10:20 +10:00
2b1cd24c6e Fix T52190: Depth picking fails 2017-07-26 02:35:27 +10:00
80e03e7709 Depsgraph: Support changing scene's render engine 2017-07-25 15:11:51 +02:00
f7636f0ef2 Depsgraph: Make sure armature mode is properly changed in all copied versions 2017-07-25 14:53:19 +02:00
6a7d7586e5 Depsgraph: Initial support of pose mode for copy-on-write armature
Some basic code, makes it possible to pose existing armature.

Probably still lots of corner cases to cover, but need to start somewhere.
2017-07-25 14:38:10 +02:00
247ddb6237 Depsgraph: Fix relations update when transform is done and there was no temporary constraints created 2017-07-25 14:38:10 +02:00
f848374e49 Cleanup: rename active to modal
This matches operators naming and should avoid confusion in future if we
want to use active as term for last-selected.
2017-07-25 22:39:58 +10:00
762fa7bee3 Depsgraph: Remove unsued node flag 2017-07-25 14:06:36 +02:00
5d327eda98 Manipulator: option to draw all while interacting 2017-07-25 22:02:16 +10:00
0612011b91 Manipulator: support select-drag to tweak 2017-07-25 21:34:20 +10:00
b97bf844b3 Merge branch 'master' into blender2.8 2017-07-25 20:53:10 +10:00
8a2fdb3749 Manipulator: break after an event is handled
Now works the same as other event handling functions.
2017-07-25 20:17:54 +10:00
50e88740c4 Fix PyManipulators having keymaps registered twice
Manipulators which are registered before UI initialized would have their
keymaps initalized twice (duplicate keymap items).
2017-07-25 20:06:49 +10:00
9bdd12d884 Merge branch 'master' into blender2.8 2017-07-25 17:36:49 +10:00
d99532e1d8 Fix crahs when doing preview from a scene withotu world 2017-07-24 17:42:55 +02:00
ff6e8b0b50 Depsgraph: Avoid assert failure in some harmless cases 2017-07-24 17:41:29 +02:00
34b248b746 Depsgraph: Synchronize collection visibility after copy
BKE_scene_copy explicitly ignores visibility of "source" collections make all
collections visible. This is also tested by regression tests.

While it seems more logical to simply preserve all possible visibility flags
and overrides, don't feel like submitting to a behavior-changes without talking
to author of those guards first.

This commit fixes cycles material preview.
2017-07-24 17:03:53 +02:00
35d044e40d Fix compilation error of alembic test after recent eval_ctx changes 2017-07-24 16:50:47 +02:00
34c2628f32 Eevee: Silence printfs. 2017-07-24 16:36:57 +02:00
b3466921b8 Depsgraph: Fix typo in comment 2017-07-24 16:32:07 +02:00
b11926487f Depsgraph: Fix crash when trying to create full copy of scene 2017-07-24 16:24:41 +02:00
1ddb3c953d Depsgraph: Textures and images are actually covered by depsgraph
Might be missing relation links tho.
2017-07-24 16:24:41 +02:00
deecfb5476 Depsgraph: Avoid creating ID nodes for objects which are coming from collections and not layers
If object is only listed in collection but not added to any of layers we shouldn't create
placeholder for it, because otherwise we'll leave lots of placeholder ID nodes.

Question: can we make this exception to be more reliable?
2017-07-24 16:24:41 +02:00
7b420e1908 Depsgraph: Be consistent about id type variable name 2017-07-24 16:24:41 +02:00
7721f8a269 Depsgraph: Cleanup, use utility function to clear lists 2017-07-24 16:24:41 +02:00
4719dbafdf Depsgraph: Ignore palettes from copy-on-write routines
They are not covered by dependency graph.
2017-07-24 16:24:41 +02:00
c21dd69060 Eevee: Fix crash when saving file with motion blur. 2017-07-24 16:21:43 +02:00
8dd0ce6b78 Eevee: Fix double buffer issue. 2017-07-24 15:55:21 +02:00
27dd82a951 Eevee: SSR: Refactor multiple rays. Plus other changes...
-Allow a maximum of 4 rays per trace pixel.
-Removes parameter Normalize: use normalization all the time now.
-Add firefly clamp slider.
2017-07-24 15:36:37 +02:00
7585c82722 Eevee: Make MinmaxZ compatible with textureArray 2017-07-24 15:36:37 +02:00
85f1b7358a Eevee: Planar Reflection: Remove distance approximation.
This commit separate the depth texture into another texture array.
This remove the need to output radial depth into alpha.
Unfortunatly it's difficult to recover position from the non linear depth buffer when applying reflection without adding a bunch of stuff.
This is in preparation of SSR planar reflections.
2017-07-24 15:36:37 +02:00
1d99d08d50 Eevee: SSR: Add two hit option.
This option add another raytrace per pixel, clearing some noise.
But multiplying the raytrace cost.
2017-07-24 15:36:37 +02:00
76bf4f2cd3 Eevee: SSR: Fix Opengl Render.
Add a constant number of 4 drawing loop to accumulate 4 "bounce" of light in SSRs.
2017-07-24 15:36:36 +02:00
56ba01a561 Eevee: SSR: Fixed problem with un-initialized texture.
Also add another debug buffer and cleanup in effect_ssr_frag.glsl
2017-07-24 15:36:36 +02:00
c5f4342692 Eevee: SSR: Small fixes
- Encode normals for other opaque bsdf so they are not rejected by the normal facing test.
- Early out non reflective surfaces.
- Add small offset to raytrace to avoid self intersection.
- Fix fallback probes not appearing.
2017-07-24 15:36:22 +02:00
f6c60ffcad Eevee: SSR: Add Weight Normalization option. 2017-07-24 15:28:27 +02:00
e5dae98999 Eevee: SSR: Add View Facing fadeout.
Also make hit boolean depends on hit coord not on pdf.
2017-07-24 15:28:27 +02:00
d2462e3d26 Eevee: SSR: Add fullscreen raytrace option and Screen border factor. 2017-07-24 15:28:27 +02:00
9906ef06b1 Eevee: SSR: Use noise to dither the stride banding. 2017-07-24 15:28:27 +02:00
a3732412ad Eevee: SSR: Add stride and thickness parameters.
Also polished the raytracing algorithm.
2017-07-24 15:28:27 +02:00
18aa6cf1cc Eevee: SSR: Add fullscreen raytrace. 2017-07-24 15:28:27 +02:00
e0c1323737 Eevee: HiZ buffer: Split into two 24bit depth buffer
This way we don't have float precision issue we had before and we save some bandwidth.
2017-07-24 15:28:27 +02:00
a2932078ec Eevee: SSR: Add firefly filter and refine noise reduction.
Push to 9 resolve sample.
Add an normalization as an option since it gives harsh limits.
2017-07-24 15:28:27 +02:00
b576d06050 Eevee: Codestyle. 2017-07-24 15:28:27 +02:00
e8912dd844 Eevee: SSR: Do the SSR pass only for probes if there is no valid double buffer.
This prevent black reflection when initializing SSR.
2017-07-24 15:28:27 +02:00
f1bf9d6bfb Eevee: SSR: Add mipmap filtering and bias to reduce noise.
Also fix the roughness factors.
2017-07-24 15:28:27 +02:00
09413fad12 Eevee: Fix glossy node roughness. 2017-07-24 15:28:27 +02:00
babef873fc Eevee: SSR: Don't block the ray if tracing behind object.
This requires to check for backface after a hit.
2017-07-24 15:28:27 +02:00
72a4778391 Eevee: SSR: Add per pixel resolve of multiple rays. 2017-07-24 15:28:27 +02:00
b1a8803c24 Eevee: SSR: Add roughness random rays. 2017-07-24 15:28:27 +02:00
7938848b63 Eevee: SSR: Add double buffer so we can read previous frame color.
Also add simple reprojection and screen fade to the SSR resolve pass.
2017-07-24 15:28:27 +02:00
14bedf80cd Eevee: SSR: Make raymarch step bigger. 2017-07-24 15:28:27 +02:00
ebc2833ca1 Eevee: Fix Shader compilation. 2017-07-24 15:28:27 +02:00
3be8ab881e Eevee: SSR: Add simple raytracing.
Still imprecise.
2017-07-24 15:28:27 +02:00
19323a0ff5 Eevee: Fix clip/hashed alpha prepass/shadow crash. 2017-07-24 15:28:27 +02:00
1d00a66f5d Eevee: SSR: Encode Normal in buffer and add cubemap fallback.
Normals can point away from the camera so we cannot just put XY in the buffer and reconstruct Z later as we would not know the sign of Z.
2017-07-24 15:28:27 +02:00
2a84331f02 Eevee: SSR: Output ssr datas to buffers.
Output in 2 buffers Normals, Specular Color and roughness.
This way we can raytrace in a defered fashion and blend the exact contribution of the specular lobe on top of the opaque pass.
2017-07-24 15:28:27 +02:00
04f8e1b21c Eevee: Ssr: Add ssr id to glossy nodes.
An id is given to each glossy node in order to determine which specular lobe is using ssr.
2017-07-24 15:28:27 +02:00
b7fbe6ae5d Initialize scene layer for evaluation context used by preview renderer
Ideally need to clean and sane and impossible-to-break way of making sure
evaluation context is fully initialized, but that would need some thoughts
and experimentation.
2017-07-24 15:00:44 +02:00
bbb1c0a077 Render preview: Always make sure all ID datablocks references by objects are in bmain
Otherwise we'll have confused dependency graph builder, which wouldn't be able to
build proper graph.

Didn't find a way to avoid world copy here, we can probably escape with some shallow
copy here, but that will currently complicate code a lot.

Ideas to consider here:

- Use shallow copy of existing world after new ID management API is in place.

  Downside would be thread safety, kind of nice to have everything local.

- Switch depsgraph away from ID_TAG and do hash lookup or so.

  This will slow down depsgraph builder, but will make code more reliable.
2017-07-24 14:50:26 +02:00
4fd3582b32 Manipulator: view-selected support
Only applies to selected manipulators
(currently not used for regular manipulators).
2017-07-24 17:26:02 +10:00
d53028b450 Manipulator: Expose Context.manipulator_group
Needed for operators run by the manipulator keymap
so they can access their selected manipulators.
2017-07-24 17:21:09 +10:00
c7bc2f5e87 Manipulator: handle keymaps for selected items
Was only handling keymap items when the cursor
was hovering over a manipulator.
2017-07-24 17:19:36 +10:00
392b6a303e Manipulator: setup_keymap callback
Also remove manipulator_group argument, the info's in the class.
2017-07-24 03:27:57 +10:00
57cbaa15b6 Custom shaders for drawing strand selection. 2017-07-23 08:32:29 +01:00
9a5d06cdd5 Manipulator: use select keymap when enabled 2017-07-23 02:45:41 +10:00
679113fbd5 Basic drawing code for hair edit mode in the new 2.8 draw engine system. 2017-07-22 12:35:40 +01:00
661a05de23 Fix error in previous merge 2017-07-21 18:32:27 -04:00
3aeabe3afa Merge branch 'master' into blender2.8 2017-07-21 18:28:32 -04:00
64fd45b1df Merge branch 'master' into blender2.8
# Conflicts:
#	source/blender/editors/transform/transform_snap_object.c
2017-07-21 14:20:24 -03:00
122706db9c Fix manipulator handles getting added each refresh
The same manipulator map handler would accumulate,
slowing down interactions.
2017-07-22 01:57:23 +10:00
ac0da72a60 Fix compilation error with Collada enabled 2017-07-21 17:44:11 +02:00
911f239d09 Merge branch 'master' into blender2.8 2017-07-21 16:08:31 +02:00
5605c26fcd Fix function declaration of some modifiers
Those functions did not use evaluation context.

Also fixed lots of unused variables warnings caused by commented out code which
needs to be ported away from DerivedMesh and to evaluation context.
2017-07-21 15:54:42 +02:00
cd301bf654 Depsgraph: Cleanup, remove unused function argument 2017-07-21 15:37:51 +02:00
9c2f55baa1 Fix compilation error with smoke and rigid body disabled 2017-07-21 15:36:59 +02:00
1c4c288727 Pass EvaluationContext argument everywhere
Note that some little parts of code have been dissabled because eval_ctx
was not available there. This should be resolved once DerivedMesh is
replaced.
2017-07-21 14:47:26 +02:00
9edb7e49d7 Depsgraph: Fix missing material update when changing links in node tree 2017-07-21 14:20:30 +02:00
4e28d88ece Fix T51724: Blender 2.80 EEVEE, Cycles, Clay Black Wall Graphical Glitch 2017-07-21 12:08:25 +02:00
9fbef5d5d5 Merge branch 'master' into blender2.8 2017-07-21 11:18:02 +02:00
c425653f16 Set face-map to active when selecting
It was annoying have to use select operator to know which facemap
applies to the active face. This behavior follows materials.
2017-07-21 15:50:58 +10:00
3ededb19d8 Depsgraph: Fix crash when updating materials with copy on write enabled
The code was freeing GPU materials from non-main thread.
2017-07-20 17:48:36 +02:00
dfcb568c16 Fix T51925: Eevee: Animated Eevee values slowdown
Move material update from RNA callback to dependency graph.
2017-07-20 17:48:36 +02:00
177a8f6dab Manipulator: add access to manipulator's group 2017-07-21 00:51:03 +10:00
6b0d4302be PyAPI: use instancing when supported
This means when a new data-type is returned it will use the same
instance as the previously created one (if it exists).
2017-07-21 00:50:18 +10:00
57ee488404 Partially revert previous commit, some unwanted changes sneaked in 2017-07-20 16:15:13 +02:00
21f27692da Depsgraph: Use explicit material update operation code
Avoids string comparison on key matching.
2017-07-20 16:03:04 +02:00
83b0bf9166 Depsgraph: Solve TODO about more granular particle settings update tagging 2017-07-20 15:38:48 +02:00
905366ca7e Fix/workaround T52127: Combed hair from 2.78 not showing when appending
Quick solution to prevent particle components from being tagged for complete
re-evaluaiton.
2017-07-20 15:16:57 +02:00
84a87bf45a Depsgraph: Fix crashes when OCIO configuration is missing
We were creating copy on write version of scene prior to validating color management
settings for the original scene.
2017-07-20 15:00:09 +02:00
b7d0cfaa60 Depsgraph: Fix missing UV layers with copy on write enabled 2017-07-20 14:29:13 +02:00
00ddbd5848 Depsgraph: Fix crash with copy on write when scene has legacy bases
The remapping code was creating plkaceholders for objects coming from legacy
bases, but since those objects were never created by dependency graph (since
they are supposed to be ignored) the copy on write relations creation was
confused.

Now we do some special trickery to clear legacy bases on copy on write.
2017-07-20 13:27:34 +02:00
f42bb9d278 Depsgraph: Ignore groups from copy on write expansion
Groups will not have IDs in the dependency graph, so we shouldn't
create them for CoW as well.
2017-07-20 13:27:34 +02:00
f5f34a9aa6 RNA: face-map access
Currently RNA doesn't give us a good way of accessing singleton layers,
for now expose as a layer list (skin & paint-pask do this too).

Noted in T47811 that this should be changed.
2017-07-20 19:52:26 +10:00
819f3b37da BMesh face map layer access 2017-07-20 19:52:26 +10:00
Dalai Felinto
eee4755c74 Fix active object doesn't show on templateID
Before that if you went to the object panel tab in the Properties Editor
the active object wouldn't show in the first panel.
2017-07-20 10:37:53 +02:00
0e2f8ed8a6 Depsgraph: Move strict checks under ifdef blocks
Those checks are not always helpful, since id remapping doesn't want to
worry about which components to tag for update. Perhaps in the future we
will introduce special flag which would mean "tag everything possible"/
2017-07-20 09:44:09 +02:00
Julian Eisel
827dc700ba Fix T51969: Filebrowser "Open File" button disappear when double-click thumbnail
This reverts commit 82ba89b042 (which caused T51969) and adds an
alternative fix (don't unset area stored in modal handler for fileselect
handlers).
2017-07-19 21:46:30 +02:00
adc43ff43f Merge branch 'master' into blender2.8 2017-07-20 03:53:44 +10:00
7fd4ad448c Clay Engine: Fix blue noise warning when compiling without clay. 2017-07-19 18:17:56 +02:00
02e318e8b9 Eevee: Fix crash when using lamps in dupli groups. 2017-07-19 18:17:56 +02:00
Dalai Felinto
2382f979e2 Doversion: Set Clay when opening "Blender Render" engine scenes
We get already enough reports of people complaining about crashes on
edit mode unaware that they are in the non-supported Blender Render
engine.

Blender Render is going away, no reason to keep it around. Once we have
a nice fallback on Eevee and fast file loading we can default to Eevee
instead.
2017-07-19 18:14:50 +02:00
9f9244b6ae Depsgraph: Remove redundant argument from add_id_node() 2017-07-19 17:31:32 +02:00
e29c54674c Depsgraph: Fix strict compiler error with copy on write disabled 2017-07-19 16:26:22 +02:00
53c1d15675 Depsgraph: Fix particle system freeing accessing freed particle settings
Need to ensure CoW IDs are freed in the right order.
2017-07-19 16:21:12 +02:00
496d18614f Depsgraph: Fix heap use after free when freeing scene with compositor
This is the fake ID nature of compositor again. Need to discard such
pointers before freeing datablock even for scenes (before it was done
for objects only).
2017-07-19 15:20:07 +02:00
6bb7a4cdf2 Depsgraph: Fix assert failure on Cycles render
Was happening when there was material in bmain but not used by any object.
2017-07-19 15:20:07 +02:00
17dcdbcf16 Depsgraph: Fix remapping of node trees when they reference self material 2017-07-19 15:20:07 +02:00
e49aa6beac Depsgraph: Add missing expansion od custom bone shapes 2017-07-19 15:20:07 +02:00
5d9a1b440b Depsgraph: Fix wrong ID remapping when armature object is constructed prior to it's targets
Previously it was possible to run into situation when armature is constructed prior to
objects which are used for it's constraints. This was causing wrong scene evaluation.

Now we create placeholders for objects used by armature in case they don't have ID node
yet, which ensures we have proper mapping from original to copy-on-write ID pointer.
2017-07-19 15:20:07 +02:00
a532fe561e Depsgraph: Ensure scene camera object is always built 2017-07-19 15:20:07 +02:00
b2ca2bb591 Depsgraph: Add code which helps catching cases when requested ID node is not ready yet
This shows the bug when IK solver doesn't update reliably when targeted an external
object and when that object is handled by build_object() after the armature.
2017-07-19 15:20:06 +02:00
49e496118b ID: Add run-time flag indicating that ID is coming from copy-on-write 2017-07-19 15:20:06 +02:00
44c6d45c2e Depsgraph: Fix compilation error in previous commit 2017-07-19 15:20:06 +02:00
c2ffea7f12 Depsgraph: Remove hacky workaround for copy-on-write tagging flushing updates to everything
Wasn't working reliably,m and it's somewhat dangerous anyway. Seed something smarter.
2017-07-19 15:20:06 +02:00
3212e72cfe Depsgraph: Fix crash opening file with IK solver with copy on write enabled
The issue was caused by id_copy_no_main() changing pointers of constraints used
in pose to a newly allocated ID. This is correct, but caused confusion too our
copy on write remapping, because we are mimicing inplace duplication by copying
memory over from a temporarily duplicated ID to a proper placeholder. This was
causing dangling pointers in pose to a temporarily allocated ID.

Now we add special code to remapping callback which replaces temporary ID with
a proper one.
2017-07-19 15:20:06 +02:00
ac136babb5 Depsgraph: Restore ID datablock tag when Object is tagged with OB_RECALC_DATA
Was lost in one of the previous commits.
2017-07-19 15:20:06 +02:00
3efde4a03c Depsgraph: Restore workaround for CoW objects not being fully expanded 2017-07-19 15:20:06 +02:00
17cd9f8df4 Depsgraph: Prevent wrong particles state when canceling playback 2017-07-19 15:20:06 +02:00
c3f64ea009 Depsgraph: Fixes to make particle system behave more correct
Couple of main things here:

- Properly handle PSYS_UPDATE_* flags from DEG_id_tag_update.

  There are still some possible issues here related on the fact
  that we don't differentiate different PSYS_UPDATE_* flags here
  and handle the mall the same.

  Other possibility here is that object level particle settings
  evaluation might be forced when particle system evaluation is
  tagged for update. Didn't see actual issue here yet, but need
  a closer look.

- Don't tag non-object datablocks on visibility changes.

  Those don't depend on visibility anyway. This prevents particle
  settings IDs from flushing updates to all objects, causing all
  cached particles to be lsot.

- Only update translation and geometry components on visibility
  changes.

  Once again, this prevents particle cache from being invalidated.

  We might need to tag material components here still tho.
2017-07-19 15:20:06 +02:00
a31233f5d2 Depsgraph: Stop tagging all IDs for update on depsgraph rebuild
This code needs to be changed. For the time being CoW might become less stable,
but need to stop doing such tag for other work.
2017-07-19 15:20:06 +02:00
414cc821d8 Depsgraph: Initial implementation of more granular tagging
This commit makes it so that only ID components which correspond to the tag
flag are tagged for update (previously the whole ID would have been updated
in the most of cases).

This allows us to have more granular tag flags and prevent tagging of things
we don't want to be tagged.
2017-07-19 15:20:06 +02:00
50f5f0957c Depsgraph: Cleanup, de-duplicate couple of utility functions 2017-07-19 15:20:06 +02:00
5eddc183b0 Depsgraph: Cleanup, remove unused untested functions 2017-07-19 15:20:06 +02:00
5727e8706f Depsgraph: Use dependency graph flush routines to update particle settings
Previously tagging particle settings for update will iterate over all objects and
all their particle system to see whether something needs an update or not. Now we
put ParticleSettings as an ID to the dependency graph, so tagging it for update
will nicely flush updates to all dependent particle systems.

Current downside of this is that due to limitation of flush routines it will cause
some extra particle system re-evaluation when it technically not needed, and what's
more annoying currently it will discard point caches more often.

However, this is a good and simple demonstration case to improve tagging/flushing
system to accommodate for such cases (similar issues happens with CoW and shading
components). So let's try to find some generic solution to the problem!
2017-07-19 15:20:06 +02:00
2fe5cf4807 Depsgraph: Use explicit parameters eval operation code
This replaces usage of generic PLACEHOLDEWR with string lookup with more
explicit opcode. This should make it faster to build dependency graph by
avoiding string comparisons when it's not needed.

There should be no user measurable different.
2017-07-19 15:20:06 +02:00
917bff4f44 Depsgraph: Add generic parameters evaluation operation code
Currently unused, but the idea is to use this code instead of placeholder
operation code followed by string comparison.
2017-07-19 15:20:06 +02:00
9356119765 Depsgraph: Use more explicit naming for operation codes
This way it's better indication what group of operation codes things belongs to.
2017-07-19 15:20:06 +02:00
ec2bca26e8 Despgraph: cleanup, make separation of opcodes strings more clear 2017-07-19 15:20:06 +02:00
62de80166e Depsgraph: Use more explicit name for particle system evaluation opcode 2017-07-19 15:20:06 +02:00
abe0527e0f Manipulators: use nearest manipulator
Add utility function to get the nearest hit
2017-07-19 20:12:24 +10:00
dd64cedd0b Merge branch 'master' into blender2.8 2017-07-19 14:38:22 +10:00
Dalai Felinto
231d688219 Outliner: Use scene_layer from context 2017-07-18 17:14:43 +02:00
Dalai Felinto
c226488a27 Layer cleanup: get rid of one of the placeholder functions 2017-07-18 11:16:14 +02:00
Dalai Felinto
f3039c7e78 Context/Workspace: Get scene layer from workspace 2017-07-18 11:16:14 +02:00
3534c3e0df Eevee: Avoid crash when using dupli objects.
This is waiting a for a better solution.
2017-07-18 10:05:16 +02:00
fe8fc79cee Eevee: Fix transparency not drawing after volumetrics.
Fix T52089, Fix T52091
2017-07-18 10:05:16 +02:00
0926b896b6 Eevee: Fix crash with transparency. 2017-07-18 10:05:16 +02:00
876cc5b7c0 Merge branch 'master' into blender2.8 2017-07-18 18:10:19 +10:00
2475dbdc94 Merge branch 'master' into blender2.8 2017-07-18 13:09:36 +10:00
Dalai Felinto
f04c06498b Fix layers unittest - we cannot use nestted get_pointer calls
Remember to update your //lib/tests folder as well.

Patch by Bastien Montagne(mont29)
2017-07-17 18:46:00 +02:00
Dalai Felinto
0e49d5376c Revert "Unittests: Workaround for basact->object.id.name written as DATA"
This reverts commit aa578fba53.
2017-07-17 18:06:49 +02:00
Dalai Felinto
aa578fba53 Unittests: Workaround for basact->object.id.name written as DATA
This was introduced on e7fb013a60. Although I would love to investigate the
issue I'm mostly concerned with gettings the tests working again.
2017-07-17 16:22:42 +02:00
Dalai Felinto
a258c5d325 Unittests: Make sure layer tests pass with or without workspace 2017-07-17 16:22:07 +02:00
Dalai Felinto
36977a962b Removing unused layer TODO placeholders 2017-07-17 14:40:12 +02:00
Dalai Felinto
8dadeab47f Fix shadow geometry shader 2017-07-17 14:28:17 +02:00
4c835b9168 Eevee: Fix double promotion. 2017-07-17 11:01:31 +02:00
Dalai Felinto
728d64c5dc Fix blenderplayer 2017-07-17 09:30:39 +02:00
f942511fd2 Manipulator: allow ID-writing for most callbacks 2017-07-17 17:20:54 +10:00
ab5be294ce Manipulator: split alpha out of color property
Gives more convenient access from Python: `mathutils.Color`

Also correct some copy-paste error w/ property subtypes.
2017-07-17 15:06:18 +10:00
02257ace22 Fix crash re-registering the same manipulator type
Wasn't unlinking from the group instance.
2017-07-17 14:36:20 +10:00
d221a999cb Manipulator: add snap flag 2017-07-17 14:16:23 +10:00
193d7d6333 Merge branch 'master' into blender2.8 2017-07-17 13:21:05 +10:00
a11808a248 Manipulator: allow py manipulators w/o properties
These could be used for manipulators that run operators.
2017-07-17 12:29:37 +10:00
65d2374c80 Merge branch 'blender2.8' into strand_editmode2.8 2017-07-16 11:48:39 +01:00
a3d9ef2ea5 Merge branch 'master' into blender2.8 2017-07-14 17:26:46 -03:00
37242f0a47 Merge branch 'master' into blender2.8
# Conflicts:
#	source/blender/editors/transform/transform_snap_object.c
2017-07-14 16:56:36 -03:00
ebc22b4490 Fix MSVSC compiler warning
A void function cannot return a value
2017-07-14 20:59:26 +02:00
0736d567f0 Snap System: minor issues
rename obj -> ob_iter
2017-07-14 14:46:07 -03:00
Dalai Felinto
2a489273d7 Implement Uniformbuffer objects for nodetree parameters
For users that means you can tweak shaders in the nodetree and things
are way faster. This is a huge improvement, particularly in
systems that have no shader cache.

From the code perspective it means we are no longer re-compiling the
shader every time a value is tweaked in the UI. We are using uniforms
for those values.

It would be slow to add that many uniforms for all the shaders. So
instead we are using UBO (Uniform Buffer Objects).

This fixes the main issue of T51467. However GWN_shaderinterface_create() still
needs to be improvedi. When opening a .blend all shaders are compiled once, so
optimizing it will bring a measurable impact.

========================================================================
NOTE: This breaks update of Cycles material upon nodetree nodes
tweaking. It will be fixed separately by depsgraph, once tackling T51925
(Animated Eevee values slowdown).

The idea is to make Depsgraph update more granular. The XXX TODO in
rna_nodetree.c will be tackled at that time as well.
========================================================================

Reviewers: sergey, brecht, fclem

Differential Revision: https://developer.blender.org/D2739
2017-07-14 17:46:10 +02:00
73b1425297 DwM: don't use context to apply color-management
Would give different results for off-screen rendering.
2017-07-15 00:50:13 +10:00
51442b64d6 Merge branch 'master' of git@git.blender.org:blender.git into blender2.8 2017-07-14 11:24:43 -03:00
8f14b96f7b Merge branch 'master' of git@git.blender.org:blender.git into blender2.8 2017-07-14 10:42:59 -03:00
92f3b4ac64 Depsgraph: Initial support of armatures for copy-on-write
This commit makes simple cases to work, for example:

- IK solver to an external object
- Object with Armature modifier, "parented" to the deforming armature
  (via animation).

More complicated setups (like agent rig) are crashing still.
2017-07-14 15:06:50 +02:00
Dalai Felinto
0ea4bb51df Another fix for snapping after merge in 2.8 2017-07-14 15:06:17 +02:00
Dalai Felinto
4467efe971 Fix snap in 2.8 after poor merge from master
If you merge from master to blender2.8 after a commit, remember to test in 2.8, otherwise what is the point?
Specially if it's a non-essential commit such as c9817c67fc.

Bug introduced on: f4155d3778 (the merge
that included the above commit).
2017-07-14 14:43:54 +02:00
Dalai Felinto
9d318acfa7 Merge remote-tracking branch 'origin/master' into blender2.8 2017-07-14 14:34:46 +02:00
Dalai Felinto
78e2238fe4 Revert "Fix T51794: Crash on hair file when opening with no UI"
This reverts commit 0095f4f834.
2017-07-14 11:44:26 +02:00
Dalai Felinto
b48694639a Workspace: Fix crash on preview, and sanitize placeholder functions
This commit effectively makes workspace switching useless as far as the
active scene layer goes.

The functions from the scene layer API to get the correct scene layer
from "context" were a placeholder to be addressed by the workspace
commit.

When workspace was merged, however G.main was used as a replacement to pass the
correct argument for the functions. As it turned out (surprise!) this
leads to crash on render preview.

We need to get rid of:
* BKE_scene_layer_context_active_ex_PLACEHOLDER
* BKE_scene_layer_context_active_PLACEHOLDER

And either use SceneLayer explicitly or replace it by:
* BKE_scene_layer_from_workspace_get
2017-07-14 11:42:31 +02:00
018df5a49a Cleanup: use 'r_' prefix for return args 2017-07-14 17:05:22 +10:00
d31276abd0 Cleanup: long lines 2017-07-14 16:56:02 +10:00
661f5a24d1 DwM: Show face-mask overlay even with full-shading
Without this face selection would be used but invisible,
display this over fully shaded surface.
2017-07-14 16:45:47 +10:00
25dba156be Fix T51945: LMB select swaps manipulator buttons 2017-07-14 16:14:19 +10:00
886ea37572 Fix T51979: Eevee: Bloom artifacts w/ zero area faces 2017-07-14 15:27:08 +10:00
6f66498c10 Revert "Eevee: Fix the NaN pixel issue."
This reverts commit d02711ed88.
2017-07-14 14:45:18 +10:00
f4155d3778 Merge branch 'master' of git@git.blender.org:blender.git into blender2.8
# Conflicts:
#	source/blender/editors/transform/transform_snap_object.c
2017-07-13 20:12:17 -03:00
ad7f782e17 Merge branch 'master' into blender2.8 2017-07-13 18:05:20 +02:00
31ad03dbde Merge branch 'master' into blender2.8 2017-07-13 17:36:52 +02:00
f8f90e1312 Fix compilation error in Freestyle 2017-07-13 17:24:12 +02:00
474454be39 Cleanup/rename etc. dashed line shaders.
Goal is to make them more modular, to allow more variants (variable
single-color, thickness, ...) to be added without having to
copy-and-change-one-line of whole chain of shaders.
2017-07-13 16:47:58 +02:00
c9aef27326 Depsgraph: Begin work on making depsgraph per-scene-layer
This is a first step towards proper depsgraph "ownership", where
we would allow scene to be in multiple states dependent on active
workspace or scene layer.

This commit introduces a basic API to get proper dependency graph
for a given scene layer. It also renames scene->depsgraph to
depsgraph_legacy, so it's easier to search0-n-replace in the future.
2017-07-13 15:43:36 +02:00
065cd6e4e4 Remove unused function
It wasn't really correct from the copy-on-write point of view anyway,
so better not to have potentially really dangerous function.
2017-07-13 15:23:37 +02:00
38cfd7b9e7 Depsgraph: Fix crash with copy-on-write enabled after recent changes
The issue was caused by original datablock being returned where we
were expecting copy-on-written one to be returned.
2017-07-13 15:23:37 +02:00
07c6011b57 Depsgraph: Add extra information to debug logging 2017-07-13 15:23:37 +02:00
84c6ce6b04 Merge branch 'master' into blender2.8 2017-07-13 21:24:02 +10:00
ab05108acb Depsgraph: Make it more explicit in naming what version of data getetrs returns 2017-07-13 12:57:19 +02:00
5fe2423ed5 Use explicit scene_layer variable name for public API 2017-07-13 12:51:35 +02:00
Dalai Felinto
8c17b5fe42 Eevee small cleanups 2017-07-13 12:04:49 +02:00
Dalai Felinto
445963f299 Eevee: Fix crash on eevee lamps and shadows 2017-07-13 12:04:49 +02:00
eb759730b1 Correct error from texface removal
Missed stencil layer
2017-07-13 19:30:00 +10:00
a3240df269 Always using full shading for eevee + sculpt mode
Also disable for dyntopo & multires since its currently not supported.
2017-07-13 19:09:40 +10:00
86b7698a3e Merge branch 'master' into blender2.8 2017-07-13 17:21:11 +10:00
ffea77253e Merge branch 'master' of git@git.blender.org:blender.git into blender2.8 2017-07-12 20:45:02 -03:00
b4988d01cb DwM: Option to use final material over mode shading
Support using full material shading in sculpt & paint modes mode.

Access 'Full Shading' from the display panel when in paint modes.
2017-07-13 01:59:44 +10:00
95a7a0a06e Gawain: add GWN_vertbuf_clear
Needed to clear the buffer without freeing.
2017-07-13 01:48:52 +10:00
5ee5c595ba Merge branch 'master' into blender2.8 2017-07-12 23:18:11 +10:00
59b93123e9 Merge branch 'master' into blender2.8 2017-07-12 11:49:43 +02:00
e5ee6cb448 Depsgraph: Remove meaningless comment
We are already on the new depsgraph only for quite some time now.
2017-07-12 11:08:51 +02:00
0837d19126 Merge branch 'master' into blender2.8 2017-07-12 13:59:13 +10:00
ac76a3caba Merge branch 'master' of git@git.blender.org:blender.git into blender2.8 2017-07-11 17:06:43 -03:00
1b91b443e0 Eevee: Transparency: Fix crash when using transparent shadows.
Fixes T52024
2017-07-11 21:52:30 +02:00
593b80143b Merge branch 'master' of git@git.blender.org:blender.git into blender2.8 2017-07-11 14:24:32 -03:00
538475dec7 Merge branch 'master' of git@git.blender.org:blender.git into blender2.8
# Conflicts:
#	source/blender/editors/transform/transform_snap_object.c
2017-07-11 13:54:08 -03:00
11ee5aa4f9 Avoid any possibility of using scene from different main in CTX_data_scene_layer
While these functions might be considered a temporary solution, please still be
very accurate about data ownership and where data is coming from.
2017-07-11 16:40:18 +02:00
ded2b30ebc Alembic: Adjusted unittest for Blender 2.8 2017-07-11 16:28:52 +02:00
4233ccfb6c Merge branch 'master' into blender2.8 2017-07-11 16:18:17 +02:00
Dalai Felinto
e5d74954bf RNA/UI: Always use capitalized words in the UI 2017-07-11 15:46:15 +02:00
0a57597aff Temporary fix for crash related to VBO update on shader change
This frees the whole mesh batch cache, instead of only the required
parts, as freeing specific parts of a cache is currently causing
crashes.
2017-07-11 13:03:27 +02:00
64890a62cd Eevee: Add failsafe check in shadow material. 2017-07-11 12:42:59 +02:00
c0f2cbab4e Eevee: Transparency: Add transparent Shadow method UI. 2017-07-11 12:39:35 +02:00
ec9330d206 Eevee: Fix default closure to match cycles. 2017-07-11 12:39:35 +02:00
91d324b3dc Eevee: Transparency: Add support for Clip and Stochastic shadows. 2017-07-11 12:39:35 +02:00
a57bc75576 Eevee: Transparency: Add hide backside option. 2017-07-11 12:39:35 +02:00
a098d02718 Eevee: Transparency: Add object center Z sorting.
Better algo should take bounding box center, but it's not referenced yet in the draw call and cannot be tweaked by user.
2017-07-11 12:39:35 +02:00
ad7458d00c Eevee: Transparency: Add Alpha Blend mode. 2017-07-11 12:39:35 +02:00
d6b46f9ea5 DRW: Make Additive blending alpha premult. 2017-07-11 12:39:35 +02:00
d35c24f87b Eevee: Transparency: Add support for blend ADD and MULTIPLY.
This introduces a new transparency pass.
It bypass the radial distance encoding in alpha for the transparent shaders.
2017-07-11 12:39:35 +02:00
55022884ba DRW: Add shading group state disable.
This is a way to remove some state flag per Shading Group.
2017-07-11 12:39:35 +02:00
eb8dddaab1 Eevee: Material: Code cleanup in order to add transparency support. 2017-07-11 12:39:35 +02:00
05bef13b53 Eevee: Add support for Alpha clip and Hashed Alpha transparency.
Hashed Alpha transparency offers a noisy output but has the benefit of being correctly ordered. Noise can be attenuated with Multisampling / AntiAliasing.
2017-07-11 12:39:35 +02:00
e2c0197a96 Merge branch 'master' into blender2.8 2017-07-11 12:30:30 +02:00
Dalai Felinto
2325d15d02 Lamps should not have their own gpu material
This was leading to multiple crashes when freeing the lamps or
materials when opening old files.

Follow up on b50839038d.
2017-07-11 11:02:56 +02:00
64dd9a117d Merge branch 'master' into blender2.8 2017-07-11 14:21:05 +10:00
bb0bdc6ce2 Revert "Revert "Revert "Temporarily disable material preview (T51796 workaround)"""
This reverts commit 6df053e527.
2017-07-10 16:49:04 +02:00
205d750a63 Depsgraph: Use explicit bmain pointer passed to layer utilities
it is not necessarily that depsgraph is built from G.bmain.

This will solve issue reported in T51782.
2017-07-10 16:47:12 +02:00
8692c3a83f Depsgraph: Fix wrong layer used
Should be context, not render active one here.
2017-07-10 15:45:06 +02:00
6df053e527 Revert "Revert "Temporarily disable material preview (T51796 workaround)""
The "fix" happened due to a mistake in copy-on-write commit, that mistake solved
preview render but broke something else.

This reverts commit 45720922f7.
2017-07-10 15:43:04 +02:00
45897f12f8 Fix T51931: VBO not updating when UVs are added to shader node tree
UVs need specific data in the VBO, which is not computed unless the
shaders assigned to the mesh actually use UVs. When adding UVs to the
shader, the VBOs were not being recomputed to include the required data.

This adds a DEG relation between the shader and the mesh, and recomputes
the required data if the shader changed.

Thanks Sergey, for all the DEG stuff...
2017-07-10 14:43:57 +02:00
d33cacf7e4 Fix image empties not drawing
A pointer to the uniform data for the empty drawing was being freed
before the actual draw call, which invalidates the uniform.

This makes the data only be freed after drawing.
2017-07-10 11:39:08 +02:00
7d5e9285b5 Merge branch 'master' into blender2.8 2017-07-10 17:48:57 +10:00
2bd908ca6e Merge branch 'master' into blender2.8 2017-07-10 16:35:56 +10:00
Dalai Felinto
2ad524bc83 Fix blenderplayer 2017-07-09 19:53:33 +02:00
f7e4484bfe Merge branch 'master' into blender2.8 2017-07-08 23:45:36 +02:00
fdadb4829c Gawain: Add support for compressed index with instancing. 2017-07-08 18:21:49 +02:00
eb8c45508d Merge branch 'master' into blender2.8 2017-07-08 02:08:41 +02:00
5eead4b74e Cycles: recognize Eevee material output. 2017-07-08 01:14:50 +02:00
db28e2deb9 Merge branch 'master' into blender2.8 2017-07-08 01:02:11 +02:00
Dalai Felinto
e960cecdf8 GPU: Silence warning of potentially unused variable (NormalMatrix) 2017-07-07 15:10:09 +02:00
Dalai Felinto
15f5457502 Draw Manager: Use defines instead of hardcoded enum values 2017-07-07 12:34:36 +02:00
09bf3b1764 Eevee: Show the metadata and output panel when eevee is selected as a render engine 2017-07-07 11:57:38 +02:00
Dalai Felinto
3615350957 Merge remote-tracking branch 'origin/master' into blender2.8 2017-07-07 11:27:48 +02:00
d290266049 Eevee: Add dimension panel to eevee
Up until now users had to switch to Blender Internal to set the dimension of their openGl renderings. This simple change adds the panel at the top of the scene render tab.
2017-07-06 23:43:55 +02:00
6eea22b2b7 Eevee: Fix Planar Reflection bug / background artifact.
This was cause by a missing uniform.
2017-07-06 18:28:25 +02:00
d35e525d10 GPUTexture: Change default comparison mode to GL_NONE.
This default will prevent more errors in the future.
Also compare mode is less used nowadays.

Fixes T51904
2017-07-06 17:02:16 +02:00
d02711ed88 Eevee: Fix the NaN pixel issue.
It's cause by degenerate triangle having normals set to (0,0,0) which may not be compressed like it should.
This fix the problem in the final indirect lighting evaluation which might be costly.
2017-07-06 16:01:21 +02:00
c217d518ef Eevee: Unlock compatible bsdfs in node add menu. 2017-07-06 13:32:19 +02:00
e5462421c0 Eevee: Add support for common BSDFs.
Add Diffuse BSDF, and Glossy.

Also Use World normal instead of view normal as input.
2017-07-06 13:32:19 +02:00
a69e3c9ee1 Fix T51943: Depsgraph: world update happening eternally on background (set) scene
The issue was caused by updates being flushed for all scenes, while actual update
was only called for an active one.

Not sure why do we need to flush updates for all scenes, so now we only flush
scenes which are updated.
2017-07-06 13:29:59 +02:00
9d71ec5f8d Merge branch 'master' into blender2.8 2017-07-06 12:21:21 +02:00
f67c331bed Eevee: Volumetrics: Avoid light leaking if last step is going trough geometry. 2017-07-06 00:28:13 +02:00
cb55498159 Merge branch 'master' into blender2.8 2017-07-05 22:25:05 +02:00
91808a67e8 Eevee: Volumetrics: Fix enum flag. 2017-07-05 22:17:09 +02:00
7b565c8a76 Eevee: Fix typo... 2017-07-05 19:57:02 +02:00
Dalai Felinto
5495f89cf6 Fix User Interface for Volumetric 2017-07-05 19:23:57 +02:00
c62f82e35b Eevee: Fixups.
Fix float promotion and missing layer parameters.
2017-07-05 19:15:32 +02:00
f6c739cbcd Eevee: Volumetrics: Add Light contribution clamping.
This avoid too much variance at light centers and remove some noise.
2017-07-05 19:14:50 +02:00
031a4d5e22 Eevee: Volumetrics: Do not add anisotropy attribute, average it.
This makes no sense to add theses. In cycles, each volume node is computed separatly. In eevee only the combined parameters are evaluated and phase should be averaged in this case.
2017-07-05 18:31:43 +02:00
b5ee6dd9a3 DrawManager: Fix manipulator blend mode.
This was giving issue with volumetrics.
2017-07-05 18:29:40 +02:00
291b365e26 Eevee: Volumetrics: Add settings. 2017-07-05 18:28:48 +02:00
8b78a8d9bc Eevee: Volumetrics: Add support for Position Coordinates.
This enables texturing of the noise via procedural or baked textures.
Note that it gets quickly really heavy.
2017-07-05 18:21:06 +02:00
f8aab24fb5 Eevee: Volumetrics: Add Volume Absorption node. 2017-07-05 18:21:06 +02:00
d5448eac6c Eevee: Volumetrics: Colored Transmittance support.
Render the transmittance in another color buffer and apply it separatelly.
It's a bit more slow because the upsample step needs to be done twice.
2017-07-05 18:20:19 +02:00
ed4e62997e Eevee: Volumetrics: Match cycles scattering. 2017-07-05 18:03:36 +02:00
Dalai Felinto
971ecfa721 Eevee: Move volumetric to its own panel, new settings to come 2017-07-05 17:58:27 +02:00
Dalai Felinto
6de28e7f90 Override template: Add text and icon optional parameters 2017-07-05 17:58:27 +02:00
Dalai Felinto
eb48eeba84 Expose rna_translate_ui_text to be used for interface templates 2017-07-05 17:58:27 +02:00
bdeeb29482 Merge branch 'master' into blender2.8 2017-07-05 15:50:01 +02:00
f3764d51bd Merge branch 'master' into blender2.8
Conflicts:
	source/blender/editors/space_view3d/drawobject.c
2017-07-05 09:20:48 +02:00
Dalai Felinto
84d20dd227 Eevee: Fix world test for volumetric
Compiler even throws a warning at this.
2017-07-04 18:07:39 +02:00
3898236b81 Third fix for my merge: crash after switch to edit mode reported by @dfelinto 2017-07-04 17:53:19 +03:00
0ef48ad504 One more fix for merged 'normal map tangents not working correctly when there are no UV maps.' 2017-07-04 16:25:49 +03:00
f23ed929ee Merge branch 'master' into blender2.8
Conflicts:
	source/blender/makesdna/DNA_particle_types.h
2017-07-04 13:13:49 +02:00
fc8f6e8f7a Eevee: Fix Closure define. 2017-07-04 11:40:12 +02:00
b09052002c Eevee: Add support for volumetrics in node tree.
Only volume scatter is implemented for now.
2017-07-03 22:08:33 +02:00
2eef097831 GPU Codegen: Add new closure socket type.
This allow specialized shaders to redefine the closure interface to fit their needs.

For instance, Volumetric closure needs to pass more than one vec4 (absorption vec3, scattering vec3, anisotropy float).
2017-07-03 22:08:33 +02:00
65b01014b9 Eevee: Initial implementation of Volumetrics. 2017-07-03 22:08:33 +02:00
9d2ee7998a Draw Manager: Add new blend mode for transmission.
This blend Mode is doing  Source + Destination * Alpha.
2017-07-03 22:08:33 +02:00
9b66a320bf Eevee: Fix luma calculation for lamp fresnel. 2017-07-03 22:08:33 +02:00
Dalai Felinto
e571e6d60e Fix edit mode not drawing
This was introduced on 1ad0cc6bde.
2017-07-03 21:48:39 +02:00
Dalai Felinto
3eeac771d0 Fix alembic after merge from master 2017-07-03 21:16:34 +02:00
Dalai Felinto
3fc342bda0 Fix building with gcc6 after merge from master 2017-07-03 21:16:34 +02:00
de2faa395f Fix for merged 'normal map tangents not working correctly when there are no UV maps.' 2017-07-03 20:13:52 +03:00
e1482841dd Merge branch 'master' into blender2.8 2017-07-03 19:53:00 +03:00
Dalai Felinto
1ad0cc6bde Eevee: Hide lightprobe data when using "Only Render" 2017-07-03 16:16:24 +02:00
Dalai Felinto
d97c3bc7ad Merge branch 'master' into blender2.8 2017-07-03 15:18:46 +02:00
Dalai Felinto
871325e26f Fix T51963: Eevee: ASAN crash on copy_attrib_name
Bug introduced on f6bb3262f1.

CustomData_get_named_layer returns a different result than
CustomData_get_named_layer_index.
2017-07-03 12:47:00 +02:00
3de5370e9d Cleanup: unused defines 2017-07-01 20:19:12 +10:00
Dalai Felinto
49a35033be Fix T51877: Deleting a scene uses freed memory
At the moment libblock_remap_data_preprocess is using
FOREACH_SCENE_OBJECT to iterate over all the objects of the scene and
unlink them.

However we were storing a reference to the Base of the removed object.
Anyways, the loop is now sanitized so that this crash no longer happens.

Also now we have an unittest for this.
2017-06-30 19:03:02 +02:00
Dalai Felinto
b43cdc91ce Fix T51721: OpenGL Detection is broken on Windows
Now computers that support OpenGl3.3 (but not 4.5) can run Blender 2.8.

For any given HDC, you may only call SetPixelFormat *ONCE* any future
calls for the same HDC will fail. And computers that would support only
OpenGL 3.3 wouldn't have a change to get a valid OpenGL context because
the pixelformat was already set while trying to probe the supported
contexts.

We fix this by splitting the final context creation from the query of
supported OpenGL versions.

Patch by Ray Molenkamp (bzzt_ploink/LazyDodo) with code style fixes and
comments by me.
2017-06-30 13:33:54 +02:00
0831099664 Eevee: Principled BSDF: add support for specular tint + optimisation
Only use clearcoat version if there is something linked or if the clearcoat value is not 0.
2017-06-30 14:12:25 +02:00
178c470c43 Eevee: Fix specular shadowing.
Compute luminance approximation instead of using green channel.
This is to match cycles principled bsdf.
2017-06-30 14:10:42 +02:00
1b4bd1c84e Fix T51118: Outliner crash when unlinking collection
The outliner tree was not being rebuilt after unlinking a collection,
and thus a dangling pointer to the collection was kept in the tree.
2017-06-30 12:32:18 +02:00
1a6ae0c70e DwM: Use GWN_vertbuf_raw_* access for shading data
Gives approx 14% speedup here.
2017-06-30 18:31:04 +10:00
34e4948682 Fix T51919: Tangents need UV's allocated 2017-06-30 17:48:18 +10:00
bc347f6015 Merge branch 'master' into blender2.8 2017-06-30 13:46:53 +10:00
cdb07ff30e Eevee: Fix broken default coordinate (reported via IRC by Dalai Felinto). 2017-06-29 20:23:06 +02:00
Dalai Felinto
98c8b5a6fb No need to free all the shaders when appending or reloading libraries
To recompile all the shaders is expensive. And something to be avoided at all costs.

It was needed before because for every new lamp in the file we needed to
recompile the shaders. Now this is no longer required since we are using
UBOs for the sahders.
2017-06-29 19:07:21 +02:00
Dalai Felinto
2c62493891 Eevee: No need to free all the gpu materials when world changes.
We have a world probe that is used to prevent exactly that.
2017-06-29 18:57:06 +02:00
7c72079381 Fix hair shading after Eevee shader refactor 2017-06-29 18:45:11 +02:00
90e16b8e03 Eevee: Fix world probe with world without nodetree. 2017-06-29 17:32:13 +02:00
5e96df7d27 Eevee: Remove Geometry shader usage for background.
This fix the behaviour of the light path node that separates the probes background from the viewport background.
2017-06-29 17:08:13 +02:00
790b15112b Eevee: Fix T51922: Avoid division by 0.
Problem was caused by a division by 0 when rendering the probes. This patch make the visibility equal to 1.0 in this case.
2017-06-29 17:08:13 +02:00
95797336f5 Eevee: Prepare support for future Anisotropic shading. 2017-06-29 17:08:13 +02:00
3888227a7b material Glsl: Fix tangent with new orco. 2017-06-29 17:08:13 +02:00
2eca054e14 Remove dupli-group support for non-empty objects
Behavior for mixing object-data & dupli data was confusing,
exporters and render engines often got it wrong.
2017-06-30 00:03:08 +10:00
f39d06589e Fix warnings in draw_cache_impl files 2017-06-29 15:46:00 +02:00
b606161458 Fix T51821: Viewport not updating when switching worlds 2017-06-29 14:49:46 +02:00
916344b49e Fix error getting the tangent layer name 2017-06-29 21:24:09 +10:00
db71df4f3f Fix world not updating when changing node links
When changing node links for the world material, a redraw of the
viewport was not being triggered.
2017-06-29 12:28:25 +02:00
7dc9e42721 Missing from last commit 2017-06-29 20:33:24 +10:00
fd3589e4c9 DwM: optimize mesh batch conversion
- Replace GWN_vertbuf_attr_set with Gwn_VertBufRaw & GWN_vertbuf_raw_step
  to avoid intermediate copy.
- Avoid extra conversion step with: float[3] -> short[3] -> Gwn_PackedNormal.
  We can skip the short[3].

Gives approx 6% speedup here.
2017-06-29 20:11:16 +10:00
34566aa969 Gawain: add method of stepping over data directly
This avoids using GWN_vertbuf_attr_set which needs to calculate the
offset and perform a memcpy every call.

Exposing the data directly allows us to avoid a memcpy in some cases
and means we can write to the vertex buffer's memory directly.
2017-06-29 20:09:05 +10:00
2343dcf0d2 Gawain: Use common prefix for packed normal 2017-06-29 18:54:23 +10:00
2113dbb013 Merge branch 'master' into blender2.8
Conflicts:
	source/blender/editors/space_outliner/outliner_select.c
2017-06-29 10:11:17 +02:00
10c887762a DwM: no need to calculate face normal 2017-06-29 15:52:08 +10:00
abd9d50faa Cleanup: quiet negative shift warning 2017-06-29 15:34:50 +10:00
f6bb3262f1 DwM: add CD_AUTO_FROM_NAME for mesh conversion 2017-06-29 15:23:47 +10:00
15079b0b43 Fix crash & performance regression w/ base lookup
Was doing O(n^2) list lookups with blender-render drawing & transform.
Also missing NULL checks would crash.

Use Object.base_flag (already used by new draw manager in places)
to avoid list lookup.

Note, transform still performs inefficient lookups,
but only for selected parents (like 2.7x), not all parents.
2017-06-29 12:19:22 +10:00
e14fd19105 Eevee: Add Initial support for Principle BRDF.
Lots of things not working yet but it's comming.
2017-06-29 01:47:59 +02:00
8d57f4e3c6 Eevee: Remove ShadingData struct.
That was a bad idea after all.
2017-06-29 01:47:59 +02:00
2117334737 Fix assert calculating tangents with no faces 2017-06-29 07:57:23 +10:00
a1a40bfe70 GPUTexture : Un-clamp float rect datas.
We do not need it anymore because we do not use glu anymore. And we need full range for HDRI Lighting.
2017-06-28 22:26:44 +02:00
beb375cdb2 GPU_codegen: Fix geometry shader. 2017-06-28 21:28:24 +02:00
ada6e720f9 GPU_codegen: Add support for passing attributes through the geometry stage.
Should fix some issues with missing attributes in Eevee.
2017-06-28 21:05:43 +02:00
26b699a105 Eevee: Fix shader linking error. 2017-06-28 18:28:52 +02:00
b6a2d255c3 Eevee: Fix Shadow Map bug: fix T51924 2017-06-28 17:21:57 +02:00
03b915d711 Eevee: Fix Shader compilation on certain driver. 2017-06-28 16:51:31 +02:00
6d0dbd3169 Probe: Irradiance Volume: Fix default clip start. 2017-06-28 16:32:08 +02:00
1982e724f4 Eevee: Refactor of shading code to be more modular.
This will enable creating shading models more easily.
2017-06-28 16:32:08 +02:00
0782c9f8dc Fix T51920: Invalidate draw cache when changing object origin 2017-06-28 14:58:25 +02:00
4a061a87e6 DwM: mesh data now only creates data thats used
Read from the GPUMaterial to find custom-data layers used for drawing.

This resolves problem where having UV's would always calculate tangents
causing noticeable slow down compared to 2.7x.
2017-06-28 13:44:28 +10:00
e78c0840f2 DwM: create eevee materials before the mesh
To know which custom-data layers will be needed in the mesh.

No functional change yet.
2017-06-28 13:36:55 +10:00
fc3d0da2fd DWM: Fix own error checking wrong layer type
Would calculate all tangents for every UV layer.
2017-06-28 11:39:05 +10:00
87dd9c31a0 GPU: split GPU_material_from_nodetree in two
Add GPU_material_from_nodetree_find to avoid having to construct other
arguments which won't be used in the case the material is exists.
2017-06-28 10:59:25 +10:00
037876659f Fix own error removing texface
Setting the name crashed with NULL poly layer.
2017-06-28 10:23:27 +10:00
87a95558a0 Fix own error removing texface
Using pointer offsets from different arrays
2017-06-28 10:11:49 +10:00
df70e3de63 DWM: separate tangents from UV conversion
Prepare for different number of UV/Tangent layers.
2017-06-28 09:55:40 +10:00
dbaa6c2aa2 GPU: GPU_generate_pass_new now takes vertex-attrs
Needed so we can tell which custom-data layers to use from the mesh.
2017-06-28 09:37:44 +10:00
2ed82d2e6b Fix missing globalsBlock in edit mode latice drawing
This was causing lattice vertices not to be drawn.
2017-06-27 18:40:39 +02:00
d04f30c5d8 Implement weight colors for lattices in draw manager 2017-06-27 15:59:13 +02:00
6e83ace809 LightProbes: Change 3d view display shape.
Introduce specific shape for each probe type to easily identify them.
2017-06-27 15:00:14 +02:00
cbfdd02f2c Fix typo in Eevee hair UV handling 2017-06-27 11:59:22 +02:00
3cb562c994 mikktspace: minor optimization
Add a safe version of normalize since all uses of normalize
did zero length checks, move this into a function.

Also avoid unnecessary conversion.

Gives minor speedup here (approx 3-5%).
2017-06-27 16:14:58 +10:00
c218d4b008 Eevee: Bloom: fix black bloom artifacts. 2017-06-27 05:18:00 +02:00
62b1d11613 RNA: update_gpu_tag() to force Batch re-generation 2017-06-27 11:09:30 +10:00
e6be5b8a2c Merge branch 'master' into blender2.8 2017-06-27 09:59:36 +10:00
03b46f7941 Cleanup: quiet warning
Passing NULL arg when nonnull attr is used.
2017-06-27 07:39:44 +10:00
8cc8aad4f9 Scene object iterator: minor optimization
Avoid an extra hash when adding to gset
2017-06-27 07:30:21 +10:00
0394c04a7f Eevee: Add Planar reflection blurring.
This method is very cheap and inaccurate. This will fill the gap untill better model is supported.
2017-06-26 21:04:53 +02:00
daf02baaea Add new DRW_draw_pass_subset function
This function allows to draw only a selected range of shading groups.

This is required for some special situations as grease pencil strokes.
2017-06-26 20:42:58 +02:00
Dalai Felinto
1758330220 Fix viewport rendering with anti-aliasing - workaround
This commit makes the fullsample option for viewport renderings always
on: Render > OpenGL Render Options > Full Sample.

(The UI still allows users to set this, so we will need to revisit this
before 2.8 releases).

Even in computers that can handle MSAA we had issues.
The way Blender gpu_* implementation is handling anti-aliasing is buggy.
For example, in Blender 2.7x if you have depth of field in a viewport
with multi-sampling, the DoF gives us jagged edges.

Since Eevee uses framebuffers for a lot of things, this issue was
leading to very visible buggy render in some computers, and more subtle
inconsistent buggy renders in others (easy to test with the depth of
field in Eevee).
2017-06-26 18:30:21 +02:00
a48bd0db71 Remove disabled code for freeing shaders on scene update
Some code for freeing shaders on scene updates (because of previous
dependency shaders had on lamps) had been disabled, as it is no longer
required. This removes that code altogether.
2017-06-26 18:16:05 +02:00
b50839038d Stop object shaders from being updated when changing lamp properties
Object shaders no longer depend on lamp data at compile time, thus they
don't need to be invalidated when lamps change. Disabling shader
recompilation allows fast viewport updates when changing lamp settings.

Note that even though shaders for lamps are currently not being used,
`lamp_changed` is still freeing the lamp shaders, as at some point we
might want to use shaders for lamps...
2017-06-26 17:53:47 +02:00
bafb904807 Fix T51559: Update draw cache when changing flat/smooth shading
This also renames some flags/variables to be more generic for updating
purposes. The call used here was previously only used for updating
paint data, but as it was reused here, flags and variables were renamed
to accomodate more clearly to the new usages.
2017-06-26 14:52:59 +02:00
Dalai Felinto
37593b6a42 New scenes should use Eevee, not Blender Render 2017-06-26 12:47:33 +02:00
e304150701 Enable shadow catching for Eevee hair
Shadow catching was disabled for hair in Eevee, because of an issue in
the shadow maps. The issue has since been resolved, so this re-enables
shadow catching for hair.
2017-06-26 12:30:30 +02:00
cbbfacdac0 Hair UV implementation for Eevee
This implements UV support for Eevee hair, enabling the usage of
textures.
2017-06-26 12:17:18 +02:00
Dalai Felinto
6f0b80425b Fix shaders not working in Eevee
Not a single node based shader was working since a recent merge from
master.

The merge brought changes from the principle bsdf shader where
unsupported gl_ProjectionMatrix was still being used.
2017-06-26 12:14:21 +02:00
21f088018a Used Py3.6 feature by accident, check version 2017-06-26 19:57:48 +10:00
28b2f1c305 Manipulator: Python API
Initial support for Python/Manipulator integration
from 'custom-manipulators' branch.

Supports:

- Registering custom manipulators & manipulator-groups.
- Modifying RNA properties, custom values via get/set callbacks,
  or invoking an operator.
- Drawing shape presets for Python defined manipulators (arrow, circle, face-maps)

Limitations:

- Only float properties supported.
- Drawing only supported via shape presets.
  (we'll likely want a way to define custom geometry or draw directly).
- When to refresh, recalculate manipulators will likely need
  integration with notifier system.

Development will be continued in the 2.8 branch
2017-06-26 16:38:04 +10:00
c9e33b36de Correct copy-paste error manipulator 2017-06-26 15:46:27 +10:00
ba6d9fefc2 Rename wmManipulatorPropertyType.type -> data_type 2017-06-26 14:36:37 +10:00
3edff2e1a4 Manipulator: use 'void *' for callback data args
Non-float properties should be editable too.
2017-06-26 14:33:10 +10:00
2d2c64dd18 Building without Python works again 2017-06-26 13:50:11 +10:00
6d1ae5897f Merge branch 'master' into blender2.8 2017-06-26 13:43:56 +10:00
fb96228441 Collada: improved Error handling: Avoid shutdown of Blender when the Collada importer finds Syntax errors in import data 2017-06-26 13:41:44 +10:00
0a79b350b5 Merge branch 'master' into blender2.8
Note that this drops all changes from master,
useful commits will need to be cherry-picked.

Did this since most commits were relating to UV/textures
which is complicated by texface being removed in 2.8
2017-06-26 13:38:23 +10:00
f0863f2a80 Merge branch 'master' into blender2.8 2017-06-26 13:27:54 +10:00
3cbf77b34f Cleanup: committed by accident 2017-06-26 13:21:09 +10:00
a4f16c63a2 Manipulator: name setting function
Default name includes group-name,
we may want to set the name without a prefix.
2017-06-26 13:16:25 +10:00
3a1f77650d WM: Fix crash in transform-orientation access
Need to support orientation access when context is NULL.
2017-06-26 08:38:21 +10:00
70b5cec5fa Manipulator: add optional properties argument
Needed for RNA/Py API
2017-06-26 08:19:55 +10:00
3c7355b3a2 Revert "Fix py-api doc building"
This reverts commit 838a4622cf.

Also add missing 'lightprobe'
2017-06-24 17:01:25 +10:00
838a4622cf Fix py-api doc building 2017-06-24 16:11:24 +10:00
07f34ee843 Eevee: Fix linking error. 2017-06-24 05:25:33 +02:00
28ff238c45 Eevee: Planar reflection: Fix normal deformation for background pixels.
Now it matches world cubemap perfectly.
2017-06-24 05:24:59 +02:00
bff98ce3f7 Eevee: Fix opengl error cause by bad texture configuration.
This is fragile and the whole Texture/Framebuffer should be extended to be more flexible.
2017-06-24 01:46:07 +02:00
8035c0f3c6 Eevee: Use smaller texture for placeholders. 2017-06-24 01:44:43 +02:00
e92940c6f3 Eevee: Planar Reflection: Add contact hardening normal distortion.
Save radial distance to camera in alpha channel of the planar probe.
Use this distance to modulate distortion intensity when shading the surface.
2017-06-24 01:08:26 +02:00
a6593645bf Eevee: Add AO support in planar reflection.
Technically this enables the use of MinmaxZ pyramid inside the probe captures.
Also Disable AO for cubemap probes because it shows big discontinuities at cubeface limits.
2017-06-23 22:51:38 +02:00
5e3f902eaa Eevee: Planar Reflection: Fix precision issue near cliplane.
The problem was that the depth prepass was using the clip plane but not the shading pass.

During the clipping stage, the triangle is converted to a quad clipped to the given clip plane.
But this introduce subtle changes in the depth when this new geometry is rasterized. Since the shading pass was using an EQUAL depth test, the depth values from the shading pass were not always equal to the depth prepass.

Enabling clipping in the shading vertex shader has a too small impact to require a dedicated shader.
2017-06-23 22:51:38 +02:00
1111e64c72 Eevee: Planar reflection: Fix bad texture binding. 2017-06-23 22:51:38 +02:00
Dalai Felinto
dd608ba20e Silence warnings (tsc, tsc) 2017-06-23 16:45:14 +02:00
986a3d15ac GPUMaterial: Avoid freeing GLSL shaders when changing scene properties.
This was causing major slowdown when changing Colormanagment settings or post processing.
2017-06-23 16:41:56 +02:00
45720922f7 Revert "Temporarily disable material preview (T51796 workaround)"
This reverts commit 0d9611718d.

The preview issues have been solved by CoW commit
802027f3f8
2017-06-23 12:26:54 +02:00
a764044ccc Fix Eevee "No output node" issue
This fixes an issue introduced by the new output node system, where "No
output node" was displayed in the material panel even when an output
node was present.
2017-06-23 10:49:09 +02:00
0f99793dee Manipulator: partial depth support
Use the depth flag added for this purpose.
Although this only works for regular currently, not selection.
2017-06-23 17:24:56 +10:00
d47cb2a4e4 Manipulator: disable GL state changes drawing geometry
If there is case this is needed, we can enable and restore state
for now it seems OK to disable.
2017-06-23 16:47:49 +10:00
16b807e84f Manipulator: flip scale flag usage
Naming was confusing, while technically correct -
the result is no scaling (manipulator ignores zoom-level).

Also remove 3D from name since this can be supported for 2D views too.
2017-06-23 15:54:27 +10:00
0a5d7efab3 Manipulator: rename struct members
Rename:
- matrix -> matrix_basis
- user_scale -> scale_basis
- scale -> scale_final

Match RNA names being added to custom-manipulator branch.
2017-06-23 14:50:44 +10:00
12b985f1b1 Eevee: Put pack AO parameters. 2017-06-23 04:13:08 +02:00
823144f0a6 Manipulator: add tweak-snap (not used yet) 2017-06-23 11:15:16 +10:00
3a243ad83f Eevee: Attempt to optimize GTAO shader.
Unroll horizon search loop. Use fast version of acos.
On nvidia linux, unrolling the 2nd loop is giving very high compilation time.
2017-06-23 02:52:34 +02:00
fbffd6d364 Eevee: Fix OpenGl errors.
Also assert if texture does not exists in draw manager. Keeping it sane.
2017-06-23 02:52:34 +02:00
221c7fdaf0 Manipulator: fix broken hover option
Hover flag caused manipulators not to update
(Camera DOF works again).
2017-06-23 09:18:53 +10:00
06cc5e4994 DrawManager: Add support for writting to depth without depth testing.
Disabling depth test will prevent from writting to depth buffer.
Add DRW_STATE_DEPTH_ALWAYS to always pass the depth test and write to depth.
2017-06-22 18:54:03 +02:00
Dalai Felinto
5b2e596ce9 Eevee: Fix max range of lightprobes 2017-06-22 18:35:08 +02:00
Dalai Felinto
d9c5433144 Eevee: Interface and units
We should use PROP_DISTANCE whenever appropriate.
Also rename "Data Draw Size" > "Size" in the UI for the lightprobes.
2017-06-22 17:37:31 +02:00
Dalai Felinto
4cd9a3e337 Light Probes: interface changes, and renames
Although we are calling all of them light probes, there are a lot of
differences between them. This commit does the following:

* Prevent user from changing the probe type once added

* Unify "sphere" and "cube" probes into reflection cubemap
(as before you can switch between them from the probe UI)

To be done
==========
* Don't show add probe menus unless we are on Eevee

* Light probes panels should not be visible in Clay. Light probe objects
should not be visible in Clay viewport (nor on Cycles).

Notes
=====
* We need icons for the different light probes, and for lightprobes as a
whole (we are using RADIO for now).
2017-06-22 17:30:15 +02:00
Dalai Felinto
7773a8ad04 Indicate to users when manual conversion of Eevee materials is needed
We now shows a report error when user opens a file that need fixing.
It's fine(ish) to not do doversion. It's not fine to not communicate that.
2017-06-22 10:48:41 +02:00
f1824507e2 Manipulator: target property definitions
Changes from custom-manipulator branch.

- use property type definitions.
- add property free callback.
- move properties into the wmManipulator struct (over alloc).
- use array length from property types instead of arg passing.
2017-06-22 18:39:28 +10:00
87adeb8dd9 Eevee: Ambient Occlusion: Enable Multibounce approximation and Change influence factor.
Making the influence a power for easy tuning. Works like a contrast knob.
2017-06-22 03:51:06 +02:00
779c950098 Eevee: Ambient Occlusion: Initial implementation.
Implement GTAO (Ground Truth Ambient Occlusion) which is a special case of Horizon Based Ambient Occlusion that is more physically accurate.
Also add a bent normal option to sample indirect irradiance (diffuse lighting) with the least occluded direction.
2017-06-22 03:51:06 +02:00
5ccc02277d Eevee: Improve material variation managment.
- Unify variations between default shaders and material shader.
- Only create default shader passes if needed.

Downside is that we have a big array of passes and shading grp in the vedata ... And it will double in size each time a new variation flag is added.
2017-06-22 03:51:06 +02:00
1159d8ccc9 Eevee: Ambient Occlusion: Add UI properties. 2017-06-22 03:51:06 +02:00
2c7f6db8d1 Eevee: Minmax Depth Pyramid.
This commit introduce the computation of a depth pyramid containing min and max depth values of the original depth buffer.
This is useful for Clustered Light Culling but also for raytracing on the depth buffer (SSR).
It's also usefull to have to fetch higher mips in order to improve texture cache usage.

As of now, 1st mip (highest res) is half the resolution of the depth buffer, but everything is already done to be able to make a fullres copy of the depth buffer in the 1st mip instead of downsampling.
Also, the texture used is RG_32F which is a too much but enough to cover the 24bits of the depth buffer. Reducing the texture size would make things quite faster.
2017-06-22 03:51:06 +02:00
ed59d03bfc GPUFramebuffer: Add recursive downsampling function.
This special case function enables rendering to a miplevel while using the miplevels above as texture input.
This is needed for some algorithm (i.e. creating a min-max depth pyramid texture).
2017-06-22 03:51:06 +02:00
fe2ff3fc89 GPUTexture: Support for nearest sampling with mipmaps. 2017-06-22 03:51:06 +02:00
Dalai Felinto
4ceb006706 Merge remote-tracking branch 'origin/master' into blender2.8 2017-06-21 15:14:42 +02:00
Dalai Felinto
2ae172ec32 Fix blenderplayer (tm) 2017-06-21 12:25:07 +02:00
85c5c5531e Manipulator: edit_properties -> target_properties
Naming was too confusing between properties of a manipulator
and properties it edits.
2017-06-21 17:06:24 +10:00
c3a8b51413 Manipulator: Move types into their own directory 2017-06-21 16:24:16 +10:00
b7669ac1c6 Manipulators: move settings to ID properties
This makes manipulator access closer to operators,
and allows Python access.

This adds RNA for manipulators, but not Python registration yet.

- Split draw style into 2x settings:
  `draw_style` (enum) & `draw_options` (enum-flag)
- Rename wmManipulator.properties -> properties_edit,
  Use wmManipulator.properties for ID-properties.
  Note that this area of the API will need further work since
  manipulators now have 2 kinds of properties & API's to access them.
2017-06-21 14:10:14 +10:00
5b51dcacbc PyAPI: add intern strings
Avoid string conversion on each use.
2017-06-21 12:43:19 +10:00
d9bb08f111 RNA: avoid many calls to 'RNA_struct_is_a'
Quicker to find the ID-subtype then use direct pointer comparisons.

Also modify `ID_code_to_RNA_type` so missing ID-codes raise a warning
(handy when adding new ID types).
2017-06-21 12:19:37 +10:00
Dalai Felinto
0ef7ccb4d7 Introduce functions/options to indicate the type of render
We should be able to differentiate between OpenGL render (viewport
render), offline render (F12), and view render (viewport draw).

This allows for us preventing offline render to skip mode drawings, grid, ...
Even OpenGL render can benefit from this forcing a higher quality
anti-alias and sampling than the viewport drawing.

I'm not sure if it's clever to keep the memset(0x00) outside the render
loop function as it is in this patch. An alternative is to just pass the
render "type" as a flag to the render function, and set DST.options
inside it. (I may change this tomorrow, I will wait to hear from
Campbell on that).
2017-06-20 20:07:18 +02:00
5c5c09439a Clean node names and organize menus for eevee
This makes the node menus aware of the Cycles/Eevee distinction, and
only show the relevant nodes for the current engine. Names have also
been changed to accomodate for the new output node system.
2017-06-20 18:39:59 +02:00
aaf37e1216 Implement Eevee output node system
This makes Eevee consistent with Cycles, by having a single output node,
and multiple shader nodes that connect to it.

Note that node systems for Eevee saved before this will be missing the
output node, and thus will show an invalid material. This is easily
resolved by connecting the shader output to a new output node.
2017-06-20 18:39:49 +02:00
Dalai Felinto
c2f4308e6b Fix blenderplayer build (tm) 2017-06-20 15:51:51 +02:00
Dalai Felinto
63d71edfca Fix collada build after gawain rename/refactor
Collada files should not have been touched.

Bug introduced on: c31f24c63b
2017-06-20 15:42:51 +02:00
c31f24c63b Manipulators: store operator type instead of id
Avoids lookups on each access.
2017-06-20 04:44:34 +10:00
56dea4b7cd Fix warning in view3d_draw. 2017-06-19 16:31:20 +02:00
Dalai Felinto
701a76769d Fixup for gawan rename
inten/opencolorio and *.cc were ignored.

Build error introduced on b4d053efc7.
2017-06-19 15:19:25 +02:00
54c9803e81 Depsgraph: Fix crash with mouse select in edit mode with Copy-on-Write enabled 2017-06-19 15:09:48 +02:00
fbff09bf7a Depsgraph: Synchronize selection from original scene to copied-on-write one
This makes it possible to select objects in the viewport.

Selection in edit mode is still tricky, mainly because currently such update
would require tagging batch as updated, which is not possible with using just
and original object because it will never have batch.

Possible solution here would be to introduce some "batch" or "render" component
to depsgraph ID node for objects, so we can tag batch for update via depsgraph
tagging API.
2017-06-19 13:23:42 +02:00
802027f3f8 Depsgraph: Initial groundwork for copy-on-write support
< Dependency graph Copy-on-Write >
 --------------------------------
        \   ^__^
         \  (oo)\_______
            (__)\       )\/\
                ||----w |
                ||     ||

This is an initial commit of Copy-on-write support added to dependency graph.
Main priority for now: get playback (Alt-A) and all operators (selection,
transform etc) to work with the new concept of clear separation between
evaluated data coming from dependency graph and original data coming from
.blend file (and stored in bmain).

= How does this work? =

The idea is to support Copy-on-Write on the ID level. This means, we duplicate
the whole ID before we cann it's evaluaiton function. This is currently done
in the following way:

- At the depsgraph construction time we create "shallow" copy of the ID
  datablock, just so we know it's pointer in memory and can use for function
  bindings.

- At the evaluaiton time, the copy of ID get's "expanded" (needs a better
  name internally, so it does not conflict with expanding datablocks during
  library linking), which means the content of the datablock is being
  copied over and all IDs are getting remapped to the copied ones.

  Currently we do the whole copy, in the future we will support some tricks
  here to prevent duplicating geometry arrays (verts, edges, loops, faces
  and polys) when we don't need that.

- Evaluation functions are operating on copied datablocks and never touching
  original datablock.

- There are some cases when we need to know non-ID pointers for function
  bindings. This mainly applies to scene collections and armatures. The
  idea of dealing with this is to "expand" copy-on-write datablock at
  the dependency graph build time. This might introduce some slowdown to the
  dependency graph construction time, but allows us to have minimal changes
  in the code and avoid any hash look-up from evaluation function (one of
  the ideas to avoid using pointers as function bindings is to pass name
  of layer or a bone to the evaluation function and look up actual data based
  on that name).

  Currently there is a special function in depsgraph which does such a
  synchronization, in the future we might want to make it more generic.

At some point we need to synchronize copy-on-write version of datablock with
the original version. This happens, i.e., when we change active object or
change selection. We don't want any actual evaluation of update flush happening
for such thins, so now we have a special update tag:

  DEG_id_tag_update((id, DEG_TAG_COPY_ON_WRITE)

- For the render engines we now have special call for the dependency graph to
  give evaluated datablock for the given original one. This isn't fully ideal
  but allows to have Cycles viewport render.

  This is definitely a subject for further investigation / improvement.

This call will tag copy-on-write component tagged for update without causing
updates to be flushed to any other objects, causing chain reaction of updates.
This tag is handy when selection in the scene changes.

This basically summarizes ideas underneath this commit. The code should be
reasonably documented.

Here is a demo of dependency graph with all copy-on-write stuff in it:

  https://developer.blender.org/F635468

= What to expect to (not) work? =

- Only meshes are properly-ish aware of copy-on-write currently, Non-mesh
  geometry will probably crash or will not work at all.

- Armatures will need similar depsgraph built-time expansion of the copied
  datablock.

- There are some extra tags / relations added, to keep things demo-able but
  which are slowing things down for evaluation.

- Edit mode works for until click selection is used (due to the selection
  code using EditDerivedMesh created ad-hoc).

- Lots of tools will lack tagging synchronization of copied datablock for
  sync with original ID.

= How to move forward? =

There is some tedious work related on going over all the tools, checking
whether they need to work with original or final evaluated object and make
the required changes.

Additionally, there need synchronization tag done in fair amount of tools
and operators as well. For example, currently it's not possible to change
render engine without re-opening the file or forcing dependency graph for
re-build via python console.

There is also now some thoughts required about copying evaluated properties
between objects or from collection to a new object. Perhaps easiest way
would be to move base flag flush to Object ID node and tag new objects for
update instead of doing manual copy.

here is some WIP patch which moves such evaluaiton / flush:

  https://developer.blender.org/F635479

Lots of TODOs in the code, with possible optimization.

= How to test? =

This is a feature under heavy development, so obviously it is disabled by
default. The only reason it goes to 2.8 branch is to avoid possible merge
hell.

In order to enable this feature use WITH_DEPSGRAPH_COPY_ON_WRITE CMake
configuration option.
2017-06-19 13:21:44 +02:00
b4d053efc7 Gawain API naming refactor
Use consistent prefix for gawain API names as well as
some abbreviations to avoid over-long names, see: D2678
2017-06-19 20:18:04 +10:00
349946bd01 Cleanup: quiet warnings 2017-06-19 20:09:26 +10:00
33e5163550 CMake: Remove unused legacy depsgraph option
We don't have legacy depsgraph anymore, no reason to keep the option.
2017-06-19 11:14:40 +02:00
4046f3a54d Manipulator: use ui-scale for widgets 2017-06-19 19:03:22 +10:00
5a029d7a6d Eevee: Add data display for planar reflection.
Maybe not very useful but it's here for feature parity with the other probes.
The fragment shader clipping is here because I'm lazy and don't want to creating a proper quad Batch.
2017-06-19 10:47:56 +02:00
bd9a328b58 Eevee: Fix Planar Probe offset changing influence calculation. 2017-06-19 10:47:56 +02:00
0993af5484 Planar Probe: Add UI, 3d view Display and change defaults. 2017-06-19 10:47:56 +02:00
3e4b9d2b5a Eevee: Initial implementation of planar reflections.
Still pretty barebone: No roughness support, No normal distortion support.
2017-06-19 10:47:56 +02:00
5c67ac2236 Eevee: Add special shader for depth prespass.
This way we can extend it to output more data (like motion vectors).
Add a variation that uses clip distances.
2017-06-19 10:47:56 +02:00
539225db81 DrwManager: Remove the need for buffers to be available.
This way we can just avoid binding a texture by setting it's ref to NULL.
2017-06-19 10:47:56 +02:00
6dbe2b0385 DrwManager: Remove unnecessary ifs. 2017-06-19 10:47:56 +02:00
83a001267a Probe: Add planar type. 2017-06-19 10:47:56 +02:00
9a5cb2e6f8 DrwManager: Add support for Custom Clipping Planes 2017-06-19 10:47:56 +02:00
9a040fa3d4 DrwManager: Add the possibility to invert backfacing.
This is done in order to support planar reflection rendering.
2017-06-19 10:47:56 +02:00
8a10fa1c53 GPUFramebuffer: Add support to attach individual texture layer. 2017-06-19 10:47:56 +02:00
7b14065729 Manipulator: de-duplicate flags and scale option 2017-06-19 17:52:26 +10:00
2ecb9856bc Cleanup: move copy-paste code into function 2017-06-19 16:12:11 +10:00
9649c6bef5 Merge branch 'master' into blender2.8 2017-06-19 15:06:48 +10:00
cf7447dacb Manipulator: comments 2017-06-18 09:08:30 +10:00
f860369ebf Manipulator: use matrix for manipulator direction
Remove type-specific axis functions.
2017-06-18 08:37:50 +10:00
49be79693c Manipulator: use matrix instead of origin
This avoids having to use manipulator-type specific functions
to set the orientation.
And will make it simpler to access transformation from Python.

Currently the matrix is still used as an offset in places.
Also per-type orientation values still need to be removed.
2017-06-18 05:38:10 +10:00
83c28ff96a Merge branch 'master' into blender2.8 2017-06-18 01:44:08 +10:00
54f0f87a4b Cleanup: use uint 2017-06-18 01:34:41 +10:00
a56de26704 Manipulator: draw options for dial
- Option to start helper angle lines based on a vector
  instead of the initial mouse coords (useful for bisect & spin).
- Option to show 2x helper lines
  useful when dial is used to rotate an axis value.
2017-06-17 15:32:47 +10:00
865bf8ecbc Manipulator: correct dial angle
Calculation was done in screen-space giving inaccuracy,
making the angle incorrect for tool code.

Cast mouse coords onto the dial plane to calculate the angle instead.
2017-06-17 14:34:23 +10:00
57c9bc9bb0 Manipulator: fix general purpose dial use
Wasn't checking own location when checking if flip is needed.
2017-06-17 11:55:53 +10:00
03f67fd5b0 Cleanup: unused code 2017-06-17 11:32:30 +10:00
608cabe2a1 Manipulator: Ignore zoom-level for on-screen widgets 2017-06-17 11:24:26 +10:00
41e22cccee Camera widget only drew 3 sides 2017-06-17 11:09:08 +10:00
aeeebacd6a Cleanup: minor consistency tweak for type name 2017-06-17 10:04:48 +10:00
8c22d31dcc Manipulator: remove type specific 'new' functions
Instead use generic 'WM_manipulator_new', adding a new 'setup'
callback (like wmManipulatorGroup.setup) used to initialize type vars.

This moves conventions closer to wmOperator and simplifies exposing to
Python.
2017-06-17 10:02:54 +10:00
71b70b23b3 Manipulator: initial manipulator for spin operator 2017-06-17 06:38:51 +10:00
df017f7867 Manipulator: New grab preset, use for bisect 2017-06-17 06:14:29 +10:00
2b8d599b3a Manipulator: add array get/set functions 2017-06-17 02:38:49 +10:00
Dalai Felinto
946bc4d3c1 Fix object selection doversion issue since Workspace
Workspace commit (7f564d74f9) made
selection to not be carried away from 2.7x files into 2.8.
2017-06-16 18:12:22 +02:00
24ec761bb4 Merge branch 'master' into blender2.8 2017-06-16 10:26:37 +02:00
e306499a41 Missed last commit 2017-06-16 08:52:42 +10:00
637fa5f670 Cleanup: rename manipulator files 2017-06-16 08:51:14 +10:00
65905a76c2 Add bisect manipulator
Example that uses library widgets to control an operator,
the API hasn't been reviewed yet so this can be seen as a test.
2017-06-16 08:25:24 +10:00
400d3f85e1 Add support for delayed manipulator removal
This is needed so manipulators can tag themselves for removal
without causing problems from freeing data within a callback.

Also use properties within the dial manipulator and fix an error where
removing a wmManipulatorGroupType didn't remove its keymap.
2017-06-16 08:20:27 +10:00
4054914813 UV manipulator from custom widgets branch
This isn't advanced, just adding to get custom
manipulator branch from being too much out of sync with 2.8.
2017-06-16 07:34:23 +10:00
Dalai Felinto
281a4540e2 Expose World ID panel for Eevee
That said, materials need to be updated when switching the world.
2017-06-15 18:46:14 +02:00
Dalai Felinto
cd21236ea1 Fix duplication of scene, it was missing duplication of layer properties 2017-06-15 18:37:02 +02:00
51404724cc Merge branch 'master' into blender2.8 2017-06-16 01:29:20 +10:00
60c5b3f76f Merge branch 'master' into blender2.8 2017-06-15 16:37:10 +02:00
a35e733ff1 Merge branch 'master' into blender2.8
Conflicts:
	source/blender/collada/MeshImporter.cpp
	source/blender/editors/object/object_add.c
	source/blender/editors/screen/screen_edit.c
2017-06-15 15:54:11 +02:00
Dalai Felinto
60a36f2028 Eevee: Use PROP_NONE for probe grid resolution
It makes no sense to use PROP_PIXEL as unit here.
2017-06-15 15:02:32 +02:00
Dalai Felinto
32cd8ac710 Layers: Scene copy should copy selection as well.
We need this for Depsgraph, otherwise CoW scene will have different selection properties.
2017-06-15 13:47:14 +02:00
830df9b33d Updates to manipulator API
While this is work-in-progress from custom-manipulators branch
its stable so adding into 2.8 so we don't get too much out of sync.

- ManipulatorGroupType's are moved out of the manipulator-map and are now
  global (like operators, panels etc) and added into spaces as needed.
  Without this all operators that might ever use a manipulator in the 3D
  view would be polling the viewport.
- Add optional get/set callbacks for non-RNA properties
  Needed so re-usable manipulators can control values that
  don't correspond to a single properly or need conversion.
- Fix divide by zero bug in arrow manipulator (when moving zero pixels).
2017-06-15 20:56:22 +10:00
Dalai Felinto
1a7099f3ec Fix T51463: Eevee motion blur not working (with AMD)
GLSL needs FragColor to be initialized. The default vec4 value seems to be
implementation dependent. Or it's a bug on Mesa/AMD.
2017-06-15 11:31:45 +02:00
826f3c715c Fix strict cflags compilation after recent const changes 2017-06-15 10:19:33 +02:00
35ec72bcb8 Merge branch 'master' into blender2.8 2017-06-15 10:17:51 +02:00
f2d7a28a09 Probes: Modify Add Menu and change defaults. 2017-06-15 00:57:16 +02:00
f5203e6cba Probe: Fix display of the Influence of grid probes. 2017-06-15 00:57:16 +02:00
634dbfa2ed Eevee: Fix grid probe updating when updating cube probe. 2017-06-15 00:57:16 +02:00
cac851a00e Eevee: Probes: Add data display for cubemaps. 2017-06-15 00:57:16 +02:00
810464e5f7 Eevee: Group octahedron map functions into one file. 2017-06-15 00:57:16 +02:00
246ee82a2f Eevee: Some probe update changes.
Dont render grids if cubemap count changes (because it does not depends on).
Recalc lighting if probe type change.
2017-06-15 00:55:45 +02:00
9c82203e82 Eevee: Probes: Change falloff of irradiance grid. 2017-06-15 00:55:45 +02:00
99ff1bb21a Probe: fix clip distances showing only for one probe. 2017-06-15 00:55:45 +02:00
0ca2f5affd Eevee: Irradiance grid: support for non-blocking update and multiple bounces. 2017-06-15 00:55:45 +02:00
26e710b1fd Eevee: Add Grid debug display. 2017-06-15 00:55:45 +02:00
4873ff005b Eevee: Fix probe diffuse computation. 2017-06-15 00:55:44 +02:00
49ba446f68 Eevee: Split irradiance functions to their own new file. 2017-06-15 00:55:44 +02:00
88602ea017 Probe: Fix probe panel 2017-06-15 00:53:41 +02:00
4a83f3e2a5 Eevee: Disable specular when rendering probes.
This prevents weird reflections and really strong indirect lighting.
2017-06-15 00:53:41 +02:00
fbd05d3b6a Probe: fix grid default resolution. 2017-06-15 00:53:41 +02:00
dccf46f18f Eevee: Add Irradiance Grid support
Early implementation. Slow and still has quality
3 ways of storing irradiance:
- Spherical Harmonics: Have problem with directionnal lighting.
- HL2 diffuse cube: Very low resolution but smooth transitions.
- Diffuse cube: High storage requirement.

Also include some name change.
2017-06-15 00:53:41 +02:00
8e5609665f Probe: Add grid probe parameters. 2017-06-15 00:53:41 +02:00
7439919ac0 Merge branch 'master' into blender2.8 2017-06-14 22:39:33 +02:00
dbca1afefa Add an option to free scene without doing id-counters
This is similar to some other datablocks. Mainly applies to collections,
so freeing scene does not involve changing any non-directly owned data.

There are two main usecases foreseen for the future:

- Less CPU ticks on bmain free, where everything is freed anyway and
  there is no need to preserve id counters.

- Easier freeing of temporary data, including data which is used by
  depsgraph's copy-on-write mechanism.

Neither of those are currently implemented, but will be shortly.
2017-06-14 16:59:52 +02:00
c59abb4c9a Implement hair in eevee
New implementation of hair for Eevee.

Note: A hard coded "transmission" property is being used. This should
eventually be exposed to the UI, possibly in the form of SSS
properties.
2017-06-14 14:04:36 +02:00
0d9611718d Temporarily disable material preview (T51796 workaround)
This stops the memory breakage caused by the material preview jobs,
to enable the new hair drawing implementation.

(This should be reverted once T51796 is actually fixed!)
2017-06-14 14:03:58 +02:00
28af03c1c2 Merge branch 'master' into blender2.8 2017-06-14 12:02:58 +02:00
6656af2d11 Merge branch 'master' into blender2.8 2017-06-14 11:17:13 +02:00
48cd25a11a Merge branch 'master' into blender2.8 2017-06-14 10:54:58 +02:00
edad3076a9 Merge branch 'master' into blender2.8 2017-06-14 10:48:20 +02:00
07c7bbef0d Merge branch 'master' into blender2.8 2017-06-14 10:11:18 +02:00
26efc7bbd1 Merge branch 'master' into blender2.8 2017-06-14 17:17:00 +10:00
Julian Eisel
a394d68177 Fix possible heap use-after-free in workspace lib-linking
Caused by one of the recent commits during workspace review.
2017-06-14 00:09:37 +02:00
Julian Eisel
c9de10a632 Fix compiling blenderplayer (tm) 2017-06-13 23:40:31 +02:00
Julian Eisel
0095f4f834 Fix T51794: Crash on hair file when opening with no UI
Just a workaround for now.
2017-06-13 23:37:37 +02:00
be4cf933ab Merge branch 'master' into blender2.8 2017-06-13 17:45:36 +02:00
Dalai Felinto
6ea6c51670 Better Fix for T51777: Separating objects by selected vertices
This reverts commit 47b9d0d040. And
implement a fix that doesn't require Depsgraph refresh.
2017-06-13 16:31:42 +02:00
7cfa6094ab Merge branch 'master' into blender2.8 2017-06-13 15:11:58 +02:00
4577bda634 Merge branch 'master' into blender2.8 2017-06-13 14:16:43 +02:00
b0b83c0db4 Draw manager: Fix initialization of static struct
It's first member is a multi-dimensional array, so proper way to initialize that
is to use multiple levels of braces.
2017-06-13 12:20:20 +02:00
4c6cb33764 Draw manager: Don't check matrix to be non-NULL
It isn't a pointer, so the check was confusing and totally redundant.
2017-06-13 12:17:55 +02:00
56ad2f0f1a Woarkspace: Remove residue of hidden type
There is no reason to be special for workspace and go against other design
decision in Blender. If something like this is going to become a common
practice in Blender it should be well thought and well tested, including
tests of all supported compilers and configurations.

This feature was relying on type re-definition, which is not only confusing
but also available in C11 only.
2017-06-13 12:02:08 +02:00
eaadfdbdc0 CMake: add missing includes 2017-06-13 14:51:15 +10:00
Dalai Felinto
47b9d0d040 Fix T51777: Separating objects by selected vertices in Eevee causes crash
I considered just copying the evaluated data from the LayerCollection.
However we need to run the evaluation so Depsgraph can handle overrides.

I will double-check with Sergey Sharybin.
2017-06-12 18:35:39 +02:00
Dalai Felinto
193a1df8fa Renaming: *_Iterator_begin/next > *_iterator_begin/next 2017-06-12 18:19:54 +02:00
2270ca9023 Merge branch 'master' into blender2.8 2017-06-12 16:55:57 +02:00
Dalai Felinto
109447d008 Draw Manager: Fix memory issues when copying scene 2017-06-12 16:12:33 +02:00
Dalai Felinto
8ca497b911 Depsgraph: Traversing should be consistent for nodes and relationship
We need to traverse the same exact objects for both nodes and relationship
builder. We were using FOREACH_SCENE_OBJECT for relationships, which
would lead to plenty of warnings in multiple situations.

In the future we will need to change this to build the depsgraph
relations and nodes to one single render_layer.

Fix T51780: If an object is in two collections and I do a full copy of
scene things go bad
2017-06-12 16:08:57 +02:00
0f4f4d8754 Merge branch 'master' into blender2.8 2017-06-12 15:12:36 +02:00
f52dc2f371 Rename probe to light-probe
Probe is a real general term, the new name is used often in docs online.
2017-06-12 21:34:55 +10:00
12bd960df9 Fix crash drawing non-mesh geometry 2017-06-12 14:43:19 +10:00
c2f6ca313e Draw Cache: fix probe vbo size 2017-06-10 13:57:39 +02:00
a5b3df7545 Rename node_widgets -> node_manipulators 2017-06-10 10:59:19 +10:00
054a6a06f2 Missed last commit 2017-06-10 10:59:16 +10:00
11d90f0f3b Manipulator Update/Refactor
Sync with custom-manipulators branch

- Use identifiers for properties.
- Property array index access.
- Remove operator from manipulators
  (wasn't used and will likely add in a different way).
2017-06-10 10:42:35 +10:00
0a5e9e2f56 Probe: Small UI improvments
-Better falloff default.
-Add clip distance visualisation.
-Reformat UI and add a display panel.
2017-06-10 00:36:33 +02:00
b35f562e18 Eevee:Uuse compressed format for probes.
One 1024px² octahedral probe (according to the GPU mem stats):
- RGBA16F = 17Mb
- RGB_11_11_10 = 4Mb
For the time being I prefer to maximize the number of probe possible in the scene for users to test.
This is obviously a temporary solution and the final choice of cubemap format should be exposed to the user.
2017-06-09 23:51:48 +02:00
97a77b43be Eevee: Probe: fix roughness bug and optimize probe evaluation. 2017-06-09 23:24:51 +02:00
a17bb772a0 Probe: Add object mode volume visualisation 2017-06-09 23:21:55 +02:00
85990343f6 Probe: Remove Bounding Box parameter.
After using it for like 30 sec, the min max bound box is absolutely not practical. Reverting into using a unit cube with object transform.
This also simplify the code.
In the future of center probes will be implemented using another object matrix (via an object pointer).
2017-06-09 23:21:23 +02:00
20572497a4 Eevee: Add parallax correction to probe reflections 2017-06-09 22:30:49 +02:00
Julian Eisel
da30509725 Fix failing render-layer tests after workpsace commit 2017-06-09 19:30:14 +02:00
ebb2c1511b Fix missing updates when changing probe's clipping
Probes were completely out of depsgraph, so tagging them could not work at all.

For now using some placeholder operations just to ensure order of updates.
2017-06-09 18:06:10 +02:00
Dalai Felinto
dadb99074c Fix crash when using sculpt dynamic smooth 2017-06-09 17:32:51 +02:00
Julian Eisel
2bb004e03d Fix crash when deleting active workspace render-layer
Also fixes some failing unit-tests for render-layers.
2017-06-09 17:17:28 +02:00
Dalai Felinto
f35df9a25a Draw Manager: stop using stack memory!
We still do it a few times, but that helps already. Related to T51718.

Note that it also reinforces the idea that any geometry datablock will
have a generated copy-on-write Mesh provided by Depsgraph.
2017-06-09 16:39:36 +02:00
Dalai Felinto
35f8a02496 Implement a new util function to get reference of mesh tex space 2017-06-09 16:39:36 +02:00
ccc625ce23 Eevee: Fix crash when saving file / opengl render. 2017-06-09 15:01:32 +02:00
Dalai Felinto
ee93bc806b Eevee DoF: Use more reasonable UI range for anamorphic bokeh
Regular camera lens have a ratio of 1.0. The anamorphic bokeh can be
used freely as an artistic decision, but it's nice to clamp it to 2.0,
to match real cameras.

That end up giving a reference for artistis playing with the
parameters unaware of the more realistic limits.
2017-06-09 11:56:40 +02:00
Dalai Felinto
461ea375ad Fix T51720: Depth of Field Bug - Black Screen 2017-06-09 11:56:22 +02:00
bb773acd5f Merge branch 'master' into blender2.8 2017-06-09 19:40:47 +10:00
16ecd0b79e Fix T51750: Group selection broken
Proper way, no base is involved.
2017-06-09 10:04:12 +02:00
Dalai Felinto
3a60b4511e Revert "Fix T51750: Group selection broken"
This reverts commit 484e3527d1.
2017-06-09 09:42:08 +02:00
3b9e8b385c Fix compilation issue 2017-06-09 01:28:43 +02:00
67913c603c Probe: Add influence display and rework UI. 2017-06-09 01:15:17 +02:00
e45ebec335 Probes: Add more parameters.
Add Min Max for box, and distance for sphere falloff.
Same for parallax.
Add clip distances.
2017-06-09 01:15:17 +02:00
974c0cc7b6 Eevee: First commit of Probe support. 2017-06-09 01:15:17 +02:00
cadb950490 Draw Manager: Add request redraw method.
This is extremly hacky and against notifier design. This must be revisited later.
We might want to mimic external renderer way of requesting redraw.
2017-06-09 01:15:17 +02:00
1ee5d08c95 Draw Manager: Add support for temporary matrix override.
This allow to specify custom matrices for certain specific passes.
2017-06-09 01:15:17 +02:00
4abb3c1bc4 Draw Manager, GPUTexture: Add support for binding individual cubeface to framebuffer. 2017-06-09 01:15:17 +02:00
c1009af596 Probe: Add panel and "Add-menu" items.
Also revisits defaults.
2017-06-09 01:15:17 +02:00
4df449edd5 Probe: Add initial visualisation 2017-06-09 01:15:17 +02:00
f6898f9ae5 Probe: fix some missing bits / errors in RNA ... 2017-06-09 01:15:17 +02:00
618aef1e58 Eevee: Fix normal orientation on default shader. 2017-06-09 01:15:17 +02:00
73949ffbf3 DNA_ID Fix comment 2017-06-09 01:15:17 +02:00
cc31d7bb49 Probe: Add new object datablock
We went for a new datablock because blending probe functionality with empties was going to be messy.
2017-06-09 01:15:17 +02:00
346619159a Merge branch 'master' into blender2.8 2017-06-09 07:21:43 +10:00
Dalai Felinto
836c3c14cc Remove unused lay value from Dupli object evaluation context 2017-06-08 19:28:54 +02:00
Dalai Felinto
c5daddbef3 Revert "Fix some groups not showing in the viewport"
This reverts commit c19fedf636.
2017-06-08 19:03:42 +02:00
Dalai Felinto
c19fedf636 Fix some groups not showing in the viewport
If the group was freshly created in 2.8 from a new object, this will prevent the object to be shown.
2017-06-08 19:03:38 +02:00
Dalai Felinto
484e3527d1 Fix T51750: Group selection broken
This was introduced in 23c93873f4.

This could be moved to deg_flush_base_flags_and_settings but since we
only need this for duplis I think it's fine to be handled separately.
2017-06-08 19:00:30 +02:00
9bcc44d505 Depsgraph: Avoid over-documentation
The comment adds zero information.
2017-06-08 16:12:04 +02:00
2335bfeaa0 Avoid allocation of evaluation context for iterator
Use stack-allocated context when possible.
2017-06-08 16:11:14 +02:00
2f9cfda459 Fix compilation error after recent depsgraph cleanup 2017-06-08 10:59:33 +02:00
23c93873f4 Remove selection color from the base
Use indirect access to it via object.

It was already flushing from base to object, now we can avoid such flushing.

Still weird to have selection color filled in by dependency graph, but now
there is no synchronization going on at least.
2017-06-08 10:46:45 +02:00
d675415eef Replace all old DAG calls with direct calls to new DEG and remove BKE_depsgraph.h
This removes BKE_depsgraph.h and depsgraph.c
2017-06-08 10:17:04 +02:00
7f480352ca WM: move manipulator library into editors
As with operators, the window-manager has the API for defining,
the editor can implement and register its own manipulators.

This exposes wmManipulator, keeping it opaque isn't
practical if editors and Python are to implement their own.
2017-06-08 07:42:17 +10:00
bfa5efeebe Fix MSVC compile (T51740)
Gawain doesn't include Blender's cross-platform "inline" definition. This change slipped in as part of D2697.
2017-06-07 16:28:24 -04:00
179bb97740 Gawain: stricter lookup of builtin uniforms
UNIFORM_NONE should never match a valid uniform (builtin or custom).

The logic for UNIFORM_CUSTOM was just wrong, since it returned the first custom uniform. This function should only accept builtin (non-custom) uniforms.
2017-06-07 16:20:37 -04:00
bb3e669d06 Gawain: faster lookup shader attribs by name
Quick hash rejection instead of string comparison. Uniform lookups already work this way. I don't expect a major overall speedup since attributes are looked up less frequently than uniforms.
2017-06-07 16:20:37 -04:00
a5242d08fb cleanup floating point literals 2017-06-07 16:20:37 -04:00
575db256db WM: add wmManipulatorType, from wmManipulator
Having the type in mixed in with each instance
made it hard to expose types to RNA/Python.
2017-06-08 05:30:21 +10:00
8ff1bce40f Manipulators: lamp, camera & force-field
From custom-manipulators branch.
These may be improved they work on a basic level.
2017-06-07 23:56:24 +10:00
cff176df37 Minor manipulator API changes
Sync up with custom-manipulator branch
2017-06-07 22:13:31 +10:00
3b6facb3d2 Merge branch 'master' into blender2.8 2017-06-07 14:09:53 +02:00
00b009ca74 Merge branch 'master' into blender2.8 2017-06-07 12:18:07 +02:00
Dalai Felinto
6fee241db5 Merge remote-tracking branch 'origin/master' into blender2.8 2017-06-07 11:38:03 +02:00
ce18956d9b Optimization of tangent calculation
Avoid doing string comparison when we already know layer is
to be added to bitfield.
2017-06-07 11:25:05 +02:00
e17a90074f WM: remove unused return values 2017-06-07 15:49:50 +10:00
Dalai Felinto
7f01329a84 Small cleanup: Use ELEM and wrong identation 2017-06-06 18:57:47 +02:00
Dalai Felinto
6d2aabc1d0 CMake: Update clay engine message 2017-06-06 18:57:47 +02:00
46f659ba2d Eevee: Fix shader compilation issue. 2017-06-06 18:27:59 +02:00
81615ddf86 Cycles: Fix infinite update when using duplis
The issue was caused by usage of address of dupli-object (which will vary
from iteration process to iteration process) as something denoting whether
we've got the data synchronized to Cycles or not.

For now solved by using address of original object (the one DupliObject
points to) as a pointer for the map.

Need to do more thoughts about this.
2017-06-06 16:30:14 +02:00
Dalai Felinto
cb97b07e23 Draw Manager: Prevent misuse of static draw context
This is supposed to help catch bugs if referrencing stack data out of
the draw loop context.

No change is suppose to happen for users (specially because the changes
here happens mostly on debug).

It includes a change in the logic for render loop, to make sure DST is
not accessed before we enter it - contribution by Campbell Barton.
2017-06-06 16:20:39 +02:00
ae6bfe9c19 Depsgraph: Cleanup, unused includes 2017-06-06 14:19:25 +02:00
e1e41e4447 Cycles: Support rendering objects from dupli-list
This commit extends the work from Dalai made around scene iterators to
support iterating into objects from dupli-lists.

Changes can be summarized as:

- Depsgraph iterator will hold pointer to an object which created current
  duplilist. It is available via `dupli_parent` field of the iterator.
  It is only set when duplilist is not NULL and guaranteed to be NULL
  for all other cases.

- Introduced new depsgraph.duplis collection which gives a more extended
  information about depsgraph iterator.  It is basically a collection on top
  of DEGObjectsIteratorData.

  It is used to provide access to such data as persistent ID, generated space
  and so on.

Things which still needs to be done/finished/clarified:

- Need to introduce some sort of `is_instance` boolean property which will
  indicate Python and C++ RNA that we are inside of dupli-list.

- Introduce a way to skip dupli-list for particular objects.

  So, for example, if we are culling object due to distance we can skip all
  objects it was duplicating.

- Introduce a way to skip particular duplicators.

  So we can skip iterating into particle system.

- Introduce some cleaner API for C side of operators to access all data such as
  persistent ID and friends.

  This way we wouldn't need de-reference iterator and could keep access to such
  data really abstract. Who knows how we'll be storing internal state of the
  operator in the future.

While there is still stuff to do, current state works and moves us in the proper
direction.
2017-06-06 14:17:32 +02:00
d220e54f28 WM: manipulator callback arg order
Use same arg order for C & RNA
2017-06-06 22:16:12 +10:00
Dalai Felinto
d267d76540 Force crash on depsgraph iterator wrong access.
Related to T51718, so it crashes even when no fancy ASAN flags are used.
Patch suggestion by Campbell Barton.
2017-06-06 12:48:12 +02:00
47fd882e79 Merge branch 'master' into blender2.8 2017-06-06 12:17:07 +02:00
Dalai Felinto
a418e269c8 Draw manager: visibility of objects centers to mimic old 2.7x behaviour
We only show object center if object is selected, active or if viewport
has the "All Object Origins" options.

The viewport display options can migrate to renderlayer options.
However, we can mimic 2.7x as a compromise while the final design is
finalized.
2017-06-06 12:00:35 +02:00
28e44da860 Scene object iterator: Replace recursion with loop
This way we are not afraid of recursion being too deep.

That could have happened when having two collections which
are sharing same list of 1000s of objects.
2017-06-06 11:22:13 +02:00
4e1257f2d8 Make particle size follow world space instead of screen space 2017-06-06 09:57:18 +02:00
443904f1f4 WM: functions for assigning all manipulator callbacks
- Move callbacks into type struct.
- Rename render_3d_intersection -> draw_select.
- Add header for function signatures (needed for types and api headers).
- Add WM_manipulatormaptype_find
2017-06-06 17:09:01 +10:00
2ebde4c82b Eevee: Optimize scene with a large number of objects.
Using a GHash to store the shgroup of every Material. This way we do not duplicates the DRWShadingGroups allocations on every object.
2017-06-05 22:05:37 +02:00
6d4f084677 WM: pass manipulator-map when creating wmManipulatorGroup
Also store parent-pointer in wmManipulatorGroup's,
since its not always possible to access the parent pointer.
2017-06-06 03:34:09 +10:00
e83001b782 Merge branch 'master' into blender2.8 2017-06-05 18:11:59 +10:00
cb4f7594a0 WM: add WM_manipulatorgrouptype_append_ptr
Needed for PyAPI registration.
2017-06-05 18:10:52 +10:00
0d428c674a WM: de-duplicate operator append code
WM_operatortype_append(_ptr) functions had diverged.
2017-06-05 17:57:57 +10:00
4ee9016e62 DwM: skip background-set objects w/ selection 2017-06-05 15:02:47 +10:00
c838dd9de6 Clay Engine: Improve sampling of SSAO
Replace completly random noise by Blue noisen, giving a better aspect.
Also randomize the distance in the sample direction to cover the whole distance even with 1 sample. Using another blue noise for this.
Replace spiral samples (that had tendency to align if the number of samples was near the chosen constant) with Hammersley samples that have good coverage even for low number of samples.
Use a UBO instead of Texture (a bit less latency) making things a tiny bit faster.
Move the noise data to the SceneLayerData, because each render layer can have a different sample count.
2017-06-04 23:11:48 +02:00
288b54b5a7 Eevee: Modify Blue Noise. 2017-06-04 21:45:41 +02:00
819b8adb94 Eevee: Move Spherical Harmonics to a new Probe UBO.
Keep data packing tight to prevent use of padding floats
2017-06-04 16:50:22 +02:00
28b597b6df Eevee: Material code refactor.
Separate material handling inside another file.
Make use of enums to identify shader variations.
Group all 64*64 LUTs into one array texture.
Only update world probe if world changes.
2017-06-04 12:12:58 +02:00
8d1e6d7833 World: Add temporary update flag. 2017-06-04 12:08:34 +02:00
3fa2409002 Eevee: Fix compilation error 2017-06-03 01:43:25 +02:00
2851e91db4 Eevee: Cleanup. Group data functions into one file. 2017-06-03 00:54:01 +02:00
433bb91a37 Eevee: fix bad eye vector and get rid of two uniform 2017-06-03 00:54:01 +02:00
bc984fd09b Eevee: Reduce shadow map precision.
Since we only store linear distance now we don't need so much bytes per pixels.
2017-06-03 00:54:01 +02:00
403c6b1b8d Eevee: fix shadows artifact by clearing to max depth 2017-06-03 00:54:01 +02:00
d385ad3ce8 Eevee: fix light update when a shadow caster is deleted 2017-06-03 00:54:01 +02:00
0d52f8daea Eevee: Polishing of Exponential Shadow mapping
Added exponent parameter to tweak light bleeding.
Added depth bias to the shadow test.
Added better blurring using 32 samples.
2017-06-03 00:54:01 +02:00
4bd2de2030 UI: Change shadow map bias tooltip 2017-06-03 00:54:01 +02:00
e97085778b Eevee: Update Light data panel 2017-06-03 00:54:01 +02:00
04992a6ffc Object Mode Engine: Fix spot cone shader. 2017-06-03 00:54:01 +02:00
68e5c082b8 Fix for crash/error drawing duplis
Drawing object centers used stack memory,
we don't want to draw these anyway so add check.
2017-06-03 02:21:10 +10:00
f6b9b452d8 Cleanup: Trailign whitespace 2017-06-02 16:08:53 +02:00
Dalai Felinto
8ff405ebd4 Fix logic for bitwise flags in bases during deg iterator
Spotted/reported by Sergey Sharybin.
2017-06-02 14:30:45 +02:00
Dalai Felinto
c5dccc9734 Fixup for 824bf261f7 so Cycles does not show dupli
Cycles is using rna_depsgraph, not rna_scene. Duplis are still not working there
but now at least it shows it was showing before the commit.

To show duplis in Cycles do:

-       data->flag = DEG_OBJECT_ITER_FLAG_SET;
+       data->flag = DEG_OBJECT_ITER_FLAG_ALL;
2017-06-02 13:05:15 +02:00
Dalai Felinto
9dddd73ee3 Silence annoying rna warnings from Eevee 2017-06-02 11:47:47 +02:00
Dalai Felinto
824bf261f7 Initial implememtation for dupli objects
Now dupli groups, objects, particles, ... are all working.

This introduces a flag for the iterator to determine whether we go over
Set and dupli objects or not.

Important to remember to keep the iteration of DEG_ as readonly.

Cycles is not working well for dupli groups, and it's memleaking
for dupli particles. So for now we iterate over main objects and set
only, not dupli.

To change that go in rna_scene.c and:

-DEG_OBJECT_ITER(graph, ob, DEG_OBJECT_ITER_FLAG_SET)
+DEG_OBJECT_ITER(graph, ob, DEG_OBJECT_ITER_FLAG_ALL)

Review and suggestions by Sergey Sharybin
2017-06-02 10:45:45 +02:00
f8ea2c92db Suppress assert for meshes with no faces 2017-06-02 16:42:39 +10:00
678a6b6c49 Fix T51695: Border select fails w/ lamps
Draw order doesn't match scene order when mixing object types.
2017-06-02 16:38:35 +10:00
eae486f5e6 Merge branch 'master' into blender2.8 2017-06-02 15:39:29 +10:00
cb23927c9b Fix View3D orientation index initial value
Would assert after transform
2017-06-02 15:21:56 +10:00
7beb173d70 Fix crash using non-camera object as camera
Also sync with master to avoid conflicts
2017-06-02 15:12:59 +10:00
f59b1179c5 Eevee: Tag shadow maps to update only when necessary.
Shadow maps are now only updated if one shadow casting object inside it's shadow bounds has been updated.
2017-06-01 23:54:36 +02:00
071315e21b DEG: Add per object update flag for Depsgraph.
This is in order to communicate what portion of this object has changed.
For now it's just a bool, but it will be extended later.
2017-06-01 23:54:36 +02:00
Julian Eisel
46fc0bb87e Move custom transform orientations to workspace
This commit moves the list of transform orientations from scenes to workspaces.
Main reasons for this are:
* Transform orientations are UI data and should not be stored in the scene.
* Introducion of workspaces caused some (expected) glitches with transform orientations. Mainly when removing one.
* Improves code.

More technically speaking, this commit does:
* Move list of custom transform orientations from Scene to WorkSpace struct.
* Store active transform orientation index separate from View3D.twmode (twmode can only be set to preprocessor defined values now).
* Display custom transform orientation name in header when transforming in it (used to show "global" which isn't really correct).
2017-06-01 20:46:18 +02:00
Julian Eisel
7f564d74f9 Main Workspace Integration
This commit does the main integration of workspaces, which is a design we agreed on during the 2.8 UI workshop (see https://wiki.blender.org/index.php/Dev:2.8/UI/Workshop_Writeup)

Workspaces should generally be stable, I'm not aware of any remaining bugs (or I've forgotten them :) ). If you find any, let me know!
(Exception: mode switching button might get out of sync with actual mode in some cases, would consider that a limitation/ToDo. Needs to be resolved at some point.)

== Main Changes/Features
* Introduces the new Workspaces as data-blocks.
* Allow storing a number of custom workspaces as part of the user configuration. Needs further work to allow adding and deleting individual workspaces.
* Bundle a default workspace configuration with Blender (current screen-layouts converted to workspaces).
* Pressing button to add a workspace spawns a menu to select between "Duplicate Current" and the workspaces from the user configuration. If no workspaces are stored in the user configuration, the default workspaces are listed instead.
* Store screen-layouts (`bScreen`) per workspace.
* Store an active screen-layout per workspace. Changing the workspace will enable this layout.
* Store active mode in workspace. Changing the workspace will also enter the mode of the new workspace. (Note that we still store the active mode in the object, moving this completely to workspaces is a separate project.)
* Store an active render layer per workspace.
* Moved mode switch from 3D View header to Info Editor header.
* Store active scene in window (not directly workspace related, but overlaps quite a bit).
* Removed 'Use Global Scene' User Preference option.
* Compatibility with old files - a new workspace is created for every screen-layout of old files. Old Blender versions should be able to read files saved with workspace support as well.
* Default .blend only contains one workspace ("General").
* Support appending workspaces.

Opening files without UI and commandline rendering should work fine.

Note that the UI is temporary! We plan to introduce a new global topbar
that contains the workspace options and tabs for switching workspaces.

== Technical Notes
* Workspaces are data-blocks.
* Adding and removing `bScreen`s should be done through `ED_workspace_layout` API now.
* A workspace can be active in multiple windows at the same time.
* The mode menu (which is now in the Info Editor header) doesn't display "Grease Pencil Edit" mode anymore since its availability depends on the active editor. Will be fixed by making Grease Pencil an own object type (as planned).
* The button to change the active workspace object mode may get out of sync with the mode of the active object. Will either be resolved by moving mode out of object data, or we'll disable workspace modes again (there's a `#define USE_WORKSPACE_MODE` for that).
* Screen-layouts (`bScreen`) are IDs and thus stored in a main list-base. Had to add a wrapper `WorkSpaceLayout` so we can store them in a list-base within workspaces, too. On the long run we could completely replace `bScreen` by workspace structs.
* `WorkSpace` types use some special compiler trickery to allow marking structs and struct members as private. BKE_workspace API should be used for accessing those.
* Added scene operators `SCENE_OT_`. Was previously done through screen operators.

== BPY API Changes
* Removed `Screen.scene`, added `Window.scene`
* Removed `UserPreferencesView.use_global_scene`
* Added `Context.workspace`, `Window.workspace` and `BlendData.workspaces`
* Added `bpy.types.WorkSpace` containing `screens`, `object_mode` and `render_layer`
* Added Screen.layout_name for the layout name that'll be displayed in the UI (may differ from internal name)

== What's left?
* There are a few open design questions (T50521). We should find the needed answers and implement them.
* Allow adding and removing individual workspaces from workspace configuration (needs UI design).
* Get the override system ready and support overrides per workspace.
* Support custom UI setups as part of workspaces (hidden panels, hidden buttons, customizable toolbars, etc).
* Allow enabling add-ons per workspace.
* Support custom workspace keymaps.
* Remove special exception for workspaces in linking code (so they're always appended, never linked). Depends on a few things, so best to solve later.
* Get the topbar done.
* Workspaces need a proper icon, current one is just a placeholder :)

Reviewed By: campbellbarton, mont29

Tags: #user_interface, #bf_blender_2.8

Maniphest Tasks: T50521

Differential Revision: https://developer.blender.org/D2451
2017-06-01 19:59:37 +02:00
Julian Eisel
0af93cf1ac Merge branch 'master' into blender2.8 2017-06-01 19:56:11 +02:00
237e17a957 Merge branch 'master' into blender2.8 2017-06-01 16:31:56 +02:00
3bc8e88643 GPUCodegen: fix missing ViewMatrix in new shading. 2017-06-01 13:23:06 +02:00
8c09826d58 Gawain: Optimize shader uniform access
Before this change Gawain was doing list lookup twice,
doing string comparison of every and each input which
is not efficient and not friendly for CPUs with small
cache size.

Now we store hash of input name together with actual
name and compare hashes first. Additionally, we do
everything in a single pass which is much better from
cache coherency point of view.

This brings Eevee cache population time from 80ms to
60ms on my desktop and from 800ms to 400ms for Clement
when navigating in a file from T50027.

Reviewers: merwin, dfelinto

Subscribers: fclem

Differential Revision: https://developer.blender.org/D2697
2017-06-01 12:33:41 +02:00
3c703df327 Correct select-similar end value 2017-06-01 19:41:19 +10:00
8cf5eaa2ba Add Face-Map to select similar
Handy for setting up face-maps,
also allows selecting all faces with no assigned map.
2017-06-01 16:42:14 +10:00
e0216ea89b Clear pose draw data in BGE pose copy 2017-06-01 14:57:27 +10:00
42e336728d Fix custom-bone display-at option 2017-06-01 13:54:29 +10:00
a5783d08f9 Resolve assert in weight paint mode w/ no weights 2017-06-01 13:37:18 +10:00
390648b984 DwM: Show wire only mesh objects 2017-06-01 02:26:24 +10:00
72cc6bea14 Fix manipulator immediate mode use
Needs 3D coords
2017-06-01 02:07:17 +10:00
f32a18994a Merge branch 'master' into blender2.8 2017-05-31 15:52:11 +02:00
82276d6cf7 Fix bone selection (index can't skip hidden bones) 2017-05-31 23:29:04 +10:00
4f11ffcce7 Fix outliner crash clicking on pose bones
From 15317775c, we can't assume directdata is a Base.
This matches logic from master.
2017-05-31 22:16:13 +10:00
c2d81f257f Eevee: Put shadows and probes inside SceneLayerEngineData
This remove the duplication of data for each viewport improving memory usage.
2017-05-30 22:30:16 +02:00
e7fb013a60 Draw Manager: Add SceneLayerEngineData and use callbacks to clear runtime engine data 2017-05-30 22:30:16 +02:00
Dalai Felinto
ff02103194 Fix T51667: blenderplayer building (tm)
Broken since 272ec8a7cf
2017-05-30 19:14:16 +02:00
272ec8a7cf Move ED_object_facemap functions into ED_object.h 2017-05-31 01:31:53 +10:00
fb27bde1c8 Somehow missed this in recent Face Maps commit
Since the previous layer type was for ints too, it worked in tests.
2017-05-31 01:31:53 +10:00
9f43b36f1c Eevee: UI add world and material nodetree layout. 2017-05-30 17:18:00 +02:00
7b379313de Bpy Extras: Port cycles node functions to new node_utils.py 2017-05-30 17:18:00 +02:00
470d66397d Eevee: Fix ggx sun light. 2017-05-30 17:18:00 +02:00
Dalai Felinto
eed26b25d2 Layer collection doversion: Remove "converted from 2.7" from the name
Followup and partial revert from d78b1147be
2017-05-30 12:30:04 +02:00
d888453244 Face Maps: custom-data, UI and RNA API
Add face maps, needed for face-map widgets,
only data structure, widgets will be separate commit.

This comes from 'custom-manipulator' branch with only minor changes.
2017-05-30 18:05:59 +10:00
d321ed62b8 Revert "Revert "Remove MTexPoly layers""
I reverted this commit by mistake. Sorry :/

This reverts commit 9caf328a7c.
2017-05-30 01:29:03 +02:00
5773f58762 Eevee: Replace Cubemaps by octahedron maps for env. probes.
This enables us to use 2D texture arrays for multiple probes.
There is a little artifact with very high roughness caused elongated pixel due to the projection (along every 90° meridian).
2017-05-29 22:04:30 +02:00
1fa216487d Gawain: update comments to match latest API 2017-05-29 13:37:02 -04:00
818268b394 Fix own mistake with NULL materials in particles 2017-05-29 16:30:56 +02:00
Dalai Felinto
30278342d1 Rename Eevee post process effects
No need to have "Enable" in their names.
2017-05-29 16:29:45 +02:00
ec90780767 Gawain: Add support for rendering using an instance batch (for particles) 2017-05-29 16:28:54 +02:00
97e89027fc Eevee : fix light colors 2017-05-29 15:52:27 +02:00
dbed33479a Eevee: Remove non-ltc area light code + optimisation.
Reduce size ShadingData struct leads to some improvement even with more computation.
2017-05-29 15:52:27 +02:00
932399612b 3D grid: Fix precision issue 2/2
We now floor the corner position and use this position as origin.
This gives us perfect derivatives in all cases even if very far from the origin.
Unfortunately this won't fix the low precision of coordinates used for computing the actual grid size, resulting in thick, non-smoothed lines.

Also did a bit of refactor how the axes are drawn.
2017-05-29 15:52:27 +02:00
330007f571 3D grid: only draw if needed. 2017-05-29 15:52:27 +02:00
e104d82376 Object Mode Engine: Fixing the 3D grid 1/2
Do not use the inverse perspective matrix inside the shader to recover world positions.
That leads to severe float imprecision leading to nasty artifacts.

Instead we compute the world view vector for each pixels and do a ray to plane intersection.
We are still getting low precision derivatives when going far away from the origin, and thus artifacts.

This commit also fixes the non-appearing negative Z axis in 3D view.
2017-05-29 15:52:27 +02:00
9caf328a7c Revert "Remove MTexPoly layers"
This reverts commit c6e92b4947.
2017-05-29 15:52:27 +02:00
35022d0f63 Move particle cache population to a dedicated function
Should help readability of switch statement which becomes far too big now.
2017-05-29 15:26:52 +02:00
377947342e Node Backdrop Manipulator
From custom-manipulator branch, usable when viewer node is selected.

This might need some changes but works on basic level.
2017-05-29 22:09:57 +10:00
1f1926e068 Fix leak with texture-paint shaders 2017-05-29 20:48:02 +10:00
51d1e204b8 Fix texture paint crash when there are no UV's
Missing check in own recent commits,
also only use texture-paint drawing on active object.
2017-05-29 20:17:42 +10:00
Dalai Felinto
4e39b31671 Fix crash on rna show diffuse color update
(untested because texture painting is not working)
2017-05-29 11:15:08 +02:00
Dalai Felinto
05f9155902 Fix crash when setting sculpt settings 2017-05-29 10:54:36 +02:00
c0cf767460 Access node backdrop as vector
Minor change from 'custom-manipulators' branch, avoid conflicts.
2017-05-29 14:29:44 +10:00
8ead56c4c9 Merge branch 'master' into blender2.8 2017-05-28 17:48:59 +02:00
Dalai Felinto
6dfe56f01a Silence warning in draw manager 2017-05-26 17:51:08 +02:00
Dalai Felinto
43badbd631 Rename: FILE_ACTIVELAY > FILE_ACTIVE_COLLECTION 2017-05-26 17:44:00 +02:00
Dalai Felinto
984cd29fda Implement support for Append objects in Blender 2.8
Note for users
==============

The active_layer option used for the filebrowser operators is now called
active_collection.

If there is no collections in the scenelayer or if this option is not selected
we automatically create a new collection for the new objects.

This is the same behaviour of trying to add a new object when there is
no collection.

Note for developers
===================

For those cases I moved the object user count handling from readfile to
the scene collection system. It's working fine for those, but we still
need to re-visit this for Add objects, and Duplicate - In those cases
the usercount is 2 when it should be 1.

Reviewers: mont29, sergey

Differential Revision: https://developer.blender.org/D2686
2017-05-26 17:44:00 +02:00
Dalai Felinto
65a042b273 Rename BKE_layer_collection_active > BKE_layer_collection_get_active 2017-05-26 17:44:00 +02:00
Dalai Felinto
0ab9b943a2 Move util function to add new scene collection when active is not available from object to layer 2017-05-26 17:44:00 +02:00
Dalai Felinto
0c6227ce77 Depsgraph iterator: Add assert for bases not yet evaluated 2017-05-26 17:44:00 +02:00
620516965b Gawain: move convert_prim_type_to_gl to private API 2017-05-26 11:23:23 -04:00
cd8a8a3d1f Fix removing texface layer 2017-05-26 23:37:10 +10:00
7d7c5135d7 Merge branch 'master' into blender2.8 2017-05-26 23:32:56 +10:00
3b311b7cb2 Fix uninit shading group in object mode particles 2017-05-26 13:36:12 +02:00
c6e92b4947 Remove MTexPoly layers 2017-05-26 21:04:34 +10:00
ff29914dcc Remove default shading groups from eevee 2017-05-26 12:55:50 +02:00
f75ca733ed Fix indentation in clay_engine.c 2017-05-26 12:55:50 +02:00
f2a8b74c25 Merge branch 'master' into blender2.8 2017-05-26 19:57:28 +10:00
Dalai Felinto
3b24ece297 Depsgraph: Rename DAG > DEG functions from depsgraph_query.cc 2017-05-26 11:23:10 +02:00
bdbf4471a6 TexFace removal part 3
- MTexPoly structure & layer type.
- The 'Mesh.uv_textures' layers.
- DerivedMesh TexFace drawing.
- Scripts & UI.
2017-05-25 15:19:58 +10:00
c7c6070a64 Merge branch 'master' into blender2.8 2017-05-25 02:48:14 +02:00
Julian Eisel
45ff4a807a Merge branch 'master' into blender2.8 2017-05-25 00:43:01 +02:00
aec76fdcc6 Fix compiler error for VS2017
a void function cannot return a value.
2017-05-24 20:13:45 +02:00
214c42157a Only calc split normals when auto-smooth is enabled
This matches cycles & derived-mesh
2017-05-25 02:31:39 +10:00
154ff1afde Fix/Workaround T51561: Disable split normals 2017-05-25 01:40:15 +10:00
f2cc6c9254 TexFace removal part 2
- Derived-mesh drawing.
- All non UV members of TexFace structs.

MTexPoly is now redundant but keeping with a dummy member,
will check on complete removal later.
2017-05-25 01:40:15 +10:00
7a9ad029dd Remove TexFace, per-face images
TexFace complicates the now more popular shading pipeline by having
per-face images, see: T51382 for details.

To keep the ability to select a per-material edit-image
(used with UV-mapping workflow), the material now stores an image
which will be set when changing images in edit-mode.

This is used as a bake-target when not using Cycles too.
2017-05-24 23:38:15 +10:00
707340edd7 Cleanup: minor de-duplicate from last commit 2017-05-24 22:54:19 +10:00
429f6bee28 Fix T51561: Normal maps fail w/ quad + eevee
Generalize derived-mesh tangent calculation so
it can be used by Batch cache creation too.
2017-05-24 22:39:50 +10:00
a6c60affff Merge branch 'master' into blender2.8 2017-05-24 21:17:05 +10:00
60a099fb09 Move empty image drawing into its own pass 2017-05-24 14:28:48 +10:00
3c92e6b8f0 Cleanup: bmesh var naming 2017-05-24 13:33:48 +10:00
c9d890585b DwM: avoid indirect edit-mesh conversion
Storing edit-mesh data as indices for passing
only to get back edit-mesh data.

This also complicated checks for real edges in tessellation tris.

Simpler to pass data directly.
2017-05-24 13:27:11 +10:00
c99e70ae6c Fix leak in particle velocity global ramp 2017-05-24 13:27:11 +10:00
eef92770a1 Optimize particle primitive shader 2017-05-23 18:39:22 +02:00
e1c4908771 Temp fix for vertex format with batch instancing
This prevents memory alignment from being screwed up when attributes are
optimized out in shader.
2017-05-23 18:39:22 +02:00
9bc88b69d8 Implement particle velocity and acceleration visualization 2017-05-23 18:39:22 +02:00
99c6601a1f Merge branch 'master' into blender2.8 2017-05-23 17:35:45 +02:00
3db15ae23a Eevee: Disable directionnal lamps shadows 2017-05-23 15:12:47 +02:00
6f063bdb1c Use pointers to actual data for particle uniforms
This makes particle color uniforms point directly to material color, and
particle size uniforms point directly to ParticleSettings size.
2017-05-23 14:37:01 +02:00
340e4394d4 Use custom shader for dot particles 2017-05-23 14:25:12 +02:00
b5426b50fb Rename/move particle shaders 2017-05-23 14:20:10 +02:00
21857cb081 Create new shading group for each psys 2017-05-23 13:52:50 +02:00
b30cefa650 Revert "Implement UBOs for particles"
This reverts commit 845732652f.
2017-05-23 13:52:50 +02:00
da9c2607c4 DWM: Add short to float / int uniform function.
Short values are common in DNA, this enables using them directly without storing temporary float somewhere.
2017-05-23 13:59:58 +02:00
694bc97768 Draw Manager: Prevent errors when overwritting the instance batch. 2017-05-23 13:59:58 +02:00
b2dc54ffe5 Stupid mistake in material access optimization 2017-05-23 21:52:18 +10:00
d859bac9e8 Cleanup: Make Gawain code style more consistent
Not as if i'm totally fine with such style, but i'd better be consistent
with whatever the project is using.
2017-05-23 11:53:47 +02:00
96f7b08aec DwM: optimize material access
- Split BMesh/Mesh loops.
- Loop over faces instead of tris.
- Add out-of-bounds check for material index (rare but can happen).
2017-05-23 18:26:16 +10:00
611779ca96 Cleanup: use more generic naming
Can be used by any user that needs faces split by materials.
2017-05-23 17:48:05 +10:00
f21c235c6f DwM: texture paint support & mask mode
Uses workaround so material slots are used when neither blender-internal
or cycles are enabled.
2017-05-23 17:40:48 +10:00
44f91a9a18 Merge branch 'master' into blender2.8
Conflicts:
	source/blender/blenloader/intern/versioning_270.c
2017-05-22 22:49:02 +02:00
6cc293a6d9 Gawain: replace switch with lookup table
This function is not performance critical, but I prefer the branch-free code and no hack needed to appease gcc.

Follow-up to recent 23035cf46f and f637145450.
2017-05-22 16:43:33 -04:00
845732652f Implement UBOs for particles
This fixes the issue where all particles were drawn with the colors and
size of the last psys to be drawn.
2017-05-22 16:42:08 +02:00
cedebeb5de Minor cleanup of previous hair commits 2017-05-22 16:42:08 +02:00
Dalai Felinto
c0202c0d33 Fix T51578: Blender 2.8 crash when select Dopesheet->Grease Pencil 2017-05-22 12:25:40 +02:00
dbb1a692f7 Revert assert, Eevee uses uniforms that might not exist 2017-05-22 17:57:34 +10:00
9efd3a3f63 Cleanup: move custom-data layers into a struct
Changed because the values co-exist with active layers
(Mesh.mloopuv, Mesh.mloopcol).
2017-05-22 17:25:31 +10:00
02cc4d8cec Cleanup: line length 2017-05-22 16:25:27 +10:00
e98652b64f Cleanup: minor edits 2017-05-22 16:21:44 +10:00
f637145450 Fix compilation on gcc 2017-05-22 03:36:05 +03:00
23035cf46f Gawain: remove GLenum from IndexType API
Goal is to make most of the API independent of OpenGL, Vulkan, any other backend.

Able to remove default case from ElementList_size because IndexType only covers index types. Not that and *everything else* like GLenum.
2017-05-21 18:25:30 -04:00
054eb9422c Gawain: use integer math to convert int16 to int10
@fclem does this work for you?
2017-05-21 18:07:23 -04:00
ea31c55b08 Gawain: cleanup code formatting 2017-05-21 17:53:16 -04:00
3f6f02e433 Gawain: drop support for APPLE_flush_buffer_range
Modern GL's glMapBufferRange works the same on all platforms.

Part of T49012
2017-05-21 17:06:42 -04:00
90a1d49180 Gawain: drop support for APPLE_vertex_array_object
Recent versions of OpenGL support VAOs natively.

Part of T49012
2017-05-21 16:48:54 -04:00
68d8618538 Gawain: promote 10_10_10 to first-class vertex format
This format is part of OpenGL 3.3, and one of the reasons for choosing 3.3 over 3.2.

Instead of checking #if USE_10_10_10 just use it wherever needed.
2017-05-21 15:59:34 -04:00
67b9a5b3d6 Eevee: Initial implementation of exponential shadowmaps
Also fixes the rendering of depth.
2017-05-20 16:58:07 +02:00
d9d65a06d3 Eevee: Move cube shadows to octahedron shadowmaps.
We render linear distance to the light in a R32 texture and store it into an octahedron projection inside a 2D texture array.

This render the sampling function much more simpler and without edge artifacts.
2017-05-20 16:58:07 +02:00
4c3382d55f GPUTexture: Enabling R32 format for linear depth encoding. 2017-05-20 16:58:07 +02:00
3f1a7aec13 Eevee: optimize vertex shader for probe and shadows. 2017-05-20 16:58:07 +02:00
07dd208209 Cleanup: warnings 2017-05-21 09:39:31 +10:00
53d1026f2a DwM: assert when uniforms aren't found
More useful when this error shows up early
2017-05-20 23:54:58 +10:00
8e3cefd0d5 DwM: Object mode empty-image support 2017-05-20 23:17:50 +10:00
65aab6cdae Merge branch 'master' into blender2.8 2017-05-20 14:19:05 +10:00
996bf65730 Clay/Eevee: fix more crash when entering edit mode
Shader stages need to agree about interpolation qualifiers. Apparently implicit smooth (the default) and explicit smooth are considered different by some GLSL compilers. Found by @letterrip on Linux + Intel.

Follow-up to 941e739d70
2017-05-19 16:12:13 -04:00
8d7b98bfd3 OpenGL: cleanup material shader GLSL
prefer vector math over scalar
prefer * over /
shorten vec3(x, x, x) to vec3(x)
use clamp, max, etc. instead of custom logic
declare loop vars as part of for loop
spacing
2017-05-19 14:20:37 -04:00
a1c558e19f OpenGL: cleanup edit overlay shaders
Mostly simple fixes to spacing & comments.
2017-05-19 14:20:37 -04:00
941e739d70 Clay/Eevee: fix crash when entering edit mode
vertexColor output was not being written --> shader failed to link --> assert hit while setting that shader's uniforms.

Vertex attribs are smooth by default, so I shortened the declaration.

@fclem or @dfelinto: is color = 0 ok here?
2017-05-19 14:20:37 -04:00
985574c010 Move particle drawing to object mode 2017-05-19 19:18:34 +02:00
8561a2dda7 OpenGL: remove BIT_OPERATIONS check from GLSL
Since the upgrade we can use bitwise operations without checking. No more lame fallbacks!
2017-05-19 12:36:10 -04:00
5218860607 Fix issue with alpha layering for AA dot drawing 2017-05-19 18:01:24 +02:00
42804d49b5 Implement particle drawing with draw manager
This still has a couple of issues:
* Instancing is not working when multiple particle systems use the same
primitive. Only the last particle system to be drawn with a particular
primitive shows up.

* Because of colors being passed as uniforms with static variables, the
color of the collection of the last object to be evauluated is used for
all particles being displayed.

Also, note that while this is being drawn in the clay engine, this might
be moved to the object mode later intead.

Part of T51378
2017-05-19 17:23:19 +02:00
c62bec8d99 Change particle draw_size default and limits
Particle draw size can now no longer be less than 1px, and the default
value has been changed to 4.
2017-05-19 17:23:19 +02:00
ef3c255457 fix typo in interlace shader
introduced by recent 8adec78ca5
2017-05-19 11:09:12 -04:00
648f2a61ad OpenGL: convert old texture2D calls in built-in shaders 2017-05-19 11:09:12 -04:00
fa47437426 OpenGL: clean up smoke & fire shaders
TODO: swap gl_Vertex for vec3 pos, update smoke setup code
2017-05-19 11:09:12 -04:00
f6ffe12ddb OpenGL: convert old texture2D calls in FX shaders
And one texture1D call.
2017-05-19 11:09:12 -04:00
4c5e9d7c0d OpenGL: convert old texture2D calls in material GLSL
Modern GLSL simplifies texture sampling functions. Info about 1D, 2D, 3D, Cube, etc. comes from the sampler type.
2017-05-19 11:09:12 -04:00
Julian Eisel
b90ad0ded7 Remove redundant workaround for removing collections in outliner
Collections are now identified by their pointer.
Also had to correct TSE_IS_REAL_ID to fix undefined behavior on undo.
2017-05-19 15:51:09 +02:00
Dalai Felinto
3af8f52752 Fix crash when changing Clay "Edge Strength"
This was introduced by a removed line in
rB0eb32ab22809d9c0c41bfff5082f58b1a7aa9965

If we want to change the value to a differen default, it should be done
in a separated commit.
2017-05-19 15:50:30 +02:00
Dalai Felinto
4525357a3a Fix crash when adding Torus in edit mode 2017-05-19 15:33:50 +02:00
Dalai Felinto
eb90798727 Fix assert on framebuffer binding 2017-05-19 14:39:27 +02:00
Dalai Felinto
8975ad7a88 Remove unused functions after WITH_LEGACY_OPENGL cleanup 2017-05-19 14:16:00 +02:00
Dalai Felinto
2383667a2e Remove reference to WITH_LEGACY_OPENGL
We only keep this as a way to get GPU_stubs to run, in case we want to do a
throughout cleanup in the codebase and want code using legacy calls to
fail to build.
2017-05-19 14:15:49 +02:00
Dalai Felinto
3527739002 Remove reference to SUPPORT_LEGACY_MATRIX
Since the change to core profile this is no longer supported.
2017-05-19 14:14:46 +02:00
Dalai Felinto
60fc04fb9b Remove reference to WITH_GL_PROFILE_CORE
There is no more point of keep those around. ES20 may need special case
when/if we dabble with it again. Meanwhile no point on polluting the
code with this.

(ghost still has reference for the PROFILE, but that's reasonable)
2017-05-19 14:14:46 +02:00
Dalai Felinto
bad8b91fd3 Correct core profile way of getting color depth 2017-05-19 14:14:32 +02:00
c409acd842 Cleanup: removing dummy legacy dashed line shader.
Dashed requires geom shader, which was not available with older OpenGL,
now that we are on 3.3 we do not need that dummy workaround anymore.
2017-05-19 09:42:30 +02:00
1f46da922a Merge branch 'master' into blender2.8
Conflicts:
	source/blender/blenloader/intern/versioning_270.c
	source/blender/depsgraph/intern/depsgraph_tag.cc
	source/blender/editors/mask/mask_draw.c
2017-05-19 09:36:14 +02:00
f95828a018 Fix empty-image draw size
Was out of sync with 2.7x.
2017-05-19 16:41:23 +10:00
321b98602d Remove use_display_lists option 2017-05-19 10:07:02 +10:00
e03e977385 OpenGL: call glProgramUniform only if version >= 4.1
Otherwise crash! Called from OpenSubdiv setup code. Might start using this in more places...
2017-05-18 18:30:24 -04:00
77f8d631b1 OpenSubdiv: insert TODO notes for OpenGL 2017-05-18 18:30:24 -04:00
2e56e1415a OpenGL: remove EXT_geometry_shader4 from OpenSubdiv
Old extension was made obsolete by GL 3.2.
Input/output layout is part of GLSL.
2017-05-18 18:30:23 -04:00
ff8673399e OpenSubdiv: remove legacy support & display queries
OSD display needs more work, since it uses some legacy OpenGL light and material functions.
2017-05-18 18:30:23 -04:00
51278bab5d remove GPU_legacy_support query
In the move to OpenGL 3.3 core profile, we drop support for compatibility profile and older versions.

OpenSubdiv was the only user; I'll update OSD next.
2017-05-18 18:30:23 -04:00
414c1c0e77 OpenGL: remove -noglsl option & GPU_extensions_disable
Also removed a leftover reference to the old basic-shader-glsl option.
2017-05-18 18:30:23 -04:00
5ed0944ce6 GPU: cleanup GLSL version and standard extensions
Now we always use GLSL 3.3, AKA #version 330. Most of the extensions we used are built into OpenGL 3.3 so we don't need them anymore.

Cleaned up comments related to GLSL version.

Part of T49012
2017-05-18 18:30:23 -04:00
7823957455 remove GPU_geometry_shader_support, instanced_drawing_support queries
These are always supported now
- instancing as of GL 3.1
- geometry shaders as of GL 3.2

The change to rna_scene.c could use some cleanup, since we don't really need a runtime query function.
2017-05-18 18:30:23 -04:00
8cb3c7bdec remove GPU_display_list_support query
Display lists are not part of modern OpenGL.

Only BGE used this, and I forced those uses to false. Commented out old BGE logic for reference.
2017-05-18 18:30:23 -04:00
13687e89d8 GPUViewport: Fix huge memory leak. 2017-05-18 20:32:36 +02:00
Dalai Felinto
781e22c2df Remove viewport shading panel
We can remove the RNA options as well, but I wanted to tackled the UI
first.
2017-05-18 18:46:46 +02:00
Dalai Felinto
740f33d8a2 Remove "Modern Viewport"
The "Modern Viewport" was an option in the Viewport panel that would use
the new fancy wire frame code and some depth debugging functionality.

This was introduced as a quick and dirty way to get the new drawing
system showing in the viewport.

Overtime we built a complete Draw Manager system, leaving this original
approach deprecated which adds clutter to Blender code since it would be
removed sooner or later.

Note: The new fancy wireframes and related shaders (white out other
objects) are still in Blender code, though you can't use them anymore.

If we are to have any of those drawing options they should be integrated
in the new draw manager, instead of integrated in the old drawing
pipeline as it was originally coded.
2017-05-18 18:46:46 +02:00
ec774fdb48 Eevee: Fix fresnel factor to match Unreal Engine specular input. 2017-05-18 18:35:55 +02:00
e52a7584be Eevee: Fix GPUShader not free. 2017-05-18 18:35:55 +02:00
d00ab4a507 Fix menu inconsistencies
This commit fixes two issues:

- UV/Image editor uvs menu did not match the 3D View's which was changed in rB2b240b043078
- Circle select tool was missing in particle edit mode

Reviewers: Severin
Differential Revision: https://developer.blender.org/D2329
2017-05-18 18:22:45 +02:00
Dalai Felinto
c9e7a13abb Fix UI button text for Eevee "Use Nodes" 2017-05-18 17:42:25 +02:00
Dalai Felinto
c2191912ca Freestyle is back for 2.8
It works with Cycles and Blender Internal for now.

The Blender Internal support will disappear, but we should be able to
integrate it with the Draw manager and use it with Clay, Eevee, ...
2017-05-18 17:34:03 +02:00
Dalai Felinto
c36eb9b291 Rename Iterator struct to BLI_Iterator 2017-05-18 16:53:02 +02:00
849b26c746 Draw Manager: Fix buffer reuse. 2017-05-18 16:50:48 +02:00
d92a9a5472 Use the correct depsgraph for freestyle
Freestyle itself is still not working, but that's to be addressed
separately.
2017-05-18 16:14:32 +02:00
7490b24241 Draw Manager: Fix instancing. Again. 2017-05-18 16:05:03 +02:00
242a044bd1 GPUMaterial: Add support for tangent node. 2017-05-18 16:05:03 +02:00
Dalai Felinto
c55c2dbfba Make sure external engines also render fine with depsgraph + freestyle wip
There is still a crash when using freestyle and Cycles,
but the changes here present are harmless
2017-05-18 14:48:13 +02:00
00164f3c70 Correct own error using u32 for back-buffer select 2017-05-18 22:33:34 +10:00
dad10ab118 DwM: Support flat-shaded w/ clay & eevee engines
Needed for sculpt mode drawing w/ engines, see: T51497
2017-05-18 20:43:53 +10:00
5dd9e17266 DwM: Armature: Cleanup envelope bone code a bit.
Mainly adding 'wire' suffix to wire/distance drawing func and shader.

Also, match wire vertex shader behavior with solid one regarding
head/tail only drawing (i.e. alwas expect head bone mat, never tail one,
and assume that if a radius is negative, then we only draw on the other
end of the bone).
2017-05-18 12:13:19 +02:00
23f256b24b DwM: Armature: add solid envelope bone drawing.
Envelope bones are now pretty much identical to old drawing code.

Note that currently new DwM drawing code does not seem to care about
wire/solid drawing modes at all, guess this is still TODO... For now we
hence just get both wire and solid for envelope bones, this can be
refined later.
2017-05-18 12:13:19 +02:00
5919919955 DwM: Armature: refine drawing condition of envelope distance outline.
Should match better original 2.7x behavior now.
2017-05-18 12:13:19 +02:00
c75cde31db Re-use vertex position VBO in weight-paint mode 2017-05-18 14:53:43 +10:00
3900b7b1e7 Cleanup: simplify material checks w/ clay engine
Instead of manipulating args when checking for duplicates,
just convert the material and memcmp.
2017-05-18 13:06:51 +10:00
4047715af3 Cleanup: use pre-defined STRINGIFY macro 2017-05-18 11:22:24 +10:00
5ec6982a82 Draw Manager: Fix instancing. 2017-05-18 01:50:06 +02:00
11e7e0769a Eevee: fix orco. 2017-05-18 01:50:06 +02:00
00a5885136 Eevee: Refactor shaders defines 2017-05-18 01:50:06 +02:00
af3954fe90 Eevee: fix bug with postprocess buffer sharing. 2017-05-18 01:50:06 +02:00
ecee490d13 Eevee: Some changes to default shader.
Use old BI material prop and use a metallic approach.
2017-05-18 01:50:06 +02:00
Dalai Felinto
60cd996c0a Silence warnings in Mac (based on buildbot build report) 2017-05-17 18:13:10 +02:00
Dalai Felinto
970a7c8bb9 Fix blenderplayer 2017-05-17 17:55:31 +02:00
cd8909fbc9 Fix typo in hair shader view vector 2017-05-17 17:27:48 +02:00
f628cfd297 Fix T51535: View vector inverting in pespective/ortho 2017-05-17 16:42:38 +02:00
a56c80cd45 Eevee: fixed Material UI. 2017-05-17 15:06:26 +02:00
1693d7d887 Fix annoying warning about unused debug var in release builds. 2017-05-17 14:37:30 +02:00
d0ceb1821b DwM: Armature: fix bone distance outline drawing.
This indeed needed its own draw pass, thank to @fclem for the hints!

Also fixes a stupid mistake in bones head/tail coloring.
2017-05-17 14:33:34 +02:00
3c799ba801 DwM: Armature: Add distance outline and wire drawing of envelope bones.
This is not complete, it does not implement 3D solid drawing of
envelope bones. 2D wire is hence always drawn for now.

Some notes:

I did not try to implement the 'capsule' approach suggested by @fclem, because:
  1. I spent enough time on this already, and finally got something working.
  2. I managed to get rid of geometry shader completely.
  3. Current approach allows us to use same shader for
     distance outline and envelope wire.

It's working fine, except for one glitch - superpositions of envelope
outlines do not work as expected, not sure what's wrong here, tried to
disable zbuff, enable GL_BLEND, no luck so far...
I think we need our own 'background' drawpass to get them working (also
to avoid them drawing over the wire lines).
2017-05-17 12:34:06 +02:00
11c167ff76 Fix particle system batch_cache on object duplication 2017-05-17 11:19:36 +02:00
c104b7b0b3 DWM: reuse position VBO for vpaint select overlay 2017-05-17 19:21:16 +10:00
a769c4a3a0 Fix weight-painting out of facemask mode w/ hidden faces
Own error in recent commit
2017-05-17 19:08:09 +10:00
Dalai Felinto
c8e96a8b6b Fixup on weightpaint shader after rBfabd55a5e9 2017-05-17 10:35:36 +02:00
Dalai Felinto
fca52c42ae Clay hair: use builtin reflect function 2017-05-17 10:21:08 +02:00
fabd55a5e9 DWM: hide hidden verts in weight-paint mode 2017-05-17 18:09:40 +10:00
c18c3ff3d5 Cleanup: line length 2017-05-17 17:37:23 +10:00
d41f98406f DWM: minor changes to face-flag use 2017-05-17 17:27:20 +10:00
e74177d3b1 Correct own error in copying vertex color to VBO's 2017-05-17 17:14:10 +10:00
e074ac65a6 DWM: don't use engine drawing for paint modes
Also only use sculpt-mode drawing with the active object.
2017-05-17 17:06:55 +10:00
3926e3ef68 DWM: correct unselected face overlay 2017-05-17 16:41:21 +10:00
9995bd8532 DWM: use DRWContextState.obact 2017-05-17 16:08:36 +10:00
741a4cfc0b DWM: Initial support vert & weight hidden faces 2017-05-17 16:01:18 +10:00
17458c511c Cleanup: quiet warning 2017-05-17 13:38:06 +10:00
aa66f2c7eb Use byte color for selection drawing
Some small advantage to using 1/4 sized data-type.
2017-05-17 13:31:01 +10:00
431b7c8eb1 Correct flag when drawing editmode face select
Own error in updating select code.
2017-05-17 13:26:09 +10:00
b4ec0e8cd5 DWM: use generic header for DRWCall
Avoid alignment mis-match casting between different draw-call types.
2017-05-17 12:58:58 +10:00
5bfeaf6cc1 Cleanup: group VBO attributes in a struct
Some names are a bit arbitrary,
this makes it clear which names are VBO attributes.
2017-05-17 12:36:02 +10:00
3d6361aa9c Cleanup: clarify select terminology
In mesh cache we have select: color, id, bool.
Current naming didn't make this clear.
2017-05-17 11:47:31 +10:00
89483c73fd DWM: write mesh data to the VBO directly
Was using intermediate functions to store each data type.
This is still done in some places (for more involved access).

For basic data: coords, normals, colors..etc this is unnecessarily indirect.
2017-05-17 11:34:42 +10:00
2f6bc53874 DWM: Add obact for convenience
Modes often need to check if the object is the active one.
2017-05-17 11:03:09 +10:00
8adec78ca5 Cleanup: remove GLSL version checks 2017-05-17 10:46:42 +10:00
c8bf3984ee Gawain: Fix crash in release build.
Non-initiliazed var, I thought I was clever than this. :(
2017-05-17 01:43:49 +02:00
58a810e640 Draw Manager: Add support for instance Batch.
Idea is to specify a batch as source of vbo instance attrib.
2017-05-16 20:30:17 +02:00
fa76c69627 Draw Manager: support render only mode. 2017-05-16 20:30:17 +02:00
90aff807ab Draw Manager: Texture Memory usage improvement.
-Use 11_11_10 buffers for hdr content.
-Eevee compositing share 1 buffer if bloom and DOF are both activated.
-Fix slowdown when resizing EEVEE viewport.
-Removed DRW_BUF_*** enums causing confusion.
2017-05-16 20:30:17 +02:00
ddc5896c81 Draw Manager: Improve debug 2017-05-16 20:30:17 +02:00
2e8cb8d836 Draw Manager: Make use of texture reuse. 2017-05-16 20:30:17 +02:00
7a029f4e00 GPUViewport: Add a Texture Pool to reuse textures across engines. 2017-05-16 20:27:52 +02:00
dc01586b40 Fix crash when particle display is below 100% 2017-05-16 17:42:14 +02:00
95547bd750 Minor cleanup in clay_engine.c 2017-05-16 16:43:48 +02:00
Dalai Felinto
15317775c5 Outliner: Bring back "activate" object when selecting from outliner 2017-05-16 16:40:00 +02:00
Dalai Felinto
3826e77593 Draw Manager: Small cleanup on bool and bitwise
We should avoid casting from an int to a flag.

In this case it is probably fine, but if the OB_MODE_SCULPT
was too high it can overflow the bool.

(also adding explicit parenthesis to a flag check)
2017-05-16 16:26:00 +02:00
Dalai Felinto
b11168c8f1 Clay/Hair: Only show hair when in object mode 2017-05-16 16:18:17 +02:00
c6da3c2655 Fix hair drawing with collection clay settings overrides 2017-05-16 16:07:45 +02:00
Dalai Felinto
e43597446e Fix hair width changing 2017-05-16 14:55:36 +02:00
Dalai Felinto
c81950fbd5 UI: Expose Views to eevee and clay 2017-05-16 12:58:02 +02:00
Dalai Felinto
1e31127933 Fix info header stats to iterator over layer instead of scene
Although this is working fine, there are two changes expected in the new
future once depsgraph copy on write is implemented:

1) To call ED_info_stats_clear a callback from depsgraph, instead of the
notifier system. (that would also allow us to clear only one
SceneLayer).

2) To store/get stats from the evaluated SceneLayer, as well as iterate
over the evaluated objects as well.
2017-05-16 12:50:23 +02:00
9619275729 Correct last commit, missing assignment 2017-05-16 18:47:43 +10:00
027ae0fdef Fix sculpt dyntopo undo leaving PBVH at NULL 2017-05-16 18:38:45 +10:00
6c951fbd34 GPU: use ifdef for flat shader 2017-05-16 16:57:26 +10:00
2fa2814c82 Fix sculpt drawing with Blender viewport
Would draw without any lighting
2017-05-16 16:38:50 +10:00
cbe97bc50f Fix face-dot's not drawing
regression in d12d8956
2017-05-16 14:57:28 +10:00
a8aebc8dd1 Fix memory leak with mesh cache (w/ select invalidate) 2017-05-16 14:55:29 +10:00
d05d73ae75 Fix memory leak with mesh cache (missed last commit) 2017-05-16 13:06:23 +10:00
57660aac74 Merge branch 'master' into blender2.8 2017-05-16 13:01:26 +10:00
5a90542d3d Fix memory leak with mesh cache 2017-05-16 11:45:23 +10:00
87bbeb2837 Gawain: further cleanup to VertexBuffer_prime
Get buffer size once, use it to both allocate and track VRAM.
2017-05-15 13:08:38 -04:00
30d325c9e6 Gawain: cleanup VRAM usage metric
same functionality
2017-05-15 13:08:38 -04:00
4f7c738a38 Gawain: revert recent VRAM usage metric
Revert 7a18ee62eb and 1ff97bbfff after discussing with @fclem.

VertexBuffer_size should always report the same buffer size, but without asking/calling OpenGL.
2017-05-15 13:08:38 -04:00
77d0aec3d1 Mesh Batch Cache: Use compressed format.
We don't compress UV by default because that would mean restricting them to [0, 1]
Leaving all other code for later settings switch.
2017-05-15 17:55:36 +02:00
9035aa9cee Use better prng algo and fix randomness UI 2017-05-15 17:27:15 +02:00
392b5b8212 Implement matcaps for hair 2017-05-15 17:27:14 +02:00
7a18ee62eb Gawain: Fix memory manager. 2017-05-15 16:24:24 +02:00
c28a4eb8cb Eevee: fix some glsl for low quality lamps. 2017-05-15 16:14:18 +02:00
e053fade99 Mesh Batch Cache: get rid of the ORCO VBO data, and reconstruct it in shader.
With only one MADD instruction we recover the orco data and reduce both the storage and the fetching cost of an attrib layer.
2017-05-15 16:14:18 +02:00
ae9da3786a Gawain: Add assert for maximum attribute name. 2017-05-15 16:14:18 +02:00
1ff97bbfff Gawain: Better metric for VRAM usage. 2017-05-15 16:14:18 +02:00
38125d0499 Mesh Batch Cache: Define Compressed format for shading data.
Deactivated by default.
All shading attribs can be packed to take less VRAM at the cost of precision (not noticable in this case).
UVs can be packed into I16 but that limits their positions into the [-1, +1] range.

This could be a setting option in the future.
2017-05-15 16:14:17 +02:00
f83a244749 Mesh Batch Cache: Optimization, make use of gawain attrib aliases. 2017-05-15 16:14:17 +02:00
cfbfa94e6b Gawain: Add support for multiple attrib names.
This adds the possibility to give multiple name to the same attrib.
This allow multiple binding points depending on the shader.
2017-05-15 16:14:17 +02:00
acc5d02f69 Edit Mode Engine: Fix loose edges/verts not displaying. 2017-05-15 16:14:17 +02:00
5a377521aa Mesh Batch Cache: Split Edit Mesh mode Vertex Buffers for faster update. 2017-05-15 16:14:17 +02:00
b3e62a8aa2 Gawain: add short vector conversion to 10_10_10 2017-05-15 16:14:17 +02:00
b43f66bcb6 Add show-weights to edit-mode UI 2017-05-15 17:56:22 +10:00
0d65dda147 Merge branch 'master' into blender2.8 2017-05-15 15:51:54 +10:00
Julian Eisel
77a90f7666 Fix crash when using template_search with non-ID data 2017-05-13 19:48:04 +02:00
Julian Eisel
2d22092230 Merge branch 'master' into blender2.8 2017-05-13 19:35:54 +02:00
41c4c3f8fd remove unused #includes 2017-05-12 23:34:21 -04:00
6deaab207c remove old PBVH VertexBufferFormat struct
Follow-up to 0722e41f9e which removed all uses of this struct. Gawain VertexFormat auto aligns attributes as described in @nicholasbishop's performance note.
2017-05-12 23:32:37 -04:00
1bcbad446e Fix ogl deprecated calls. 2017-05-12 18:02:31 +02:00
7d12d8956d Sculpt: Move sculpt drawing to engines.
Only mask are handled by sculpt mode engine and are multiplied on top of the render.
There is room for improvement:
 - Shaded meshes don't have correct tangents or uvs.
 - Masks are in range 0.8 - 0.2 thus always darkening at least 20% the render.
 - It only uses the first material slot of the mesh.
2017-05-12 17:54:14 +02:00
Dalai Felinto
2eff390e13 UI: Expose more UI settings to CLAY and EEVEE
Physics panels are not all back, and the material related panels (e.g.,
hair render panel) should go be changed since there should be no
material for those.
2017-05-12 16:45:51 +02:00
dbd3bf5ed2 Fix memleak in previous hair commit 2017-05-12 16:34:33 +02:00
c986b07e4d Draw Manager: Fix crash when saving file. 2017-05-12 16:31:12 +02:00
5aca575d85 Eevee: Add Rotation and ratio parameters to DoF. 2017-05-12 16:31:12 +02:00
0eb32ab228 Implement hair drawing with Draw Manager in Clay engine
Part of T51378
2017-05-12 16:14:55 +02:00
bd31b1f182 Clay: Use switch statement instead of if-else chain 2017-05-12 15:47:33 +02:00
Dalai Felinto
24168f72c3 Fix for edit modes (sculpt, weight paint) menus not showing in header
But introduced on 2b0f02057f
2017-05-12 15:46:54 +02:00
Julian Eisel
18a96e39ea Merge branch 'master' into blender2.8 2017-05-12 15:36:52 +02:00
Dalai Felinto
56859ae7fd Startup.blend: set EEVEE as the default engine
The original idea was to use Clay as the default. But since clay may not
even be in the final release, we can't afford to have a startup.blend
that doesn't deliver a reliable result regardless of build options.
2017-05-12 13:54:48 +02:00
3a5501d168 Use static assert in Clay engine to ensure struct alignment 2017-05-12 12:02:45 +02:00
20881a7794 Some minor cleanup. 2017-05-12 11:57:15 +02:00
3394f7c74b Fix again DwM bbones drawing.
Stupid mistake in rB6824ee0595c9dd7d1c18864f2 fix, again reported by
@campbellbarton, thanks.
2017-05-12 11:56:26 +02:00
Julian Eisel
c20c203b82 UI: Add template_search (version of template_ID for non-IDs)
Adds a version of template_ID that can be used for non-ID properties.
The property to search for and the collection to search in has to be
passed to it.
Like template_ID it also takes arguments to define a 'new' and 'unlink'
operator. They will be displayed as icon-only buttons then.
Also added a version that can display preview thumbnails.

Had to do some additional changes to make text-buttons support
displaying/modifying empty RNA properties.

This will be needed for workspaces, see D2451.

Reviewed By: campbellbarton

Differential Revision: https://developer.blender.org/D2666
2017-05-12 01:47:55 +02:00
Dalai Felinto
c8ab7d4656 Force core profile as main profile
This removes a few options from CMake:
* WITH_LEGACY_OPENGL
* WITH_GL_PROFILE_COMPAT
* WITH_GL_PROFILE_CORE

We still have WITH_GL_PROFILE_ES20. So you can still alternate between
ES20 and CORE profile (when es20 is disabled).

If you want to explicitly see the stubs errors just define
WITH_LEGACY_OPENGL.
2017-05-11 16:47:46 +02:00
9c102f339d Merge branch 'master' into blender2.8 2017-05-11 16:47:21 +02:00
ef3aaa3269 Eevee: Small Dof upsampling blur.
This soften the low res buffer so that jaggies are less perceptible.
Also soften the nearplane transition.
2017-05-11 16:29:35 +02:00
3fbafaffa1 Eevee: Add tonemapping using ocio.
Actually it's done by the Draw Manager, so other engines can use it.
2017-05-11 16:29:35 +02:00
3341c11bcc Eevee: Disable motion blur if camera is different from its animated pose. 2017-05-11 16:29:35 +02:00
2e39a27e3b Eevee: Fix light color being non-linear. 2017-05-11 16:29:35 +02:00
c8d8f04746 Eevee: Fix motion blur when not having set another key. 2017-05-11 16:29:35 +02:00
6fb568af79 Eevee: Add render properties and scene panel. 2017-05-11 16:29:35 +02:00
4edee280e4 Merge branch 'master' into blender2.8 2017-05-11 16:28:58 +02:00
Dalai Felinto
2f8a5ed985 Remove warnings after CDDM fix 2017-05-11 16:15:26 +02:00
Dalai Felinto
4f96c24af2 Merge remote-tracking branch 'origin/master' into blender2.8 2017-05-11 16:11:02 +02:00
Dalai Felinto
bde45b5ae7 Allow building the game engine with core profile
Note: This is not about functionality, but about using the same stub file
we are using in Blender for the game engine.
2017-05-11 16:10:53 +02:00
d58310fe37 Support drawing of solid mode CDDM with core profile
Nothing terribly exciting, just a hackish implementation of solid mode CDDM
drawing for cases when we are building with core profile.

The goal is to be able to see SOMETHING with new OpenGL for thew guys who
tests alembic and friends in blender2.8 branch. This is a temporary solution,
the whole drawing will be reworked. Limited to hardcoded material and lighting.
Selection outline color is also hardcoded because of lack of glColor() in the
core profile.

After this commit there is no big stoppers from stop worrying about legacy
OpenGL, so we can go core profile as the only way for Blender.

While some areas will become broken after that, we'd better just fix them
after that and for now just focus on more important design work.
2017-05-11 16:00:47 +02:00
f129e48993 Merge branch 'master' into blender2.8 2017-05-11 22:16:23 +10:00
4e7eafb86f Eevee: Fix motion blur. 2017-05-11 14:17:38 +02:00
0e0888970d Merge branch 'master' into blender2.8 2017-05-11 22:07:00 +10:00
5ae58f8ab8 DWM: Use draw manager for sculpt PBVH drawing
Add a shader-group type to draw
generated geometry by running a callback.
2017-05-11 21:27:33 +10:00
f1242ea93b Fix bug in copying VertexFormat
Pointer-offsets need updating on copy,
seems VertexFormat's were being made static to avoid this bug?
2017-05-11 21:05:49 +10:00
0ffb19ca64 Revert "DWM: remove redundant state reset"
Enable this for now, needs some investigation.
2017-05-11 18:56:41 +10:00
2a2b23c142 Fix typo in the CMakeFile message 2017-05-11 10:06:12 +02:00
3465f80319 DWM: remove redundant state reset 2017-05-11 08:36:17 +10:00
1e9f922c9e Merge branch 'master' into blender2.8 2017-05-11 07:53:03 +10:00
891159cea0 Merge branch 'master' into 28 2017-05-11 07:42:35 +10:00
50b67d83a9 Merge branch 'master' into blender2.8
Conflicts:
	source/blender/makesrna/intern/rna_space.c
2017-05-10 20:40:31 +02:00
Dalai Felinto
f305aba868 Make sure 'use_property_button_exec' can deal with arrays as well 2017-05-10 20:36:11 +02:00
Dalai Felinto
4f80260f11 Expand the collection settings RNA API for arrays 2017-05-10 20:04:50 +02:00
Dalai Felinto
4240b67e4c Expand the collection settings API to support float arrays
We still need to update the RNA interface to access those. But since
there is no RNA_def_property_float_array_funcs I'm not sure how many
changes this will require.
2017-05-10 19:25:39 +02:00
Dalai Felinto
e5ec386803 Merge remote-tracking branch 'origin/master' into blender2.8 2017-05-10 17:03:27 +02:00
45207bf3ce Eevee: Post process parameters.
-Display almost all parameters.
-Made some small adjustment to motion blur to support FOV motion blur.
-Made DOF max radius a parameter.
2017-05-10 16:03:25 +02:00
fdf2d8bb95 Eevee: Support for light path node "is camera ray" output. 2017-05-10 16:03:25 +02:00
da8b34e527 Eevee: Fix some issues
Fix issue with manipulator contributing to depth.
Fix blender internal shader.
2017-05-10 16:03:25 +02:00
Dalai Felinto
7902e3f1c8 Fix multi-view (single camera) selection 2017-05-10 16:00:42 +02:00
Dalai Felinto
a438750cad Fix multi-view (single camera) manipulators selection 2017-05-10 15:54:23 +02:00
Dalai Felinto
1a6b97e98f Merge remote-tracking branch 'origin/master' into blender2.8
Note: Depth placement was working already for BI, and althugh this
commit breaks it for it, it makes it work for the draw manager engines.
2017-05-10 15:40:08 +02:00
Dalai Felinto
90997710cc Merge commit 'origin/master (9395646c2c)' into blender2.8 2017-05-10 14:21:14 +02:00
0722e41f9e DWM: Use Gawain for sculpt drawing
Currently only uses the simple shader.
2017-05-10 20:35:51 +10:00
1c18d07a1c Eevee: Make Depth of field zoom invariant.
Multiply the sensor size by the viewcamtexcofac which is basicaly how scaled is the viewport relativly to the camera frame.
2017-05-10 00:57:53 +02:00
965571cca7 Draw Manager: Handle negative scaled meshes. 2017-05-10 00:47:27 +02:00
707756d277 Draw Manager: Extend simplification to UBOs & fix a context error. 2017-05-09 23:55:19 +02:00
8277609810 Small cleanup 2017-05-09 23:55:19 +02:00
e32ec677c3 Draw Manager: Simplify usage and check for errors. 2017-05-09 23:55:19 +02:00
9075f934aa Eevee: Initial Depth Of Field commit. 2017-05-09 23:55:19 +02:00
435f5017fa GPUCompositing: Fix comment and component count. 2017-05-09 23:55:19 +02:00
1413bee158 Draw Manager: Add additive blending. 2017-05-09 23:55:19 +02:00
26b6bd6e90 Object Mode Engine: Fix grid distance if view is camera view. 2017-05-09 23:55:19 +02:00
306603ae76 GPUTexture: Add support for 32bit textures. 2017-05-09 23:55:19 +02:00
6dc8368b8f Draw Manager: Add Triangle batching and empty batch.
This is usefull for Depth Of Field because we don't need to store data for each sprites and just generate them when rendering.
2017-05-09 23:55:19 +02:00
bf0ebfca1a Draw Manager: Fullscreen triangle
Used a triangle instead of a quad for fullscreen passes.
2017-05-09 23:55:19 +02:00
Dalai Felinto
75ba1826c8 Merge remote-tracking branch 'origin/master' into blender2.8 2017-05-09 17:56:16 +02:00
24a64cb414 Fix shadow shader to support core profile. 2017-05-09 16:30:40 +02:00
Dalai Felinto
65ebb668ec glPushAttrib/Pop change implementation to use a stack
The original implementation (cbd78c8126) broke depth of field.
2017-05-09 15:23:33 +02:00
86c299c6a4 Merge branch 'master' into blender2.8 2017-05-09 14:33:05 +02:00
Dalai Felinto
dad797d037 Expose camera stereo settings in Clay engines 2017-05-09 12:33:13 +02:00
382c38efae Fix T51439: Object not updated when particle system settings change in 2.8
A bit too early to disable workaround for particles.

Guess it was commented out after particles removal but was not brought back
after particles restore commit.
2017-05-09 10:05:54 +02:00
f7ce1be694 DWM: share positions & normals in shading VBO. 2017-05-09 10:56:22 +10:00
e35e23c72c Cleanup: rename layer-names -> layer-uuid
These names are created from a hash,
don't confuse with actual layer names.
2017-05-09 10:38:52 +10:00
faba1e7d6e DWM: Tangent support for editmesh 2017-05-09 10:26:36 +10:00
54af61440e Merge branch 'master' into blender2.8 2017-05-08 17:44:17 +02:00
a04c29e8ab Fix crash and assert failure when using OCIO GLSL draw mode and color management disabled
The issue was happening when display device is set to None, which makes it so
all the color transformation is a no-op which does not really require any LUT.

This is something we can not know from Blender side easily, because LUT sampling
and related logic is fully done in OCIO library itself. The following happens:

- OCIO sees that no LUT is needed and uses simple pass-through logic in the
  color conversion function.

- GLSL compiles sees that uniform used for LUT is unused in the GLSL code and
  strips it out.

We can not know this from Blender side because technically any conversion to
the same space might be a no-op and that we wouldn't know without some tricky
parse of the OCIO configuration.

So for now we simply avoid crash but are disabling checks for existence of the
uniform.

Ideally would be nice to have some GLSL-code parses which gets the uniforms
from the code itself, so we can distinguish between typo in the uniform name
and uniform being optimized out.
2017-05-08 16:45:07 +02:00
883c62d5d3 Add comment about vertex format created in OCIO 2017-05-08 16:40:59 +02:00
6aa7843de7 Fix wrong attributes and shader binding in sequencer when using OCIO 2017-05-08 16:38:49 +02:00
907135011a Fix hardcoded attribute locations used in image draw 2017-05-08 16:31:10 +02:00
81ecd3f938 Fix OCIO shader being attmepted to be unbound twice 2017-05-08 15:59:00 +02:00
0719a1bce0 Merge branch 'master' into blender2.8 2017-05-08 15:51:17 +02:00
2fed99ad9f Fix T51379: Entering particle edit crash (temporary)
Disabled particle edit mode for now, as there's no point in fixing it
before refactor.
2017-05-08 11:47:47 +02:00
0dd766b043 DWM: Share VBO positions & normals for mesh cache
Select, weight & color cache included redundant position and normals.

Use multiple VBO's per batch for more efficient storage.
2017-05-08 17:39:41 +10:00
6f1a8739a0 DWM: Fix face center's not working w/ hidden faces 2017-05-08 16:16:28 +10:00
ce30ab1e02 Accidentally left show_weight enabled 2017-05-08 14:44:13 +10:00
d8bf5c1378 Cleanup: use struct for custom-data offsets 2017-05-08 13:00:44 +10:00
1a869fb6b9 DWM: show weights in edit-mode
Engine collection settings aren't currently flushed,
once they are this will work as expected.
2017-05-08 13:00:43 +10:00
0927748624 Vertex color access for edit-mode
Currently not used, adding since legacy drawing can display this.
2017-05-08 13:00:43 +10:00
d94e7936ee Cleanup: style & header guards 2017-05-08 13:00:43 +10:00
d2bd9195d4 Cleanup: naming 2017-05-08 13:00:43 +10:00
Julian Eisel
9181f13af7 Merge branch 'master' into blender2.8 2017-05-08 00:19:22 +02:00
c47926542a GPUMaterial: Fix regressions concerning background texco 2017-05-07 15:51:54 +02:00
2a0c91b70c GPUViewport: Make Depth texture not depth testable. 2017-05-07 15:51:54 +02:00
104e6a7b8a GPUMaterial: Make background not transparent 2017-05-07 15:51:54 +02:00
0aa2a662b9 Eevee: Add Bloom post process.
Based on Kino/Bloom v2 - Bloom filter for Unity
MIT license.
2017-05-07 15:51:54 +02:00
29c5692eba Draw Manager: Fix multiple timer query issued for one pass. 2017-05-07 15:51:54 +02:00
Julian Eisel
cbdaa47abb Fix unfreed render-layer properties memory after loading file
Would cause pointer to allocated memory to be overridden.
Steps to recreate were:
* Start Blender
* Save
* Open saved .blend
* Close Blender -> should report unfreed memory
2017-05-07 00:30:33 +02:00
90ebf4832f Merge branch 'master' into blender2.8 2017-05-06 22:54:28 +10:00
a9572c2820 PyAPI: Remove bpy.app.handlers.scene_update
This is routinely mis-used to continuously run scripts,
causing performance problems.

This should be replaced with more specific handlers, or possibly timers.
See: T47811
2017-05-06 22:24:12 +10:00
5221093512 Cleanup: naming 2017-05-06 22:23:59 +10:00
317544455e Add missing weight paint vertex shader 2017-05-06 01:34:43 +02:00
Julian Eisel
cffe15e9c9 Fix all objects being selected when opening pre-2.80 files
Caused by rBe87ddda149b. Selecting objects shouldn't be done in such a
low level function anyway (IMHO).
Made sure duplicating objects still works correctly.
2017-05-05 19:32:06 +02:00
d9949c351d Pass selection to weight paint vert overlay instead of colors 2017-05-05 18:23:27 +02:00
5539544958 Update paint wire when changing modes 2017-05-05 18:23:27 +02:00
Dalai Felinto
8d9c484152 Implement overridable scene render settings
This add a new set of (possible) render settings that can be defined at
the scene level and overridable at the scene layer level.

Once we get workspaces we can either add workspace inbetween scene and
scene layer evaluation. Or to replace layer settings, to avoid extra
confusion to users.

An example of this setting is "samples", as implemented now for the clay
engine.
2017-05-05 18:08:24 +02:00
741d848cf8 Fix crash with no active object 2017-05-05 17:59:08 +02:00
872d8993dd Clean up weight/vertex painting code
Now passing selection state instead of colors for the wire/face mask
overlay thing. Also added masking indication on the faces in vertex
paint.
2017-05-05 15:53:37 +02:00
Julian Eisel
14bf4ed194 Fix Blenderplayer linking error 2017-05-05 13:11:44 +02:00
31f2f1b5f2 Eevee: Fix compilation issue on certain driver. 2017-05-05 13:07:11 +02:00
Julian Eisel
8b8792e7b8 Merge branch 'master' into blender2.8 2017-05-05 12:44:52 +02:00
a7388d650a Fix empty struct errors in paint_vertex_mode.c 2017-05-05 11:38:15 +02:00
ce04c7e9f6 Use immediate mode for back-buffer selection
Needed so selection works with core profile.
2017-05-05 10:37:12 +10:00
1c2b5430ca Merge branch 'master' into blender2.8 2017-05-05 08:23:59 +10:00
ef746be982 Cleanup: include the type of data in function name
Was confusing, some functions return vert or triangle data
but naming wasn't very clear.
2017-05-05 06:42:53 +10:00
Dalai Felinto
129355c80a Multiline support for ED_region_info_draw
Many thanks for Campbell Barton for the help here and the idea to
implement the multi-line as a new function with array as arguments.
2017-05-04 22:24:38 +02:00
6f5307e74d Draw Manager: Add a memory stats to debug view.
Adds 2 static unsigned int to Gawain and GPUTexture to roughly keep track of the memory stats on the GPU.

Stats can be view at the bottom of the GPU stats with debug value > 20.
2017-05-04 21:26:54 +02:00
4bd2429f35 Use mesh draw cache for back-buffer selection
Vertex/weight paint now work with core profile, resolves T51380.
2017-05-05 05:17:31 +10:00
9869436b89 Cleanup: use doxy categories 2017-05-05 05:07:52 +10:00
c6800dd65b Missed last commit 2017-05-05 05:06:57 +10:00
83d43a0e0b Cleanup: de-duplicate mesh data calculation 2017-05-05 04:56:28 +10:00
3103b819aa Vertex paint with draw manager
Reviewers: fclem

Subscribers: campbellbarton, dfelinto

Differential Revision: https://developer.blender.org/D2658
2017-05-04 20:05:59 +02:00
Dalai Felinto
b5b9b2d04d Draw Manager: Combine multiple engines info texts
This join them with \n separators.(right now they clash on top of each
other).

Note: We still need to change "ED_region_info_draw" to accept multi-line strings.
2017-05-04 19:38:16 +02:00
5b70283717 Draw Manager: Fix debugging output. 2017-05-04 19:38:03 +02:00
550b0a22ad GLSL Materials: Fix envmap node artifacts. 2017-05-04 19:12:19 +02:00
665296e6f9 Eevee: Motion blur switch 2017-05-04 19:11:20 +02:00
fbfa53ae1d GPUMaterial: Remove unused Normal input. 2017-05-04 17:42:22 +02:00
4ef0513aab Eevee: Draw background shader.
Also fixes some remaining errors caused by some matrices not updated.
2017-05-04 17:42:22 +02:00
5601a62179 Eevee: Simple Camera Motion Blur.
Disabled by default. Set ENABLE_EFFECT_MOTION_BLUR to 1 to enable.
No fancy motion blur. Use depth and camera matrix to get the motion vectors. Then blur in this direction.
Only available in camera view.
Only Camera animation is supported, does not take into account the parents motion
2017-05-04 17:42:22 +02:00
Dalai Felinto
a3d8ef059c Draw Manager: Implement render info for external engines
This can be used by any engine actually. For example to give feedback
regarding probe caching in Eevee, ....

Unline master, we try to conciliate both the original viewport info
(FPS, view name) and the render info.

Note: I had to split the function in two because the camera alpha
passepartout is handled inside the view3d_draw_region_info function.

Review: Campbell Barton and Clement Foucault.

Thanks to Sergey Sharybin and Pablo Vazquez for some of the design
discussions.
2017-05-04 16:59:58 +02:00
6ea45da05c Cleanup: rename ct -> len
Also use 'defgroup' instead of 'index' for passing weight arg.
2017-05-04 23:37:03 +10:00
Dalai Felinto
77cb570e72 Cycles: Remove "Preview active layer"
In Blender 2.8 we always only preview active layer
Also remove use_viewport_visibility since it's no longer required.

Reviewer: Sergey Sharybin
2017-05-04 13:04:07 +02:00
002b2066ac Remove cpack
Places where it's removed are already replaced by newer logic.
2017-05-04 20:50:03 +10:00
f3550242ed Remove visibility check for project paint
This is such a corner case, and currently there is no way to paint on a
hidden object, removing.
2017-05-04 19:59:57 +10:00
Dalai Felinto
e778be9e20 Fix "doversion" of collection settings for collections
For collections we do not need a doversion as granular as the scene one.
However if a new engine settings is added we need to take care of it.
2017-05-04 11:26:29 +02:00
930f0ba702 Fix passing object to BKE_mesh_batch_cache_dirty 2017-05-04 19:31:05 +10:00
c8d45a7e97 Merge branch 'master' into blender2.8 2017-05-04 10:05:01 +02:00
Dalai Felinto
55ae54c469 Fix relationship lines in draw manager [*]
This fix doesn't really fix the situaion now because at the moment we
only flush the evaluated flags at DEG_OBJECT_ITER time, which is silly.

But it's all we can do until we have CoW.

So the parent visibility flag is not flushed. And even if we flushed its
visibility flag, we would need to rely on having the parent flag flushed
before we get to the object in question.

Anyways, take this commit as a future fix for when depsgraph comes to
rescue all our souls.
2017-05-04 09:57:20 +02:00
Dalai Felinto
b2e908f929 Fix relationship lines visibility test for legacy viewport 2017-05-04 09:47:17 +02:00
Dalai Felinto
e87ddda149 Better fix for duplicate objects not moving them
(original fix on 51a977a86f)
2017-05-04 00:21:49 +02:00
Dalai Felinto
b1858b4d2f Merge remote-tracking branch 'origin/master' into blender2.8 2017-05-03 23:55:29 +02:00
606d1f2b6e Fix projection paint initialization failing 2017-05-04 05:09:05 +10:00
51a977a86f Select new object bases using object's base flag
This fixes object duplicate operator.
2017-05-04 05:09:05 +10:00
Dalai Felinto
628dad4f01 Fix building on Windows and blenderplayer linking after weightpaint engine
Those problems were introduced on 20f95de6ba.
2017-05-03 20:24:42 +02:00
Dalai Felinto
62189a5ab7 Fix potential crash introduced by weightpaint engine when no active object 2017-05-03 20:10:54 +02:00
8c2b98ffa5 Cleanup: line length 2017-05-04 03:35:01 +10:00
d96171ab53 Correct struct type (harmless) 2017-05-04 03:17:05 +10:00
20f95de6ba Weight painting with draw manager
This implements weight rendering with the draw manager, with all drawing
options (Shading, wire, face masking, vertex masking).

This is part of T51208

Reviewers: campbellbarton

Subscribers: dfelinto

Differential Revision: https://developer.blender.org/D2654
2017-05-03 18:57:35 +02:00
b9451c0493 Merge branch 'master' into 28 2017-05-04 02:58:26 +10:00
82e242cc72 Merge branch 'master' into blender2.8 2017-05-03 18:33:02 +02:00
2564d929fc Correct over-alloc struct declaration 2017-05-04 02:15:50 +10:00
Dalai Felinto
673e6fc535 Draw Manager: Bring pose bones to the pose engine
Note: We should test if the armature is the "armature modifier" parent of the
object.

If any good samaritan feels like tackling this, the function to change
is: DRW_pose_mode_armature
2017-05-03 18:06:47 +02:00
3bf31c6d23 Move pose-bone colors into draw_data
Also only allocate necessary number of bone segments.
2017-05-04 01:32:16 +10:00
1f16703792 Error in last commit 2017-05-04 00:43:54 +10:00
827818d37d Rename bPoseChannel's temp/cache pointer for DrawManager to draw_data.
More generic name, this remains a temp solution anyway, until we have
proper handling of temp data from 'magic DEG'! ;)
2017-05-03 16:18:03 +02:00
6824ee0595 Fix bad scaling of BBone single-segment bones in new Armature drawing code.
Reported by @campbellbarton over irc, thanks.
2017-05-03 16:18:03 +02:00
3c91fbf6be Draw Manager: Use color-sets for solid pose-bones 2017-05-04 00:16:31 +10:00
e0722a2c07 Draw Manager: use pose bone theme and constraint colors 2017-05-04 00:01:10 +10:00
Dalai Felinto
2bec7c6070 Code Style: Don't add padding in a function call 2017-05-03 14:32:29 +02:00
60886670cd Move GPU compositing out of draw-manager off-screen drawing
Also no need to use VP_legacy_ prefix here.
2017-05-03 22:17:07 +10:00
825430c589 Cleanup: move off-screen drawing to view3d_draw.c
Since offscreen drawing now uses draw engine, this doesn't need to be
considered legacy.

Note that there are some calls into view3d_draw_legacy.c from view3d_draw.c
this is generally not accepted, so its only dont where there are checks
for new/old engine.
Functions exposed to do this use a VP_deprecated prefix.
2017-05-03 22:03:48 +10:00
a2a436bba3 Update comment 2017-05-03 22:03:48 +10:00
Dalai Felinto
5f38a4a238 Draw Manager: Enable Pose engine as part of the weight paint mode
We still need to bring pose bone drawing for the pose engine.

Note: In the future, once we get face-widget selection, we will need to
make sure the pose engien only draws then if "weight paint mode" is not
enabled too.
2017-05-03 12:41:58 +02:00
Dalai Felinto
50a7d104d2 Draw Manager: Fix pose mode not working well.
In the future this will allow us to implement things like face manipulators.

For now however, this is getting on the way of using pose mode
(mesh objects are drawn green).

NOTE: pose engine should also be the one taking care of pose bones

(and for that matter, X-Ray armature option should/could be a property
of the Pose engine even).
2017-05-03 12:16:40 +02:00
b08fc83d1d Eevee: Fix Lamp Roughness. 2017-05-03 12:08:56 +02:00
e0fded5d3a GPUMaterial: Force old outputs to fail with EEVEE.
Workaround waiting for compatibility bit / or PyNodes.
2017-05-03 12:08:56 +02:00
5570ba9c4f NodeTree: Add eevee default shader tree. 2017-05-03 12:08:56 +02:00
a740495814 Eevee: Add "uber" Shader Output Nodes.
Include Metallic and Specular workflow.
Clearcoat and are not implemented yet.
2017-05-03 12:08:56 +02:00
54bde82445 Draw Manager: Introduce a foreach function for all shgroups in a pass. 2017-05-03 12:08:55 +02:00
bde4499496 Fix draw manager w/ cycles
8b2640f08 introduced the error,
caused by external-engine needing depth mask to be disabled,
which happened to be the case before changing state changing logic.
2017-05-03 20:12:31 +10:00
Dalai Felinto
2a86082945 Validate collection properties at readile
The alternative would be to do version bump + doversioning every
time a new property is added.
2017-05-03 11:51:49 +02:00
Dalai Felinto
66c74242bb Make IDP_MergeGroup recursive
With this we also do not need IDP_MergeGroupValues anymore.
If this causes problems in the future we can always make recursion an
option (like overwrite is).
2017-05-03 11:51:49 +02:00
bf0ac873ba Fix crash loading files where outliner treestore isn't set 2017-05-03 18:13:09 +10:00
d116932f3a Add BBone and Wire Armature draw types to DrawManager.
Most of this was copying/adapting code from octahedral existing draw
code, tough part was to get BBone matrices to behave as expected, they
are using a fairly specific setup...

Addresses T51365 and T51362.
2017-05-03 08:37:24 +02:00
8b2640f088 Draw Manager: fix draw-state switching logic
Changing states didn't properly reset between shading groups
causing the GL state to be wrong based on draw order.

States are now only set when changed.
2017-05-03 08:24:50 +10:00
85ca3156fc Cleanup: typedef for empty list
Without this the intent isn't clear.
2017-05-03 05:21:55 +10:00
1b6c21c03b Workaround external engines with OpenGL rendering
For now just do the OpenGL render and don't render using the engine.
This is a slightly odd-use case since it makes more sense to do a regular render.
2017-05-03 05:06:13 +10:00
075638f85c Cleanup: consistent arg order 2017-05-03 03:06:37 +10:00
3f567535da Draw Manager: OpenGL render support
Works for clay-engine but doesn't draw objects with eevee.
2017-05-03 02:52:39 +10:00
2b0f02057f Draw Manager: split DRW_draw_view into 2 functions
Needed for offscreen render
2017-05-03 00:45:10 +10:00
47239b4041 Cleanup: use depsgraph for scene/layer access 2017-05-03 00:14:54 +10:00
22855f1a60 Merge branch 'master' into blender2.8 2017-05-02 15:41:15 +02:00
7f833c0da8 Merge branch 'master' into blender2.8 2017-05-02 15:29:00 +02:00
Dalai Felinto
ec9ce9e118 Draw Manager: No need of glScissor for external engines 2017-05-02 15:26:18 +02:00
Dalai Felinto
8c660c7801 Cycles integration with Draw Manager
We can now use object and other modes on top of Cycles.
Since we are now always on "render_to_view" (old Rendered mode), the
pause button is always visible.
2017-05-02 15:13:50 +02:00
61b77d8948 OCIO: Fix crash cause by bad IMM usable. 2017-05-02 15:13:12 +02:00
Dalai Felinto
d3964db5bd RNA: Remove remaining relevant scene->basact and BaseLegacy
Note: In one case (rna_Scene_editmesh_select_mode_set) I had to resort
to the temporary solution of BKE_scene_layer_context_active.

This is fine for now, but it will be a problem once workspaces are
introduced. In this case the fix is to use a temporary value in the set
routine, and actually only set the active object in the update function
(which can take bContext).
2017-05-02 12:59:07 +02:00
a9d6a07d78 Add scene argument for notifiers
From workspaces branch
2017-05-02 09:58:01 +10:00
7eebc5113c Eevee: Add support for legacy materials node. (not PBR) 2017-05-01 18:11:21 +02:00
62ea911e1a GPUMaterial: Making material node tree compatible with new drawmanager.
- code_generate_fragment : Making sure that shaders uses the new uniforms.
- code_generate_vertex_new : create require attribute based on their names and not their id (see draw_cache_impl_mesh.c).
- add support for ramp textures.
2017-05-01 18:11:21 +02:00
19f86a3d5f Mesh Batch Cache: Add support for uv/vcol/tangent data layers.
This is a bad implementation waiting for some improvement that are :
- Gawain support for multiple names. -> will remove duplication of attribute alloc
- Glsl safe name string escaping. -> will remove any risk of hash colision.

Old glsl drawing was relying on attribute being choosen by DerivedMesh at drawing time.
For this reason, we declare all possible attrib "name" for each data layer inside the batches.
In the glsl code, we declare required data by type and name.
Then Gawain only bind vbos if names correspond.
This is way cleaner as we do not need to access the CD itself when drawing.

One other problem is that the hash maybe 11 caracters long and rapidly overload gawain's attrib name buffer.
2017-05-01 18:11:21 +02:00
27fc8ae1cb Eevee: Change MAX2 to max_ff 2017-05-01 18:11:21 +02:00
e868b459bb Eevee: World nodetree gpumaterial compatibility.
- Unify GPUMaterial creation (world/mesh).
- Support for multiple shader variations (not used for now).
- Convert GPUInputs to DRWUniforms to be used with the draw manager.
- Nodetree Update is not supported. The only way to refresh the shaders is to change render engine.
- Cleanup in GPUPass.
- Add new temporary Node Compatibility type. Compatibility types should be removed in the future.
2017-05-01 18:11:21 +02:00
2f100c13ee Getting rid of setlinestyle: FCurves drawing. 2017-05-01 17:43:51 +02:00
9c73cead49 Getting rid of setlinestyle: last bit in NLA.
Note that smooth-shaded outlines of muted NLA strips should also be
dashed, not sure how to do that currently (in a simple way), so kept
them solid for now.
2017-05-01 17:43:51 +02:00
Dalai Felinto
d5acf4f467 Fix for issue when duplicating text objects
The crash happens with Cycles and Font objects if we get Cycles working
with draw manager.
2017-05-01 16:48:09 +02:00
bb5f4a1f67 Cleanup/followup to previous commit: get rid of dashed-specific helpers.
Those are no more needed.
2017-05-01 16:32:55 +02:00
d7d4bca23b Reworked version of dashed line shader.
Using geometry shader allows us to get rid of the 'line origin' extra
vertex attribute, which means dashed shader no longer requires fiddling
with those vertex attributes definition, and, most importantly, does not
require anymore special drawing code!

As you can see, this makes code much simpler, and much less verbose,
especially in complex cases.

In addition, changed how dashes are handled, to have two 'modes', a
simple one with single color (using default "color" uniform name), and a
more advanced one allowing more complex and multi-color patterns.

Note that since GLSL 1.2 does not support geometry shaders, a hack was
added for now (which gives solid lines, but at least does not make
Blender crash).
2017-05-01 16:32:55 +02:00
Dalai Felinto
6ef497d401 WITH_CLAY_ENGINE: Should be used for CLAY only, not drawmanager 2017-05-01 15:44:50 +02:00
Dalai Felinto
22be057e37 Draw Manager: Fix copy-paste harmless comment "typo" 2017-05-01 15:44:50 +02:00
ea9d163644 Blender 2.8: Update arc config 2017-05-01 15:20:19 +02:00
c899c7c9e1 Check we've got GLEW version 2 when building with core profile
There was a bug in older GLEW version which kept glGenVertexArrays as NULL
when 3.2 core context is requested [1].

Didn't find a way to check GLEW version from CMake, it seems the version
is not really exposed to the header.

[1] https://sourceforge.net/p/glew/bugs/124/
2017-05-01 10:37:04 +02:00
c4491d76ed Getting rid of setlinestyle: sample line in Image space. 2017-04-29 20:41:57 +02:00
74f9d31409 Getting rid of setlinestyle: UV editor drawing. 2017-04-29 20:12:30 +02:00
785950c18a Getting rid of setlinestyle: remove gpencil's debug-only dashed line drawing.
No need to add extra complexity of conditional dashing here for now!
2017-04-29 19:42:04 +02:00
c5fd6acfce Getting rid of setlinestyle: ed_util's pos-to-mouse dashed line. 2017-04-29 19:40:32 +02:00
b1b8ce0bbf Getting rid of setlinestyle: GPencil eraser.
Note the ugly hack on number of segments for outline dashed circle, to
get an OK-ish rendering of dashes...
2017-04-29 19:31:36 +02:00
45eaad88e2 Getting rid of setlinestyle: add imm_draw_circle_wire_dashed() util.
Needed a bit of twisting in generic private func behind the imm_draw_circle
helpers, but think it's fine.

Note that this demonstrate yet another downside of new dashed shader
compared to olde line style: not only does it needs more complex setup,
and can only work with PRIM_LINES type of primitives, but it also
behaves totally wrong with chained short segments!

We really need to find a better way to do this effect at some point. :(
2017-04-29 19:31:36 +02:00
8f5f4241c0 Cleanup: comment blocks 2017-04-30 03:14:57 +10:00
fbd172a00a Merge branch 'master' into blender2.8 2017-04-30 03:06:42 +10:00
b0a72c98bb Getting rid of setlinestyle: NLA (part I).
Also restore drawing of local action markers in NLA strips...

Note: there is another usage of setlinestyle in this file, not sure how
to hanlde it for now, so will leave it for later...
2017-04-29 13:19:17 +02:00
56e10c1997 Getting rid of setlinestyle: Color ramp markers. 2017-04-29 12:57:14 +02:00
d2589b0a31 Getting rid of setlinestyle: Text space margin line. 2017-04-29 12:43:37 +02:00
8f028ec840 Cleanup: rename struct for private engine data
Also remove from pass list (there were some duplicate unused entries).
2017-04-29 16:52:12 +10:00
33a5248b6c Merge branch 'master' into blender2.8 2017-04-29 16:32:30 +10:00
Dalai Felinto
de9e45a88b blenderplayer: fix warnings in stubs 2017-04-29 02:07:39 +02:00
Dalai Felinto
e702b391ed Draw manager: Style cleanups 2017-04-29 00:54:11 +02:00
b2178472e9 Disable custom armature colors 2017-04-29 04:26:31 +10:00
04f43d4cdf Merge branch 'master' into blender2.8 2017-04-29 03:39:24 +10:00
Dalai Felinto
b868f43fd3 Cycles support for preview on viewport with core profile
This upgrade the drawing code to use latest opengl calls.
Also, it adds a fallback shader for opencolorio.

Reviewers: sergey, brecht
Subscribers: merwin, fclem

Differential Revision: https://developer.blender.org/D2652
2017-04-28 19:25:57 +02:00
ba4f47ce8e Getting rid of setlinestyle: Clip drawing code.
This one has been painful, it's doing lots of nifty conditional drawing
of all kind... Also, very nice illustration of how cumbersome it is to
use dashed shader currently, we really need to find a simpler way at
some point imho. But this is not critical issue either, for now we can
live with some uglyness like that. :/
2017-04-28 19:22:45 +02:00
9fe19437e9 Getting rid of setlinestyle: markers' dashed line in VSE. 2017-04-28 19:22:45 +02:00
5e04e4eb0d Merge branch 'master' into blender2.8 2017-04-29 03:24:03 +10:00
074c5f0d26 Merge branch 'master' into blender2.8 2017-04-28 15:52:07 +02:00
08142dde2c Hide object center and other info when drawing sets 2017-04-28 23:52:02 +10:00
886966aa38 Correct comment, we need wire_outline data in this case 2017-04-28 23:04:29 +10:00
0e94d91048 Draw Manager: pose-mode custom bone display 2017-04-28 22:31:58 +10:00
cc43dd054f Recent commit state broke lattice vertex drawing
e4d856e3 caused lattice vertices not to draw in editmode.
2017-04-28 18:43:46 +10:00
226b6e60b9 Fix draw manager draw-modes interfering with eachother 2017-04-28 05:22:30 +10:00
a680bcd13b Draw Manager: basic text overlay support 2017-04-28 04:54:04 +10:00
e4d856e31b OpenGL: manage legacy state only when WITH_LEGACY_OPENGL=ON
- enabled lights
- alpha test
- texture environment
- point sprites (always enabled in modern GL)

Moved is_clip_plane for better struct packing, no functional change there.

Part of T51164
2017-04-27 14:32:47 -04:00
079e0b5943 OpenGL: don't set texture LoD bias via glTexEnvf
Not supported in core profile. We could do this in GLSL if it's really needed.

Part of T51164
2017-04-27 14:24:32 -04:00
0d5c5a8438 OpenGL: early exit from functions that don't mix with core profile
These parts will not be part of final viewport, but are called indirectly during the transition. To avoid runtime errors on core profile, exit early -- functions effectively do nothing.

I put the early exits inside the functions to avoid cluttering the code that calls these. But (long term) the calling functions need to change.

Basic shader's detect_options function was unused and full of old, so I deleted it.

Part of T51164
2017-04-27 14:21:12 -04:00
99fde39f49 OpenGL: fix color logic op
GL_LOGIC_OP is a synonym for GL_INDEX_LOGIC_OP, from OpenGL 1.0's indexed color drawing. It's not part of modern GL and causes an error in core profile.

GL_COLOR_LOGIC_OP is still supported in the latest GL. It's the last stage before writing to the framebuffer.

Part of T51164
2017-04-27 14:19:03 -04:00
87a66864bc Add back text color for legacy drawing 2017-04-28 03:05:24 +10:00
75fac519c0 Gawain: safely orphan immediate mode's VBO
There are multiple ways to orphan a buffer resource, and this code picks the oldest/safest way no matter which OpenGL version we're running.

TODO: use other (more recent) methods after thorough testing

Follow up to 8e0c57a812
2017-04-27 11:43:25 -04:00
741ed16d13 OpenGL: don't glGet(GL_RED_BITS) in core profile
or GREEN or BLUE. These are deprecated and cause errors under core profile.

TODO: get color depth value another way

Part of T51164
2017-04-27 11:43:25 -04:00
bfaf7a3eb1 OpenGL: stop enabling GL_TEXTURE
Texturing is always enabled in GLSL. Simply use a sampler in the shader.

Replaced gpu_generate_mipmap with glGenerateMipmap since the former just Enabled/Disabled the texture target and called the latter.

Part of T51164
2017-04-27 11:24:35 -04:00
a49708a691 OpenGL: stop using GL_NORMALIZE
With GLSL there is no need for GL_NORMALIZE. We explicitly normalize in the shader, or (better) send in unit vectors.

Part of T51164
2017-04-27 10:35:12 -04:00
34c808287e Gawain: fix pointer arithmetic warning
void* + offset = ???

This Mac-only code works, but wasn't strictly correct. clang doesn't warn about this, gcc does.
2017-04-27 09:59:19 -04:00
9a193a28c4 fix Clay compatibility comment
When building WITH_LEGACY_OPENGL, Mac uses GL 2.1, Mesa uses GL 3.0. Has nothing to do with Intel!

Clay assumes GL 3.3 is available.
2017-04-27 09:30:49 -04:00
1dbb41f195 OpenGL: restore all 8 lights
fixes a copy/paste mistake
2017-04-27 09:30:48 -04:00
5c7b8cfffa OpenGL: remove GL_MAP1_VERTEX_3
This is related to OpenGL evaluators (old feature). From my understanding, we don't seem to be actually using it.

Part of T51164
2017-04-27 09:30:48 -04:00
6f0cf4a804 support OpenGL 3.0 on Linux only when WITH_LEGACY_OPENGL=ON
Part of T49012
2017-04-27 09:30:48 -04:00
cbaacc08dc Getting rid of setlinestyle: transform code.
Note that I also made 'dash anchor point' consistent (the static one,
not the mouse one), in previous code somtimes dashed were anchored to
the static center point, in others, to the moving mouse position, the
later was rather disturbing imho...
2017-04-27 15:28:30 +02:00
b649f53a62 Error in last commit 2017-04-27 22:01:31 +10:00
23b8fa5299 Cleanup: split cmake source/headers 2017-04-27 21:58:43 +10:00
98b6c6f2c0 Merge branch 'master' into blender2.8 2017-04-27 21:42:08 +10:00
21d31f8f58 3D widgets were obscured by view geometry 2017-04-27 19:43:27 +10:00
acec2a92ef Pose-mode drawing used alpha where it shouldn't 2017-04-27 19:31:19 +10:00
a845fc0d39 Fix gpuScaleUniform (caused strange pose-bone size) 2017-04-27 18:44:57 +10:00
f4c548ce2b Use pose-mode colors for pose-bone drawing
Also move static vars into structs
2017-04-27 18:17:47 +10:00
2d11d7c570 Cleanup: use doxy groups for armature 2017-04-27 17:06:52 +10:00
a4b97390d9 Fix basic pose-mode select drawing 2017-04-27 16:57:11 +10:00
58e61446df Fix wrong scene assigned when using sets
Depsgraph was left with wrong set-scene.
2017-04-27 16:21:56 +10:00
4afbd08941 Fix/workaround crash with non mesh geometry
eevee was crashing on curve grometry, draw without material for now.
2017-04-27 15:56:04 +10:00
d8ce3ed140 Cycles: Allow samples to finish in split kernel to avoid artifacts when canceling
Previously canceling a render done by the split kernel could cause artifacts
such as very bright or dark tiles. This was caused by unfinished samples
being included in the output buffer. To avoid this we now wait till all the
currently rendering samples have finished, up to a limit of twice the
expected time for them to finish (currently this is no more than 20 seconds,
but usually its much less). If samples still haven't finished by then we
stop anyways in case there's an endless loop occurring.
2017-04-26 21:28:16 +02:00
c6bf5d4724 Cycles: Change OpenCL split kernel to use single program by default
Single program builds twice as fast as multi programs, so its better for
users to have it as the default.
2017-04-26 21:28:16 +02:00
38563bad9d Cycles: Enable Correlated Multi Jitter for OpenCL and split kernel
Testing showed no issues so there's no reason to not have this.
2017-04-26 21:28:16 +02:00
25b2dfcbf0 [msvc/make.bat] Provide a convenience rebuild.cmd in the build folder for easy rebuilds. 2017-04-26 21:28:16 +02:00
4b682fa3e7 Getting rid of setlinestyle: Paint 'line' strokes. 2017-04-26 21:22:05 +02:00
cf959dc03a Getting rid of setlinestyle: armature drawing code.
Firts usage of 3D version of new dashed line shader... Though not sure
whether that code will be kept for long?
2017-04-26 20:57:18 +02:00
bb43dff935 Add 3D version of dashed line shader.
This is actually nearly same code as 2D version, maybe we can
deduplicate that later?
2017-04-26 20:57:18 +02:00
224f148e22 2D dashed line shader: changed to use viewport side instead of scale.
The scale version was working(ish), but it was not really extendable to
a 3D line version of the shader.

Also note that sequencer view still keeps its 'UI scale' adaptation
(dashes grow together with UI scale setting). Would be nice to do that
everywhere ultimately imho, but nothing urgent here.
2017-04-26 20:57:18 +02:00
795e839d3b Cleanup: rename select engine -> basic
This is used by depth drawing too and had no selection specific code.
2017-04-27 02:51:07 +10:00
a7c5d2e159 Pass graph to depth functions 2017-04-27 02:36:56 +10:00
edd1512741 Draw Manager: cleanup, use doxy categories
Also add DRW_state for accessing current draw state.
2017-04-27 02:04:56 +10:00
7631f4bf6d Draw Manager: use engine drawing for depth drawing 2017-04-27 01:43:05 +10:00
f59d3a7b0c View3D: move depth drawing into own function
No functional changes
2017-04-27 01:01:43 +10:00
c9d4a0930b Merge branch 'master' into 28 2017-04-27 00:58:28 +10:00
dc27d31a21 Merge commit 'master@6ed15c5a41130b55cb57a43a8a9470a91d38c3d5' into blender2.8
# Conflicts:
#	source/blender/alembic/intern/abc_exporter.cc
2017-04-26 16:50:29 +02:00
7517cf6bbb Getting rid of setlinestyle: 3DView ruler. 2017-04-26 15:19:03 +02:00
318216e677 Gawain: add immAttrib2fv helper. 2017-04-26 15:19:03 +02:00
75e9d59b96 Getting rid of setlinestyle: non-camera 3DView render border.
Also fixed wrong color for in-camera render border, and added a comment
to imm_cpack about expected color components order in integer parameter.
2017-04-26 15:19:03 +02:00
Dalai Felinto
e791e01c0b Fix material preview for Cycles and BI
I had to update the .blend files too, and get them to use collections over the nameless old layers.
2017-04-26 14:37:18 +02:00
b38d87fbaf Last commit broke object-armature select 2017-04-26 22:39:12 +10:00
aca6a12330 Draw Manager: pose-bone selection 2017-04-26 22:28:42 +10:00
ec442224df Getting rid of setlinestyle: Squencer space.
Not much to add here, except that it needs the scale of its MVP matrix
to be taken into account here...

Reviewers: merwin, dfelinto

Differential Revision: https://developer.blender.org/D2647
2017-04-26 12:26:30 +02:00
8de3778d11 Getting rid of setlinestyle: 3DView camera view.
Use new 2D dashed line shader in 3DView camera view.

Note that this also involved converting UI_draw_safe_areas() to this
dashed shader, which means it cannot be used anymore with other shaders.

Part of D2647.
2017-04-26 12:17:46 +02:00
88a7d3438d Move imm_draw_line_box_dashed to GPU_immediate_util. 2017-04-26 12:11:40 +02:00
621b8bdf86 Tweak 2D line dashed shader to take a scale parameter.
Even though in some cases this does not seems useful, in others (like
zommed 2D views) we have to correct MVP matrix scaling to get fixed
dashes size.

Note that we could do that differently (commented about it in shader),
would also have been cleaner to extract that MVP scale from within the
shader, but there does not seem to be a way to initialize uniform values
from within a shader, and would rather avoid recomputing the scale for
every run (especially since 3DViewport does not need it e.g.).

Part of D2647.
2017-04-26 12:04:35 +02:00
80b49c1521 UI utils: add helper to get float3 blended color from theme. 2017-04-26 12:00:15 +02:00
2387ba93d2 BLI_math: add helper function to extract XY 2D scale from a 4D matrix. 2017-04-26 12:00:15 +02:00
Dalai Felinto
b2fde7b1ee Silence eevee warnings 2017-04-26 11:25:43 +02:00
Dalai Felinto
c2e91bcfc4 Proper fixup for selection and core
That still not ideal, but so be it. IS_VIEWPORT_LEGACY should be
removed anyways, this is code from pre-draw manager and the
"modern viewport" as well as legacy will go away entirely once the draw
manager is feature complete.
2017-04-26 11:21:55 +02:00
Dalai Felinto
8b4941b7c5 Revert "Fixup for "always use selection in core""
This reverts commit 535cf2c714.
2017-04-26 11:19:15 +02:00
Dalai Felinto
535cf2c714 Fixup for "always use selection in core"
In my previous commit [1] I forgot one of the if() calls. Handled it
differently now.

[1] dc1f491a50
2017-04-26 11:13:22 +02:00
Dalai Felinto
b27775138b Pass depsgraph via Context to selection code 2017-04-26 11:05:04 +02:00
Dalai Felinto
dc1f491a50 Selection: Always use new selection code when building with using core profile 2017-04-26 10:42:40 +02:00
Dalai Felinto
f88e6763d6 Depsgraph and selection: Flush selcol on Depsgraph
Selection code needs to iterate over DEG_OBJECT_ITER otherwise we won't
get modifiers, dupli objects, ...

Also make selection respect selectability flag.

Review by: Sergey Sharybin
2017-04-26 10:42:40 +02:00
3dc6528cd4 Merge branch 'master' into blender2.8 2017-04-26 10:11:03 +02:00
ab168f63f6 Remove show_backface_culling check in select engine
May add back so selection engine can read backface cull state
from from different engines.
2017-04-26 18:08:49 +10:00
3f91567052 Cleanup: draw engine
- use DRW_engine prefix for engine types.
- use engine suffix for files that define a draw engine.
- remove engines from include path (they're only referenced once)
2017-04-26 17:42:39 +10:00
bfc2043332 Draw Manager: add select engine
This does very little currently, but allows changing behavior for
selection drawing in the future.
2017-04-26 17:25:41 +10:00
de0d3ec457 Allow new selection in eevee & blender draw modes 2017-04-26 16:52:02 +10:00
5634763e5e Draw Manager: armature editmode selection 2017-04-26 16:12:01 +10:00
82686f0a0c Eevee: World default shader.
- Use uniform color world for the world probe.
- Refactored the Fresnel expression to be better with Area Lights.
- Squared the roughness for default materials.
2017-04-25 23:51:05 +02:00
bb75b0bcbc Eevee: Disable shadow rendering until we get proper update scheduling.
Performance is quickly getting poor when you have lights otherwise.
2017-04-25 23:51:05 +02:00
7bc637a40d Eevee: Fix Square light with non uniform scale. 2017-04-25 23:51:05 +02:00
d8e83516e2 Draw Manager: support for selection using engines
Needed to remove old draw code entirely.

Object mode selection support, pose and armature still need to be added.
Enabled when 'use_modern_viewport' is set.
2017-04-26 04:59:18 +10:00
041a50291b Eevee: Make default shaders works.
- Added New Batch cache routine to get the split mesh for each material. (optimization needed)
- Did some shader modifications to create default_frag and support a somwhat correct fresnel for lamps (to finish)
2017-04-25 18:47:20 +02:00
Dalai Felinto
00f5c621a6 Outliner: Re-build depsgraph when reordering collections
Otherwise if we create a new collection, and drag a collection into it we either
get a crash, or at the very least we dont get the visibility flags correct.
2017-04-25 18:44:17 +02:00
Dalai Felinto
973f4944e0 Render API: Rename render > render_to_image; view_draw > render_to_view
This is part of the new draw manager design. Any engine (even clay, eevee, ...) should be able to draw to the viewport, as well as render to an image directly.
Changing the API names to conform to that.
2017-04-25 18:03:13 +02:00
Dalai Felinto
4122eeb09a Cycles: Use depsgraph instead of layers 2017-04-25 18:03:13 +02:00
Dalai Felinto
05243a633a Depsgraph: Store Scene in depsgraph struct
This way we can retrieve the scene from depsgraph that were not created from a G.main (e.g., when doing material thumbnail preview render).
2017-04-25 18:03:13 +02:00
Dalai Felinto
b43200a120 Cleanup: Line-width 2017-04-25 18:03:13 +02:00
6822e353ff Merge branch 'master' into blender2.8 2017-04-25 17:04:17 +02:00
99d2d6f387 Alembic import: don't use global main 2017-04-25 17:03:15 +02:00
2aa4f8ab92 Alembic import: removed BaseLegacy from BKE_cachefile_clean
Now we just iterate over all objects. It may be a better idea to use a
smarter approach for performance. However, since this function is not
called regularly (only when changing Alembic file paths), it's not a very
big deal.
2017-04-25 16:59:36 +02:00
7cf7b3b7e5 Draw Manager: clear draw global data after use 2017-04-26 00:39:53 +10:00
acf07e7366 Draw Manager: store context vars per draw
Was performing context access per object for scene, region etc.
While not very slow they don't change during drawing so cache in a struct.

This also makes it possible to draw in views besides the current context.
2017-04-26 00:35:08 +10:00
75a759ea5e OpenGL: better context creation on Windows
Compatibility profile was working fine, this is mostly to get the highest GL core profile version available.

Our minimum requirement is 3.3 core profile.  When we request a specific GL version:
 - AMD and Intel give us exactly this version 
 - NVIDIA gives at least this version <-- desired behavior 
so we ask for 4.5, 4.4 ... 3.3 in descending order to get the best version on the user's system.

Accept OpenGL 3.0 on Mesa instead of 3.3+ compatibility profile. (requested by @LazyDodo) This will be removed after we finish moving to core profile.

Part of T49012 and T51164
2017-04-24 22:30:17 -04:00
9c87bb124a group WITH_LEGACY_OPENGL with the other GL options
Blender subsystems that care about OpenGL use GL_DEFINITIONS, which now includes the newest (temporary) WITH_LEGACY_OPENGL.

Also updated Gawain's CMake to use this instead of its own logic.
2017-04-24 17:41:26 -04:00
Dalai Felinto
0f143627d2 Collection: __FUNCTION__ > __func__ 2017-04-24 18:15:37 +02:00
Dalai Felinto
9f074444ad Layer cleanup: Rename _Iterator_ > _iterator_ 2017-04-24 18:14:41 +02:00
Dalai Felinto
9b94e2a743 Bring back outliner hierachy delete 2017-04-24 18:08:08 +02:00
Dalai Felinto
8c7e0f23c2 Fix view local not working 2017-04-24 18:06:48 +02:00
Dalai Felinto
a8fd510bd5 Outliner: Bring back bases when pertinent
This partially reverts c4e34a84e0

Note: This is necessary for the "delete hierarchy" functionality
2017-04-24 18:06:48 +02:00
Dalai Felinto
1ffdffc699 FOREACH_SELECTED_BASE iterator 2017-04-24 18:06:48 +02:00
2f2e2bae8d Fix own mistake in smoke.c 2017-04-24 17:15:17 +02:00
913e9350a5 Convert BaseLegacy to Base (part) 2017-04-24 16:09:04 +02:00
2010dbe8a5 Merge branch 'master' into blender2.8 2017-04-24 22:11:05 +10:00
f93f4169cb Merge branch 'master' into blender2.8
Conflicts:
	build_files/cmake/platform/platform_apple.cmake
2017-04-23 10:49:39 +02:00
79fd8eeb0e missing from last commit 2017-04-23 04:06:45 +10:00
2acb5d1e38 Fix armature drawing ignoring object matrix
Looks like name-space collision.
2017-04-23 04:03:13 +10:00
23c4f01fb4 Draw Manager: hide 2d curves normals 2017-04-23 03:28:53 +10:00
4ee36a2aea Cleanup: line length 2017-04-22 16:13:18 +10:00
36b29c05db Cleanup: use DRW_shgroup_call prefix for dynamic and fixed
More useful for completion since an 'shgroup_dynamic' is not a thing
(would be confusing if other dynamic functions are added).
2017-04-22 15:53:11 +10:00
9fe9cf8261 fix omission from previous commit
Missed one old call on Linux/X11.
Follow-up to ef640ecf10
2017-04-22 00:58:42 -04:00
ef640ecf10 OpenGL: remove use of GLEW MX
MX (Multiple conteXt) support was dropped from the GLEW 2.0 library to make core profile support cleaner.

Our WITH_GLEW_MX build option was OFF by default already; this commit removes the inactive code paths.

I'm working on a plan for multiple GPUs, contexts, resource sharing, etc. This commit gives us a cleaner starting point for that upcoming work.

Tested on Mac, will test on Linux & Windows immediately after pushing.
2017-04-22 00:35:04 -04:00
1beed61b76 OpenGL/GHOST: don't request accum buffer on Mac
This was blocking core context setup on Mac, since accumulation buffers are obsolete. With this (and appropriate CMake options) I now get

renderer:	'Intel HD Graphics 4000 OpenGL Engine'
vendor:		'Intel Inc.'
version:	'4.1 INTEL-10.24.45'

in system-info.txt intead of 

version:	'2.1 INTEL-10.24.45'
2017-04-21 16:04:03 -04:00
12261aa047 fix unitizialized use warning
The code would only use 'type' uninitialized in error conditions, but it's still better to avoid that.

caught by clang
2017-04-21 15:51:08 -04:00
dcda9b4136 Eevee/OpenGL: fix shader for core profile 2017-04-21 15:48:56 -04:00
8ac1f03f41 Eevee: Cascaded Shadow Maps, follow up.
- Compute coarse bounding box of split frustum. Can be improved
- Make use of 4 cascade.
- View dependant glitches are fixed.
- Optimized shader code.
2017-04-21 16:43:35 +02:00
cc2d501642 Merge branch 'master' into blender2.8 2017-04-21 16:30:24 +02:00
Dalai Felinto
111a53f74c Fix crash when duplicating objects by tagging depsgraph
This may change once depsgraph becomes aware of workspaces.
For now this is the best we can do.
2017-04-21 16:25:20 +02:00
Dalai Felinto
e6f073fe41 Re-enabling Alembic test
(disabled because of bug fixed on 19548040d9)
2017-04-21 16:07:53 +02:00
Dalai Felinto
19548040d9 Fix T51261: New objects aren't selected
The original code was failing because the base to object flushing was
only happening as part of the depsgraph. However we can use the
evaluated values to set the initial values of the base.

In this particular case, we couldn't set the new object visible because
its selectability flag was not set yet.
2017-04-21 15:27:32 +02:00
Dalai Felinto
2f506b9458 Fix objects visibility evaluation bug
This was introduced on 4b77fb3075 no idea how I left this in, shame on me
2017-04-21 15:27:02 +02:00
Dalai Felinto
cc8f104098 Tag depsgraph update when hide and hide_select are changed
We were not updating depsgraph when collection just "became" selectable,
but although this doesn't change object selection, it change its
selectability.
2017-04-21 14:42:45 +02:00
81011679dd Merge branch 'master' into blender2.8 2017-04-21 14:19:05 +02:00
bfa888cef2 Cleanup: move draw-cache creation from BKE to DRW
Creating draw-cache should only ever be used by the draw-manager.
2017-04-21 22:06:06 +10:00
Dalai Felinto
c7f00feaba Unify RNA and core depsgraph.objects
Note: Since this is not listbase nor array I'm also expanding
RNA_types.h to allow for custom data.
2017-04-21 13:00:40 +02:00
Dalai Felinto
4b77fb3075 Move DEG_OBJECT_ITER inside depsgraph 2017-04-21 13:00:40 +02:00
3540b50780 Cleanup: use id-property access macros 2017-04-21 19:47:01 +10:00
Dalai Felinto
6294bd1b8b Depsgraph: Move DAG_get_object function
BKE_depsgraph.h will be deprecated eventually, so moving it to DEG_depsgraph_query.h
2017-04-21 11:33:15 +02:00
3e7968c35f Draw Manager: don't assign bool from flags
Some MSVC versions don't support this.
2017-04-21 18:43:54 +10:00
15d73e53c3 Gawain: fix for building empty element list 2017-04-21 18:33:44 +10:00
Dalai Felinto
dafdf72904 Rename: Alembic job struct sl > scene_layer 2017-04-21 10:03:44 +02:00
Dalai Felinto
01a627dac9 Include the set in the depsgraph objects iterator
Pending: Include the set in the rna depsgraph.objects

In fact it would be nice to unify them both. However this will likely
change once Depsgraph incorporate this iterator, so I'm not sure we
should bother with that.

Related to T51203
2017-04-21 09:56:26 +02:00
3a75e84376 Draw Manager: edit-mode 3d text drawing
Draw cursor and selection, also support for fast-display.
2017-04-21 17:58:18 +10:00
2b9738b7f8 Merge branch 'master' into 28 2017-04-21 17:14:13 +10:00
c4780ee459 Cleanup: redundant struct qualifier & long lines 2017-04-21 04:40:44 +10:00
d21a4407dc Cleanup: rename & change order of declaration 2017-04-21 04:29:33 +10:00
677aa36632 Curve: draw curve/surface/text geometry
Note that displists will be removed, but this wont be hard to replace.

Signed-off-by: Campbell Barton <ideasman42@gmail.com>
2017-04-21 04:23:28 +10:00
Dalai Felinto
9d1421c069 RNA: depsgraph.objects
Iterator to return the objects evaluated from depsgraph. The
iterator itself will change once CoW is implemented.

This reproduces the behaviour of DEG_OBJECT_ITER but for Python.
2017-04-20 17:21:06 +02:00
Dalai Felinto
f2a2adc910 RNA: bpy.context.depsgraph 2017-04-20 17:20:56 +02:00
74023d46ce Implement DAG_get_scene_layer
Even though this will have to change once we get workspaces, we will
still have a depsgraph for the Scene.

This is required for the upcoming depsgraph.objects RNA iterator.
2017-04-20 17:18:31 +02:00
66377b89da Fix T51251: Armature/Normal-button scaled twice 2017-04-20 22:12:08 +10:00
afc885cd13 Draw Manager: round vertex size up
Without this assigning `gl_PointSize = sizeVertex`
made vertices too small.
2017-04-20 21:16:37 +10:00
84c464a4b8 Use theme vertex size for lattice & curve vertices 2017-04-20 21:16:37 +10:00
3d17ece539 Eevee: Start Implementation of Cascaded Shadow Maps 2017-04-20 13:07:51 +02:00
b386828671 Eevee: Do shadow cube render in one pass. 2017-04-20 13:07:51 +02:00
3fa665f56d Draw Manager: Fix Gradient Background 2017-04-20 13:07:51 +02:00
6028ff2736 Correct error drawing curve normals 2017-04-20 21:01:23 +10:00
aa4102a441 Merge branch 'master' into blender2.8
Disabled a unittest, to be re-enabled when T51261 is fixed.

# Conflicts:
#	source/blender/alembic/intern/alembic_capi.cc
2017-04-20 12:50:20 +02:00
8e0c57a812 Gawain: fix immediate mode drawing exceeding IMM_BUFFER_SIZE
Would cause crazy colors in file selector.
2017-04-20 20:43:56 +10:00
28ed66552b Fix debug checks were enabled for release builds only
NDEBUG meanse Not DEBUG.
2017-04-20 11:03:55 +02:00
Dalai Felinto
913472165b Fix T51215: depsgraph evaluation of collection properties (overrides) 2017-04-20 11:00:32 +02:00
Dalai Felinto
3cb0e8e1af IDProperty: New util function to merge groups recursively 2017-04-20 11:00:32 +02:00
Dalai Felinto
53d59af364 Corrections for layers unittest based on design change
Example, imagine an object Cube in collections 1 and 2 where both
collections are nested to A. Now we set a "color" property as follow:

```
Scene -> GREEN
--
A     -> RED
↳ 1   -> BLUE
↳ 2   -> -
```

In this case the object will be RED, because of A↳ 2.

Now if we have:

```
Scene -> GREEN
--
A     -> RED
↳ 1   -> -
↳ 2   -> PINK
1     -> -
--

The object will be PINK because of A↳ 2.

Note that the (top level) collection 1 doesn't influence the object color
because there are no overrides on it. The scene render settings (GREEN
in this case) are only used as fallback if an override is not set at
all.
2017-04-20 11:00:32 +02:00
b5b0fc9c94 Cleanup: Use explicit unsigned int type
This is as per our code style states ans as majority of the team
prefers types to be used.
2017-04-20 10:56:08 +02:00
09bf8f4a69 Use reflect for calculating second normal 2017-04-20 18:56:53 +10:00
d8bf090090 Merge branch 'master' into 28 2017-04-20 18:16:01 +10:00
462d9e37ea Cleanup: remove type prefix from render-data vars
Render data is never mixed with other object types,
no need to make a distinction.
2017-04-20 16:25:20 +10:00
c7c162e2e0 Fix merge of master (no more base...). 2017-04-19 22:13:57 +02:00
6a5b53fe6f Merge branch 'master' into blender2.8 2017-04-19 22:11:53 +02:00
a738e985c6 Fix update drawing curve editmode 2017-04-20 05:55:48 +10:00
72efee07ff Draw Manager: draw curve normals 2017-04-20 05:33:52 +10:00
896d62d1c2 Fix error disabling curve handles 2017-04-20 04:53:55 +10:00
43a273616b No need for while-loop counting curve-normals 2017-04-20 03:01:13 +10:00
e28a92bacb Cleanup: put overlay & wire in own structs 2017-04-20 02:53:33 +10:00
c0f9d962f0 Merge branch 'master' into blender2.8
Updated tests/python/bl_alembic_import_test.py to be 2.8-compatible.
2017-04-19 17:33:22 +02:00
307059ed61 Alembic import: correctly linking objects to scene layer.
The import is always performed on the active LayerCollection. If there
is none, a new one is created.
2017-04-19 17:30:06 +02:00
248946542d Fix alpha overlay for sculpt/paint when using core profile
Same fundamental problem as fonts -- there is no longer GL_ALPHA format.
2017-04-19 16:57:44 +02:00
e708f45eab Cleanup: Remove executable flag from GLSL shaders 2017-04-19 16:57:44 +02:00
553d820b80 Remove basic shader from paint cursor overlay
Immediate mode built-in shader is used for this drawing already.
So there is no reason to try building basic shader which is not
supported in the core profile.
2017-04-19 16:57:44 +02:00
4bee5b80d4 Convert direct usages of base defines
This replaces all direct usage of:
- FIRSTBASE
- LASTBASE
- BASACT
- OBACT

Some usages still remain in legacy utility functions which are called
all over the place.
2017-04-19 16:52:27 +02:00
2f2420709c Remove local view toggle operator 2017-04-19 16:52:27 +02:00
1427765ec5 Cleanup: remove redundant assignments
Return the 'Batch' instead of assigning a variable.
2017-04-20 00:52:53 +10:00
cdba73c8fa Draw Manager: curve support
Draws the curve centerline and editmode verts/handles.

Handle theme colors, and normal display still need adding.
2017-04-20 00:38:44 +10:00
ce6b01f203 Cleanup: move theme-id to shader-group into funcs 2017-04-20 00:26:44 +10:00
d8c698a76d Fix mistake in previous commit 2017-04-19 16:16:30 +02:00
3f11be3f7d Get rid of glMatrixMode calls
With the explicit calls we don't need to worry about current state
outside of the GPU module now. In fact. we don't need to worry about
current matrix mode in core profile at all.

Legacy OpenGL now has some code which ensures current matrix mode
when using explicit calls to push/pop matrix.
2017-04-19 15:22:58 +02:00
288892bf08 Make UI block drawing closer to master
There is no need to break assumptions of what's being modified
by this call and what's restored. The changes in this function
simply spread crappyness outside of the UI block.
2017-04-19 15:22:58 +02:00
ba4d23fe37 Fix node editor drawing when built with core profile
There are two major things in this commit.

First one is to have proper stack for projection matrices. This is
something what OpenGL specification grants to have at least 2 elements
for and what is required to have for proper editor drawing without
refactoring the way how we restore projection matrix.

Supporting this stack have following advantages:

- Our GPU stack is closer to OpenGL specs, making it easier to follow
  by other developers who are always familiar with OpenGL.

- Makes it easier to port all editors to a new API.

- Should help us getting rid of extra matrix push/pop added in
  various commits to 2.8 branch.

The new API follows the following convention:

- gpuPushMatrix/gpuPopMatrix ALWAYS deals with model view matrix
  and nothing more.

  While this name does not fully indicate that it's only model view
  matrix operator, it matches behavior of other matrix operations
  such as transform which also doesn't indicate what matrix type
  they are operating on.

- Projection matrix has dedicated calls for push/pop which are
  gpuPushProjectionMatrix/gpuPopProjectionMatrix.
2017-04-19 15:22:58 +02:00
781108cdc6 Merge branch 'master' into blender2.8
# Conflicts:
#	source/blender/alembic/intern/abc_exporter.cc
#	source/blender/alembic/intern/abc_exporter.h
2017-04-19 15:07:54 +02:00
b01df8222f Comment out places which are using texture matrix mode for core profile
There is only two places which are using texture matrix mode:

- Tiled tface support.
- Texture shading mode for texture mapping.

Both cases are subject for reconsideration: it is likely that we'll be getting
rid of tface, which means game properties like tiles needs to be revisited
anyway. As for texture shading it is using basic shader which is also not
supported by core profile anyway.
2017-04-19 14:44:42 +02:00
Dalai Felinto
9c84d99819 Unittests: Layer render settings evaluation
More failing unittests to add to the existing ones.
2017-04-19 14:35:29 +02:00
bca55e7adf Cleanup, indentation of preprocessor 2017-04-19 14:33:34 +02:00
fb2330c1e0 Use model view matrix instead of texture matrix for texture brush overlay
It is required for our new matrix stack to only have projection and model view
matrix modes. This commit ports paint cursor overlay to model view matrix.
2017-04-19 14:13:53 +02:00
4b376dbe84 Fix wrong RNA update function declarations
This fixes lots of crashes, especially with painting/brush updates.
2017-04-19 12:23:06 +02:00
Dalai Felinto
54f03914b0 Fix identation 2017-04-19 11:17:14 +02:00
76ecbd38f2 Edit Mode Engine: Fix shader compilation on AMD. Also fix Bweight display. 2017-04-19 11:09:07 +02:00
b3edd94e42 Eevee: Fix black background 2017-04-19 11:09:07 +02:00
9a5b379374 Cleanup: set-but-unused warning 2017-04-19 15:57:37 +10:00
94d5ca7cdb Eevee: Remove last deprecated textureCubeLod 2017-04-18 22:56:55 +02:00
8c584dcb65 Eevee: fix core profile. 2017-04-18 22:46:09 +02:00
0610bc88a3 Eevee: Re fix Compilation on MSVC 2017-04-18 22:34:44 +02:00
5670e4149b Eevee: fix compilation error with MSVC 2017-04-18 22:02:46 +02:00
303a9ae0e8 Eevee: Optimize Spherical Harmonic computation time (17ms -> 1ms) 2017-04-18 21:33:09 +02:00
80db709250 Eevee: Spherical Harmonic diffuse.
For now it's done each frame and it's rather slow (16ms) but result will be cached soon.
2017-04-18 21:33:09 +02:00
5bbc803ff0 Eevee: Fix crash on core profile. 2017-04-18 21:33:09 +02:00
85b4398d90 Draw Manager: Fix uniforms array not been found. 2017-04-18 21:33:09 +02:00
94789e30a5 Gawain: fix building WITH_GL_PROFILE_CORE
I intially hard-coded this for compatibility profile. This commit makes the library respect the main CMake options so they match the rest of Blender.
2017-04-18 14:51:42 -04:00
26e171c4d9 OpenGL: don't require legacy extensions when using WITH_GL_PROFILE_CORE
These checks guarantee we meet the minimum expected GL requirements listed in T49012.
2017-04-18 14:44:57 -04:00
473c2b1c94 Gawain: fix stupid APPLE_LEGACY mistake
@dfelinto caught this while building on Linux

fixes a copy/paste mistake from b0351bd3bd
2017-04-18 12:43:50 -04:00
53c56dcd08 Gawain: enable 10.10.10 vertex format for core profile (any platform)
This is an OpenGL 3.3 feature, currently being used for surface normals. It's 1/3 the size of floating point triples and perfect for normals or colors.

See T49012 for why Windows can use this feature regardless of core vs compatibility.
2017-04-18 12:09:17 -04:00
45b3555cba OpenGL: fix compatibility with Mac & Mesa
This combines the Mesa fix (16e929e6ff by @brita_) with the Mac fix (89e23c743e by @merwin).

And uses the same fix for another call to glFramebufferTexture introduced in f1fb605ec9.
2017-04-18 12:09:17 -04:00
b0351bd3bd Gawain: define feature macros in a more compatible way
Thanks to @sergey for proactively testing clang 4.0, which does not accept defined(FOO) as part of macro definitions.
2017-04-18 12:09:17 -04:00
72fc837d1e Cleanup: replace num/ct/tot with 'len' 2017-04-19 01:04:42 +10:00
bb31648b9b Merge branch 'master' into blender2.8 2017-04-18 16:47:25 +02:00
2c29b94384 Fix text drawing with core profile
The issue was going to the fact that GL_ALPHA was deprecated in core profile
and common solution online is to use GL_RED instead. That is what is done in
this commit.
2017-04-18 16:42:16 +02:00
Dalai Felinto
c9d78b6c43 Merge remote-tracking branch 'origin/master' into blender2.8 2017-04-18 16:30:13 +02:00
Dalai Felinto
bc6a75b405 Revert "Object Info node support for GLSL mode and the internal render"
This reverts commit 76425feed8.

** Note **
This was supposed to be a merge, but it was rebased.
2017-04-18 16:29:42 +02:00
b8fd6f94a0 Cleanup: replace num/ct/tot with 'len' 2017-04-19 00:12:12 +10:00
Dalai Felinto
2926675bfd OpenGL: Update GPU_legacy_stubs.c
The list is now re-ordered too.
And we are no longer including the new tokens suggestions here (the ones
defined as USE_ in gl-deprecated.h)
2017-04-18 16:02:17 +02:00
Dalai Felinto
80b6f8b1d8 OpenGL: Comment out the old tokens from gl-deprecated
Those tokens are still valid. Although we should not being using them,
they should not prevent us from building with core profile.

In the future we can have a new flag WITH_GL_CORE_STRICT for those.
But only after we build with core profile by default
2017-04-18 16:02:17 +02:00
Dalai Felinto
e5bf726f44 BGL: Remove deprecated enums
Note: The enums that are deprecated and supported are still there
2017-04-18 16:02:17 +02:00
4778369ee8 Eevee: Fix warning 2017-04-18 15:37:22 +02:00
76425feed8 Object Info node support for GLSL mode and the internal render
Object Info node can be useful to give some variation to a single material assigned to multiple instances. This patch adds support for Viewport and BI.

{F499530}

Example: {F499528}

Reviewers: merwin, brecht, dfelinto

Reviewed By: brecht

Subscribers: duarteframos, fclem, homyachetser, Evgeny_Rodygin, AlexKowel, yurikovelenov

Differential Revision: https://developer.blender.org/D2425
2017-04-18 15:37:22 +02:00
8fdd568343 Draw Manager: T51218 Support edit-mesh hide 2017-04-18 23:33:50 +10:00
1129fd1c51 Use better workaround ofr getting scene layer for Derivedmesh's mask
This replaces access to the first scene layer (which was wrong) with a linear
lookup of scene layer by it's active index.

This seems to be a better temporary solution to have things working for until
we've got proper workspace, depsgraph and it's per-layer storage in place.
2017-04-18 15:06:41 +02:00
363ea3a1ce Remove deprecated GL_LIGHTING chunk from manipulator draw code.
This is new feature, will likely need own shader to get same result.
Just commented it as TODO, though, this is not high priority.

Part of T51164.
2017-04-18 14:58:45 +02:00
b27a98df1d Merged master@e12c3110024dc4b62ffefa739288218b04e39f71 into blender2.8
This doesn't merge entire master into blender2.8, but at least solves
one conflict.
2017-04-18 14:18:06 +02:00
a229ca8f48 Garwain: fix ShaderInterface buffer shrinking 2017-04-18 22:04:00 +10:00
edcf128ce2 Eevee: Introduction of world preconvolved envmap.
For now only compute GGX convolution. The GGX LUT used for the split sum approximation (UE4) is merged with the LTX mag LUT that uses the same parameters (theta and roughness)
2017-04-18 13:10:17 +02:00
f1fb605ec9 GPUFramebuffer: Allow to bind a specific texture mip to framebuffer. 2017-04-18 12:52:29 +02:00
40e69ad6df GPUTexture: Fix Cubemap upload 2017-04-18 12:50:28 +02:00
eda0ebc7b3 GPUTexture: Add Mipmap Control functions. 2017-04-18 12:50:28 +02:00
Dalai Felinto
7bf8ab3c49 Remove 4.1 pseudo-deprecated calls from gl-deprecated
First: we settle on core profile 3.3, not 4.1. Second, GL_CURRENT_PROGRAM still exists in 4.1 and 4.2. But it is recommented to use GL_ACTIVE_PROGRAM instead.

Following the logic of gl-deprecated.h we should define it to USE_GL_ACTIVE_PROGRAM instead. That said, removing it for now.
2017-04-18 12:09:32 +02:00
554277986d Gawain: fix missing NULL check
Also shadowed variable warning
2017-04-18 15:04:01 +10:00
16e929e6ff OpenGL: Fix crash on start with Mesa drivers
glFramebufferTexture() is only available from OGL 3.2, it is also not part of the ARB_framebuffer_object extension.
I don't know if there is a better way to check for mesa drivers or if using the 2D version will have issues with f2f16a256, but so far I had no problems
2017-04-17 22:31:56 +02:00
c6e8a004a1 Gawain: fix for last commit
Follow-up to 3bc6b831d8

Initial code was getting the number of ShaderInterfaces that could fit between two pointers (which makes no sense). I really meant number of bytes.

Surprised it worked on Mac, glad I tested on Windows before bed  :D
2017-04-17 04:01:46 -04:00
3bc6b831d8 Gawain: shrink ShaderInterface name buffer
ShaderInterface stores names of custom uniforms and all attributes in an internal buffer, but it doesn't know how large to make this buffer until all inputs are scanned.

This commit shrinks the buffer to the exact size needed.
2017-04-17 01:45:21 -04:00
b3e38cfc6b Gawain: look up uniforms by name quicker
ShaderInterface_uniform searches custom uniforms first, then builtin uniforms if needed.

This reduces the amount of string matching since you're almost certainly looking for one of those custom uniforms. Otherwise you would've called ShaderInterface_**builtin**_uniform.
2017-04-17 01:19:28 -04:00
47e0d2b235 OpenGL: tweak GPU_texture_create_nD
- test for 2D textures first since it's the most common case
- declare variables close to where they're used
- fix compiler warning for proxy (uninitialized use)
- safe return if n != 1, 2, 3 (should never happen)
- white space
2017-04-16 15:11:38 -04:00
8dcf7a46a2 OpenGL: fix GPU_SHADER_SIMPLE_LIGHTING_SMOOTH_COLOR
The fragment shader expects a normal, but the vertex shader was not providing one.

Fix: added a new vertex shader that has normals + smooth color interpolation.

I also split gpu_shader_3D_vert in two:
- one with just position
- one with position + normal

For each of the builtin shaders, we should be able to look at the GLSL and tell exactly what it's doing. Using #defines and #ifdefs for rendering options makes the shaders hard to read and easy to break.
2017-04-16 15:04:07 -04:00
6a2c82332b fix mistake from last commit
I didn't build this BGE-related code before pushing. My bad!

fix for af61b5eb0c
2017-04-16 13:57:16 -04:00
af61b5eb0c cleanup use of immUniformColor
- use best function for the job
- don't specify alpha if 100%
- 'f' for floating point literals
2017-04-16 13:44:34 -04:00
ae07130540 Gawain: add immUniformColor3ubvAlpha
Convenience function for specifying colors with separate RGB and alpha. Alpha ranges from 0 to 255.
2017-04-16 13:33:21 -04:00
7041b99b5a use immUniformColor instead of immUniform("color"
The specialized color functions are better in every way:
- faster lookup (don't have to match "color" string)
- flexible inputs (RGB with separate alpha)
- automatic alpha = 1.0 if not specified

Sort of related to T49043
2017-04-16 12:25:42 -04:00
bf441fcfac Gawain: move AttribBinding funcs to private interface
Other parts of Gawain uses these internally, but they're not part of the public API.

Part of T51219
2017-04-16 11:21:45 -04:00
4a41bc8cea Gawain: fix compiler warnings
vertex_format.c implements both public and private functions, so needs to include the private header.

Follow-up to 7c57ca5109
2017-04-16 11:08:26 -04:00
30249499c4 Gawain: fix compilation on MSVC 2013
attrib_binding.c uses NULL, so include stddef.
Also swapped stdlib for stddef in vertex_format.c, since it only needs NULL.

Not sure why MSVC 2017 and clang/Mac work without this...

Thanks to @youle for reporting!
2017-04-16 11:00:59 -04:00
888e742f84 OpenGL: minor cleanup & TODO
Just clearing out some old git stashes.

No point getting old GL light model to work on old Intel GPUs (both are obsolete for 2.8)
2017-04-15 19:43:56 -04:00
da17928fd5 Gawain: look up builtin uniforms by enum, not by name
This speeds up color and transformation matrix lookups at draw time (used by almost all shaders).
2017-04-15 19:19:00 -04:00
abd1934be6 Gawain: use ShaderInterface to manage vertex attribs
This eliminates tons of glGetAttribLocation calls from the drawing loop. Vast majority of code can keep making the same function calls. They're just faster now!
2017-04-15 18:06:54 -04:00
2593ce9c33 Gawain: remove 2D matrix uniforms from ShaderInterface
- remove 2D-specific variants of BuiltinUniform enum
- rename remaining builtins to exclude "_3D" since they can be used by 2D or 3D shaders

Follow up to D2626
2017-04-15 17:07:29 -04:00
ea105bab2b Gawain: fix header comments
Missed this when splitting VertexBuffer from Batch -- they used to live in the same file.
2017-04-15 15:42:58 -04:00
7c57ca5109 Gawain: move some VertexFormat funcs to private interface
Other parts of Gawain uses these internally, but they're not part of the public API.

Part of T51219
2017-04-15 13:10:14 -04:00
16f08b08fc Gawain: rename AttribBinding clear for consistency
AttribBinding is only used internally by Gawain.

Part of T51219
2017-04-15 13:06:43 -04:00
Julian Eisel
b92b250b08 Fix missing manipulator update after undo
Steps to recreate the error were:
* Enter edit mode
* Change Vertex positions
* Undo -> Manipulator position isn't updated
2017-04-15 15:58:49 +02:00
2f78d58681 Cleanup: lattice drawing had mesh include & names 2017-04-15 17:52:42 +10:00
376d05bf30 Cleanup: GPU header guards 2017-04-15 17:51:08 +10:00
8c0864b5ed GPU matrix: add back type checks
Without this gpuGet functions would cast everything
(no type or size checks and override const variables).
2017-04-15 17:45:20 +10:00
ce1dc55453 Remove redundant declaration 2017-04-15 17:17:09 +10:00
4b043994e8 GPU Matrix API: clean up after 2D-3D unification
See GPU_matrix.h & gpu_matrix.c for the important changes. Other files are mostly just updated to use the latest API.

- remove unused functions, defines, enums, comments
- remove "3D" from function names
- init to Identity transform (otherwise empty stack)
- gpuMatrixReset lets outside code return to initial state

Part of T49450
Follow up to D2626 and 49fc9cff3b
2017-04-15 01:29:56 -04:00
ff3942505a Cleanup: Use doxy-groups for draw-cache 2017-04-15 14:24:30 +10:00
608b711beb Cleanup: explicit names for return arguments and position last 2017-04-15 14:07:57 +10:00
Dalai Felinto
49fc9cff3b GPU Matrix API: Remove ModelView/Projection 3D suffix 2017-04-14 18:07:16 +02:00
Dalai Felinto
cb2c4bfb74 GPU Matrix API refactor: Stick to a single 4x4 stack for 2D and 3D
* Brings us closer to core profile, all matrices are working, and apart
from a problem with text drawing, Blender is working fine.

* Reduce the coding overhead of having to setup/teardown when
alternating between 2D and 3D drawing sessions.

* Gives us fewer modes and states we need to keep track of.

Unfortunatelly this also "rejects a fundamental change" the original
design was trying to make - that 2D is different from 3D and
deserves its own best implementation.

That said, it is still aligned with the function API design as
originally implemented (i.e., it still uses gpuTranslate2D, ...).

Finally, if you build with core profile and this patch you get:
https://developer.blender.org/F545352

[The text glitch is an unrelated issue].

Reviewers: merwin, sergey, brecht

Differential Revision: https://developer.blender.org/D2626
2017-04-14 18:07:16 +02:00
e7c4eddace Add fatal error in CMake when trying to build WITH_GAMEENGINE but without WITH_LEGACY_OPENGL
This won't work currently.
2017-04-14 17:16:15 +02:00
89e23c743e OpenGL: fix Mac crashing on startup
On Apple we use OpenGL 2.1 + an ARB extension for framebuffers.

The glFramebufferTexture function is part of OpenGL 3.0 but not part of the ARB extension. This commit fills that gap.

All other platforms are using GL 3.0+ already so it's not an issue there. All platforms (Mac too) will use GL 3.3+ soon so this workaround will be removed.
2017-04-14 10:35:30 -04:00
Dalai Felinto
bef2aab862 Gawain: fix crash when drawing batches (e.g., scale manipulator)
Introduced in b02786ae6b
2017-04-14 14:33:29 +02:00
95b3632112 Merge branch 'master' into blender2.8
Conflicts:
	source/blender/alembic/intern/abc_exporter.cc
2017-04-14 12:39:54 +02:00
6cda217a82 Fix Blenderplayer (c) 2017-04-14 12:14:47 +02:00
26f25b1b27 OpenGL: use ShaderInterface to look up uniforms
These were the last few glGetUniformLocation calls in source/blender.

The new system gets uniform information once when a shader is created, then uses this cached info every time after that.
2017-04-13 18:37:26 -04:00
Dalai Felinto
532532afc7 Revert "OpenGL core: add some missing gpuBegin to allow clay with no UI"
This reverts commit 1c01811cce.

It broke everything.
2017-04-13 18:24:04 -04:00
02273441dc Draw Manager: lattice editmode drawing 2017-04-14 04:34:12 +10:00
Dalai Felinto
1c01811cce OpenGL core: add some missing gpuBegin to allow clay with no UI 2017-04-13 19:18:42 +02:00
Dalai Felinto
fe559d0659 OpenGL: do not support legacy matrix when using core profile 2017-04-13 18:45:17 +02:00
257e6c0c7d Remove deprecated opengl stuff from opensubdiv
This removes glGetBooleanv queries for GL_LIGHTING. This has been #ifdef'd
out with legacy opengl disabled. Thus a false positive still shows up in
the gl queries. Also, note that this removes support for wireframes in
opensubdiv, when desabling legacy opengl, which should be fixed later.

Part of T49043
2017-04-13 16:57:53 +02:00
8458ffcf5b Remove some elbeem debug functions
Some elbeem debug functions had old gl drawing calls. I removed the
functions instead of converting, because Blender doesn't even build
with them enabled anymore, because some elbeem debug libs got removed
at some point.

Part of T49043
2017-04-13 16:57:53 +02:00
Dalai Felinto
5a5f1dc8e4 Unittests for depsgraph layer collection render settings evaluation
Some of the tests are failing at the moment.
Those problems were introduced in eba09b1520
2017-04-13 16:28:50 +02:00
Dalai Felinto
9b53bab0b7 Update despsgraph when set/unset variables 2017-04-13 15:38:35 +02:00
Dalai Felinto
368b3c145b Layer collection settings API
This way we can set a property via RNA, and also force an update of scene layer (which I am using for unittesting)
2017-04-13 15:38:15 +02:00
2128e26d86 Draw Manager: initial lattice support
Still misses support for edit-mode selection & weight drawing.
2017-04-13 22:09:59 +10:00
b96777b3e1 Cleanup: minor changes to logic for outline drawing
Use brace placement following code-style too.
2017-04-13 21:46:18 +10:00
102c331146 Fix RNA LayerCollectionEngineSettingsClay not inheriting from LayerCollectionSettings.
Was hence missing the 'name' property, which broke the 'dict-like'
behavior of Scene.collection_properties.
2017-04-13 12:17:50 +02:00
6f268ac55d Merge branch 'master' into blender2.8 2017-04-13 13:02:39 +03:00
0a62e971b2 Draw Engine: Draw sets recursively
Matchers regular viewport behavior
2017-04-13 19:42:59 +10:00
ffa63d2de6 Use regular header guards in GPU 2017-04-13 19:11:55 +10:00
1c426d5b6c OpenGL: implement 2D with 4x4 matrices
... even though 3x3 feels better.
 
This is a compromise to get core profile up & running sooner. Eventually I'd like to finish the original 3x3 plans, but this commit will let us get on with other tasks.

External API stays (almost) the same. Our GLSL shaders can use this without any changes.

Part of T49450 and T51164
2017-04-13 04:00:19 -04:00
fae01c3a54 use new 3D matrix impl in draw manager
These functions mark the beginning and end of 3D drawing, causing the matrix API to use our own implementation instead of legacy OpenGL.

Part of T49450
2017-04-13 01:07:52 -04:00
56e9629d96 Gawain: look up array uniforms correctly
Look up "name[0]" when asked for "name", since that marks the beginning of the array.

We're comparing to the name stored in ShaderInterface which comes from glGetActiveUniform.
2017-04-13 01:07:51 -04:00
f7087109ce cleanup image drawing setup 2017-04-13 01:07:51 -04:00
b02786ae6b Gawain: use ShaderInterface to manage uniforms
This eliminates tons of glGetUniformLocation calls from the drawing loop. Vast majority of code can keep making the same function calls. They're just faster now!

- Batch_Uniform*
- immUniform*
- gpuBindMatrices
- and others
2017-04-13 01:07:51 -04:00
6bfb9b7b5f Gawain: add immUniform4iv
Needed soon by OCIO.
2017-04-13 01:07:50 -04:00
c61b7b0263 Gawain: add (temp) legacy GLSL support to ShaderInterface
A temporary measure needed by GPU_basic_shader.

Part of T51164
2017-04-13 01:07:50 -04:00
02fd9a1aaf Gawain: improve ShaderInterface
- builtin uniforms match what Blender needs
- set input counts in struct (stupid mistake)
- look up uniforms by name
- look up builtin uniforms by enum
- check attrib/uniform locations for error
2017-04-13 01:07:49 -04:00
c0a9e388b3 GLSL: rename edit_overlay -> edit_mesh_overlay
Avoid confusion with overlays with non-mesh types
2017-04-13 14:13:46 +10:00
64660b902c Use 'safe' macros for common free operation
Same as MEM_SAFE_FREE macro,
checks for NULL, runs free then sets NULL.

Blocks of code that do this many times are noisy and likely
errors here wouldn't be noticed immediately.

Also NULL's static vars which were being left set.
2017-04-13 13:37:27 +10:00
c080702e73 fix drawing file column dividers (T51189)
Problem was an edge case where vertex_ct logic and draw logic disagreed on how many dividers to draw.

Fix: copy draw logic to earlier vertex_ct

I also skip any drawing or setup if vertex_ct = 0, and set color attribute only for each line's provoking vertex. Small optimizations but these things add up.
2017-04-12 14:20:55 -04:00
Dalai Felinto
2871bad8ea Fix T51188 compilation errors in Windows 2017-04-12 18:58:38 +02:00
Dalai Felinto
6e4cc26265 Layer / Outliner / Depsgraph: update depsgraph when running outliner operators 2017-04-12 16:55:04 +02:00
Julian Eisel
428e07a9f7 Outliner: Draw nested collections before objects of a collection
Collections may contain a huge list of objects, would be annoying having
to scroll over it all the time to get to the nested collections.
2017-04-12 14:47:54 +02:00
Julian Eisel
64905c4c77 Outliner: Fix objects of master collection not showing up in 'Master Collection Tree' 2017-04-12 14:45:42 +02:00
af2fc7b637 Merge branch 'master' into 28 2017-04-12 20:23:44 +10:00
0c9a2def8b Draw Engine: remove hard coded limit on array sizes
This removes MAX_STORAGE, MAX_BUFFERS, MAX_TEXTURES, MAX_PASSES limits.

Actual memory saving isn't so important, it just means we don't need to
manually bump these based on changes to engines.
2017-04-12 19:51:14 +10:00
b380f4927e Remove bool -> int cast
Wont work as expected on big endian systems
2017-04-12 18:23:40 +10:00
208f25d626 Cleanup: naming & line length 2017-04-12 18:23:17 +10:00
cc0c5dbd91 Cleanup: use DRW_cache_mesh prefix w/ mesh objects
Avoid confusion for non mesh types where verts/wire/surface might apply.

Other object types use this convention already.
2017-04-12 18:11:10 +10:00
9e94479359 EditMesh Render: remove edges-of-vert loop
Replace topology check which checked edges twice
with a loop on the edge array.
2017-04-12 15:43:20 +10:00
dc1499ba1c Merge branch 'master' into 28 2017-04-12 14:23:47 +10:00
ed8c71da1c Cleanup: replace char array with struct 2017-04-12 14:08:44 +10:00
5cf090ffec EditMode: remove edge-hash from MeshRenderData
LoopTri's can access this data.
2017-04-12 13:45:56 +10:00
e78412c905 Cleanup: use const pointer for view access API 2017-04-12 12:10:01 +10:00
95dd478e47 Cleanup: line length
Avoid right-shift
2017-04-12 12:05:11 +10:00
42349f6efd fix compile warnings 2017-04-11 19:35:30 -04:00
e8ddd258ef Correct own error in adding colors
Make comment regarding GLSL more clear.
2017-04-12 00:56:19 +10:00
5a4fceff1b Make image drawing code working with core profile
The issue was caused here by usage of deprecated GL_CURRENT_PROGRAM
which was returning rubbish value.

Now we use imm API and create vertex format prior to immBindProgram.
This made us required to have some sort of state passed from setup
function to actual drawing.
2017-04-11 16:49:39 +02:00
Dalai Felinto
35ee9db1e2 Renaming: sl > scene_layer 2017-04-11 16:49:32 +02:00
Dalai Felinto
4fe4c82dbd Fix blenderplayer(tm) 2017-04-11 16:24:59 +02:00
70e4f1e003 Draw Manager: Fix blended color. 2017-04-11 16:13:29 +02:00
181c8f8ccd Draw Manager: Fix Background sets not being drawn. 2017-04-11 16:13:29 +02:00
Dalai Felinto
aef4519c8a Renaming: sl > scene_layer 2017-04-11 16:09:30 +02:00
Dalai Felinto
6f8c838b78 Cleanup: remove no longer needed BASE_ defines 2017-04-11 15:51:18 +02:00
Dalai Felinto
9a303d5db7 Bring snapping back (Base / BaseLegacy) 2017-04-11 15:46:01 +02:00
513aacbdb6 Use immediate mode API for OpenColorIO 2017-04-11 15:39:04 +02:00
fd5b882a67 Move cage_manipulator.c to new GL code.
Note: I’d assume gawain equivalent to glDrawArrays would be batches? But
for two lines drawn twice this looks totally overkill anyway, so
switched back to basic immediate-mode-like API.

A bit frustrating to work on this code, since afaict you cannot check
the results in Blender, being mostly unused currently...
2017-04-11 15:19:00 +02:00
b8c4be0844 FIx copy/paste mistake in own previous commit. 2017-04-11 15:19:00 +02:00
85f81293c4 GL/WIP: fix crash drawing text object
Note that this doesn't set the normal as it should (noted as a TODO),
just committing to avoid the crash.
2017-04-11 22:46:56 +10:00
88fddd118f Draw Manager: replace varargs with a pointer array
Allows to ensure correct number of args
2017-04-11 21:20:18 +10:00
7c4e164ff3 Get rid of last deprecated OpenGL calls in arrow_manipulator.c
Hope that makes sense...
2017-04-11 12:47:38 +02:00
633a2a3592 Move arrow2d_manipulator to new immediate mode GL. 2017-04-11 12:46:49 +02:00
9d00b7680f Uncomment deselected center point color 2017-04-11 15:48:54 +10:00
e199eae39d Draw Manager: Add center-color for linked/multiuser objects
Draws a blue center circle for library objects.
As with regular drawing, this uses a hard-coded color.
2017-04-11 14:05:39 +10:00
c8e2436734 Merge branch 'master' into blender2.8 2017-04-11 11:01:16 +10:00
016790b3b0 Object Engine: Fix Selected Group Objects color. 2017-04-10 22:23:50 +02:00
4f063dc4dd Object Engine: Ported Force Field object drawing. 2017-04-10 22:23:50 +02:00
fb1ecbc2da Gawain: remove PRIM_QUADS_XXX
Thanks @mont29 for finishing off the last few QUADS in blender.
2017-04-10 16:20:24 -04:00
f0404c3382 Get rid of last PRIM_QUAD usage, in blf_font.c/blf_glyph.c. 2017-04-10 21:21:38 +02:00
c9685a148f Nuke three remaining uages of PRIM_QUAD in drawobject.c
This was slightly less obvious, especially particle billboard drawing.
That one now requires 1.5 times more space in VBOs and ParticleDrawData
buffers, since we have to draw two triangles per particle, instead of a
single quad... And diagonal of each quad is now drawn in wire mode, not
sure how much we consider this an issue (as in, will this particle draw
code change a lot in future?).

From quick check on the web seems there is no other way to do anyway. :/
2017-04-10 20:33:09 +02:00
490fea6107 Minor cleanup/fix for own rB45f3150c9844326 merge. 2017-04-10 18:52:35 +02:00
d8fa3dd7c3 GL: use imm* module for 2D cage manipulator 2017-04-11 02:32:53 +10:00
304935e02a GL/playanim: use immediate mode wrapper, replace glDrawPixels 2017-04-11 02:05:53 +10:00
45f3150c98 Merge branch 'master' into blender2.8
Conflicts:
	source/blender/editors/space_view3d/drawobject.c
2017-04-10 17:34:31 +02:00
5f70116030 OpenGL: Fix textureXd deprecated calls. 2017-04-10 16:59:20 +02:00
01bd6da68f Draw Manager: Add Manipulator Back. 2017-04-10 16:59:20 +02:00
9a38a6bdab GPencil 2D Drawing: get rid of PRIM_QUAD_XXX.
Here we can easily use a PRIM_TRIANGLE_STRIP instead!
2017-04-10 16:54:21 +02:00
346964eb3f Merge branch 'master' into blender2.8
Conflicts:
	source/blender/editors/gpencil/drawgpencil.c
2017-04-10 16:53:12 +02:00
39451ac712 Fix compilation error with strick flags caused by missing abort() 2017-04-10 16:20:18 +02:00
Dalai Felinto
e68b808564 Fix glCheckFramebufferStatusEXT 2017-04-10 15:53:08 +02:00
9fd3435a93 First batch of PRIM_QUAD_XXX replacement by PRIM_TRIANGLES. 2017-04-10 15:17:26 +02:00
Dalai Felinto
2d158a425d Upgrade glew to v2.0 2017-04-10 14:53:32 +02:00
f2f16a2568 Eevee: First Shadows implementation
Using Texture Arrays to store shadow maps so less texture slots are used when shading. This means a large amount of shadows can be supported.

Support Projection Shadow Map for sun like in old BI/BGE.

Support Cube Shadow Map for Point/Spot/Area lights. the benefit of using it for spot light is that the spot angle does not change shadow resolution (at the cost of more memory used). The implementation of the cubemap sampling is targeted for 3.3 core. We rely on 2D texture arrays to store cubemaps faces and sample the right one manualy. Significant performance improvement can be done using Cubemap Arrays on supported hardware.

Shadows are only hardware filtered. Prefiltered shadows and settings comming next.
2017-04-10 12:36:32 +02:00
0811d089b4 Draw Manager: Use Texture flag in Framebuffer init. 2017-04-10 12:36:32 +02:00
fad3fe4ed1 GPUTextures: Work on cubemap support and array textures 2017-04-10 12:36:32 +02:00
da082a095b Eevee: Fix spot lights 2017-04-10 12:36:32 +02:00
Dalai Felinto
f87815705b Make build with GL 3.3 again
This is a workaround while the PRIM_QUADS_XXX are still in the code
2017-04-10 12:21:13 +02:00
Dalai Felinto
b6ba507c1b Layers unittest: layer_cyncing test was not being called 2017-04-10 10:08:29 +02:00
Dalai Felinto
90b2b99505 Unitettesting: Force python errors to show as error 2017-04-10 10:03:02 +02:00
Dalai Felinto
29c738258b GL stubs: no need to assert when calling deprecated calls 2017-04-10 09:33:57 +02:00
Dalai Felinto
2482f94706 Expand OpenGL stubs to allow for breakpoints 2017-04-10 09:15:59 +02:00
Dalai Felinto
91056337a8 Add stubs to build WITH_GL_PROFILE_CORE
This is an auto-generated list, crossing gl-deprecated.h, glew.h and the
Blender code. It allows Blender to build with core profile.

WITH_OPENGL_LEGACY=ON: nothing changes

WITH_OPENGL_LEGACY=OFF and WITH_GL_PROFILE_CORE=OFF:
It stubs deprecated legacy calls.

WITH_OPENGL_LEGACY=OFF and WITH_GL_PROFILE_CORE=ON:
It stubs deprecated legacy calls thus allowing Blender to build with
core profile only.

Technically you only want to use WITH_OPENGL_LEGACY=OFF when
WITH_GL_PROFILE_CORE=ON. But it doesn't hurt to have it working for both
scenarios.

Reviewed by: merwin

Differential Revision: https://developer.blender.org/D2610
2017-04-10 08:45:00 +02:00
Julian Eisel
15bcfaa36b Merge branch 'master' into blender2.8 2017-04-09 22:51:38 +02:00
928f5df1b4 Cleanup: glsl indentation 2017-04-09 16:36:39 +10:00
c800ee6bfe Merge branch 'master' into blender2.8 2017-04-09 16:09:12 +10:00
79e862ad6b GPU lib support for WITH_LEGACY_OPENGL
For early testing of core profile:
- GPU_legacy_support = false
- GPU_display_list_support = false
- GPU_geometry_shader_support = true

Relates to T49012
2017-04-08 02:34:30 -04:00
f60626e3a6 OpenGL: drop support for EXT_geometry_shader4
See gpu_shader.c for the main changes.

EXT_geometry_shader4 brought this feature to GL versions < 3.2, but now it's just cluttering up our code.

Soon all platforms will be on version 3.3 so we won't even have to check support at runtime!
2017-04-08 02:21:13 -04:00
d5883bb1ba Gawain: remove GL enum from primitive API
Callers now have to use Gawain's PRIM enum to specify geometric primitives.

This makes the API more bullet-proof (at least less vulnerable) since GLenum covers waaay more than GL_POINTS, GL_LINES, etc.

Also prepares us for Vulkan.
2017-04-08 01:19:48 -04:00
0947c97fad OpenGL: use PRIM instead of GL enum everywhere else
Well, everywhere that uses Gawain for drawing. Places that call OpenGL directly still use GL enums.

Part of T49043
2017-04-08 01:19:48 -04:00
1de61696fd Correct constraint manipulator colors
Widget show as color of constrained axis
2017-04-08 12:08:51 +10:00
8205a19323 Fix WITH_LEGACY_OPENGL=ON
This wasn't working outside of gpu module.
2017-04-08 12:01:29 +10:00
bd3a1b9490 OpenGL: use PRIM instead of GL enum for immBegin
Getting ready for a Gawain API change...

Part of T49043
2017-04-07 16:31:26 -04:00
c1dc078840 Gawain: remove GL enum from vertex format API
Callers now have to use Gawain's COMP enum to specify vertex attributes.

This makes the API more bullet-proof (at least less vulnerable) since GLenum covers waaay more than component types.

Also prepares us for Vulkan.
2017-04-07 16:00:03 -04:00
1ad5287260 use COMP instead of GL enum to construct vertex format
I converted all other files a day or two ago; this file was part of a recent merge.
2017-04-07 15:51:39 -04:00
da24848fb4 OpenGL: remove UI_reinit_gl_state function
All line & point drawing is responsible for setting its own state (as of January 2016) making this redundant.
2017-04-07 15:10:48 -04:00
7a75581d92 OpenGL: transition away from GL_QUADS
Single quads are drawn as a TRIANGLE_FAN, with 4 verts in the same order.

Multiple quads now use PRIM_QUADS_XXX and will need further work. Only 8 places still use this.

Part of T49043
2017-04-07 15:03:24 -04:00
d6ae3789a1 Gawain: append XXX to PRIM_QUADS to make it scary
Quads are not part of modern GL or Vulkan, so we should avoid them. XXX makes coders think "hmm how could I draw this without using quads?"

Quads will be removed during the transition to core profile.

Part of T49043
2017-04-07 14:21:10 -04:00
23b10b549a fix use of uninitialized variable
Bug crawled in via 2944438e9a as part of custom manipulators.
2017-04-07 13:48:11 -04:00
3f6d25f4eb shrink fixed-size internal GLSL string buffers
We concatenate #defines and #extensions into these, and can count the max string lengths needed. 256 is enough to hold today's strings; we can adjust later if needed.
2017-04-07 13:28:42 -04:00
1a156f7103 use best GPU matrix function for the job
Follow-up to 204e067111 which coverted manipulators' legacy GL matrix calls to new ones.

part of T49450
2017-04-07 13:24:00 -04:00
f0ce39ab16 OpenGL: support GLSL 3.3 core profile
When WITH_LEGACY_OPENGL = OFF.

This is our final target for Blender 2.8, all previous versions will be dropped in the future. GLSL 3.3 is richer so we don't require as many extensions.
2017-04-07 12:51:11 -04:00
Dalai Felinto
db444fc783 Workaround for weightpoint not working
Kudos to Germano Cavalcante for spotting the issue, the real fix is to pass SL to the function though
2017-04-07 18:00:54 +02:00
31c272e840 Simplified some test code in render_layer_common.py 2017-04-07 17:51:23 +02:00
ad60283bc8 No more need to alter sys.path in each and every render_layer unit test.
I tried the clean way, by setting the PYTHONPATH environment variable for
CTest, using SET (CTEST_ENVIRONMENT blablab), but that didn't seem to
work.
2017-04-07 17:50:47 +02:00
6cf3fa9ff0 Tests: import blendfile without modifying sys.path 2017-04-07 17:29:14 +02:00
063bae4fcc Merge branch 'master' into blender2.8
# Conflicts:
#	source/blender/alembic/intern/abc_exporter.h
#	source/blender/alembic/intern/abc_util.cc
2017-04-07 17:28:22 +02:00
Julian Eisel
711ac03fa1 OpenGL: Get rid of PRIM_QUADS usage in manipulators code 2017-04-07 17:05:33 +02:00
Dalai Felinto
4e09533f8c OpenGL / Outliner: QUADS are not supported in core 2017-04-07 16:43:05 +02:00
Julian Eisel
204e067111 Fix drawing of planar transfrom manipulators, update matrix code 2017-04-07 16:04:04 +02:00
2dd84c9570 3D Manipulator: add back protected flags check
This used to be a separate pass
2017-04-07 23:01:20 +10:00
2944438e9a 3D View: manipulator from custom-manipulators branch
Original code from @Severin with changes from @dfelinto & @hypersomniac.

This doesn't cause many functional changes
besides using new transform manipulators.

Submitted as D2604
2017-04-07 21:23:32 +10:00
Dalai Felinto
8ec1a05ef5 Replace CGSubSurf direct includes to GL/glew.h 2017-04-07 13:03:31 +02:00
d649f26858 Fix compilation error after recent changes 2017-04-07 09:58:54 +02:00
9c01aaa3dd OpenGL: disable rotate manipulator clipping on Mac
This fixes T51143.

gl_ClipDistance is part of GLSL version 1.3 but Mac is stuck on 1.2 for now.

This workaround uses GPU_SHADER_3D_UNIFORM_COLOR for the entire rotation widget, ignoring any clipping plane. The CLIPPING shader only works on GLSL 1.3+ so I removed its 1.2 cruft.

A legacy implementation using gl_ClipVertex might be possible, but is not worth the effort. This problem (and workaround) goes away when all platforms move to 3.3 core profile.
2017-04-07 03:08:00 -04:00
c986a2c7aa fix rotation manipulator's Push/PopMatrix balance
Was popping out the bottom of the stack.
2017-04-07 03:51:10 -04:00
115a889bd7 OpenGL: refactor ui_panel_category_draw_tab
changes:
- exact vertex count
- take bool (filled vs outline) instead of GLenum

This function has some flexibility that is not currently used. I left that in.
2017-04-06 19:37:50 -04:00
f69678482c OpenGL: refactor UI_draw_roundbox functions
Each function takes a bool (filled vs outline) and a color. We already had multiple ways of passing color in; these are still here. Special variant for anti-aliasing.

- took GLenum out of interface
- removed UI_RB_ALPHA flag (only one place really used it)
- use exact vertex count
- removed redundant state changes (BLEND, LINE_SMOOTH)
2017-04-06 19:15:26 -04:00
Dalai Felinto
934dfc4200 New build option WITH_LEGACY_OPENGL
This introduces a new CMake option - WITH_LEGACY_OPENGL. Without this option
things may not draw perfectly, however, we should soon be able to build with
OpenGL core profile.

The matrix-related api calls are (still) not handled here (glTranslate, ...).

There seems to be no consensus on whether to make this build option the
default. We can talk about this later. For now two things are the
priority:

(1) To get rid of deprecated calls when WITH_LEGACY_OPENGL is ON
(2) To make core profile work for Mesa/Mac when WITH_LEGACY_OPENGL is OFF

Reviewers: merwin, sergey, campbellbarton

Differential Revision: https://developer.blender.org/D2603

Many thanks for Sergey Sharybin for the help.
2017-04-06 18:46:33 +02:00
843922a480 Depsgraph: Prefer use anonymous structs for unused arguments 2017-04-06 16:58:19 +02:00
035b340f48 Depsgraph: Remove old depsgraph header from window manager 2017-04-06 16:44:32 +02:00
ec178b861c Depsgraph: Remove print dependnecies operator
This is not really supported with the new depsgraph.
2017-04-06 16:43:09 +02:00
ed1ef06199 Depsgraph: Remove old depsgraph header from blender internal 2017-04-06 16:38:43 +02:00
2d80f37bce Depsgraph: Remove old depsgraph header from python 2017-04-06 16:36:15 +02:00
05ffca5c8a Depsgraph: Remove old depsgraph header from modifiers 2017-04-06 16:34:38 +02:00
1165027308 Depsgraph: Remove old depsgraph header from freestyle 2017-04-06 16:32:59 +02:00
35db70a466 Depsgraph: Remove olde depsgraph header from new depsgraph 2017-04-06 16:18:42 +02:00
e9e703f0dd Depsgraph: Remove old depsgraph header from collada 2017-04-06 16:17:21 +02:00
7da2379124 Depsgraph: Remove old depsgraph header from blenloader 2017-04-06 16:13:57 +02:00
7b45edacab Depsgraph: Remove old header from blenkernel 2017-04-06 16:11:50 +02:00
2613ad64c5 Depsgraph: Remove old depsgraph header from alembic files 2017-04-06 15:49:56 +02:00
ae33f78229 Depsgraph: Remove old depsgraph header from game engine 2017-04-06 15:40:53 +02:00
d36fb4f08f Depsgraph: Remove old depsgraph headers from creator 2017-04-06 15:40:08 +02:00
a1b8c0bca2 Depsgraph: More type definitions to new depsgraph header 2017-04-06 15:37:46 +02:00
d8f931c9b7 Changes from custom-manipulators branch
Minor changes from custom-manipulators branch,
before larger changes are applied.
2017-04-06 22:10:09 +10:00
0feca278a4 Merge branch 'master' into blender2.8 2017-04-06 12:31:26 +02:00
Dalai Felinto
967b04cb07 Layer unittesting: pep8 touch up on test_evaluation_selectability_f.py 2017-04-06 12:22:21 +02:00
0debbe2b7f Gawain: VertexFormat_add_attrib (function name change)
See intern/gawain for the API change. Other files are updated to use the new name. Also updated every call site to the recommended style:
unsigned int foo = VertexFormat_add_attrib(format, "foo", COMP_ ... )
2017-04-06 01:18:12 -04:00
c2f5cd8f64 Gawain: add VertexBuffer prefix to functions
See intern/gawain for the API change. Other files are updated to use the new names.
2017-04-06 01:18:12 -04:00
957b408458 Fix manipulator showing in pose & editmode 2017-04-06 15:17:38 +10:00
0899b4bb3f Fix building without clay engine 2017-04-06 15:17:38 +10:00
ff3880ff93 Initialize immediate mode in Animation Player
PS. With this solution, immediate mode can be initialized and finalized consecutively if you drop a video

part of T49043
2017-04-06 01:54:10 -03:00
9f72580d07 Merge branch 'master' into blender2.8 2017-04-06 12:26:55 +10:00
13f77de214 Merge branch 'master' into blender2.8 2017-04-06 12:04:48 +10:00
e63ba6d0f4 Remove NULL check from gimbal_axis 2017-04-06 11:32:45 +10:00
Dalai Felinto
40cb5a067b Immediate Mode: missing ALPHA_TEST in gpuRestoreState
Missed in rBcbd78c81268f06e7b658ae042f3ab6a3816149b0
2017-04-05 21:46:08 +02:00
fa5e5f898e Cleanup: Remove depsgraph stubs 2017-04-05 15:57:36 +02:00
1980f3d3b8 Motion paths: Switch to a slower evaluation which does not need bases to be sorted
New dpesgtraph does not ensure bases are sorted by the evaluation order
any more, so motion paths update might go horrribly wrong.
2017-04-05 15:56:27 +02:00
5b386270a5 Cleanup: Get rid of legacy depsgraph header file 2017-04-05 15:50:45 +02:00
a13878b9af Cleanup: Remove legacy depsgraph private header from modifiers 2017-04-05 15:46:56 +02:00
70aa5f97f2 Cleanup, remove unused function 2017-04-05 15:45:54 +02:00
3bb88a7807 Merge branch 'master' into blender2.8 2017-04-05 15:36:55 +02:00
Dalai Felinto
929c45b7d4 Paint cursor changes, so it save/load only the required flags 2017-04-05 15:02:31 +02:00
Dalai Felinto
cbd78c8126 Immediate Mode: replacing glPushAttrib/glPopAttrib
Reference document: http://docs.gl/gl3/glPushAttrib

This patch only tackles the bits that are set by Blender with the
following exceptions:

1) Deprecated states (e.g., GL_STIPPLE) are not saved/restored

2) The exception being GL_ALPHA_TEST, which will be removed, but it may
affect drawing too much now. To be removed once we no longer set GL_ALPHA_TEST
elsewhere.

3) paint_cursor will be tackled separated, since it was abusing
glPush/PopAttrib in the first place.

4) Despite what the glPushAttrib page above may suggest, GL_DEPTH_WRITEMASK needs glGet, not glIsEnabled

5) BGE is still a problem since it relies on GL_ALL_ATTRIB_BITS which
would lead to a way more complete/lenghty solution. Since the BGE has
other (OpenGL deprecated) problems anyways, it can be handled on its own
time.

Finally, the original design for 2.8 was to implement a proper stack
system. However we need to move to core profile sooner than later. So
this is a pragmatic temporary (that may be permanent) solution.

Reviewers: merwin, campbellbarton

Differential Revision: https://developer.blender.org/D2600
2017-04-05 15:02:31 +02:00
Dalai Felinto
bbfa1a8639 Viewport: 3D cameras don't need glPushAttrib/glPopAttrib 2017-04-05 15:02:31 +02:00
ba5b792dd9 Depsgraph: Remove all layer bit flags related checks
These bits became obsolete with the new layer system, so we can
simplify some code around them or avoid existing workarounds which
were trying to keep things working for them.

There are still work needed to be done for on_visible_change to
avoid unnecessary updates, but that can also happen later.
2017-04-05 11:39:30 +02:00
1f6037c887 Fix T50976: Blender UI problems with certain theme files.
Core of the issue was that some of our Theme colors are RGB-only, but
were loaded as RGBA.

Note that tracking all possible cases is pretty impossible, so we'll
have to tackle those as they get reported am afraid.
2017-04-05 11:01:27 +02:00
2f700b8280 GPU_immediate_util: missed last commit 2017-04-05 18:53:34 +10:00
a4fac21fc5 Cleanup: Move imm_draw utils into own file
These were in BIF_glutil which is documented to be removed,
so best not define new API's there.
2017-04-05 18:43:59 +10:00
e9bb018a4a Merge branch 'master' into blender2.8
Conflicts:
	source/blender/alembic/intern/abc_exporter.h
2017-04-05 10:02:25 +02:00
4dadb6d445 Naming constancy for 'imm' utility functions
- use 'imm_draw_' prefix for functions that draw.
- use '_3d' suffix for 3d functions, no suffix for 2d functions.
- use terms fill/wire (shorter than filled / lined).

Also add `imm_draw_circle_fill_3d` (only had wire version)
2017-04-05 17:46:25 +10:00
bcd95dbdbb Merge branch 'master' into blender2.8 2017-04-05 11:40:17 +10:00
064eba208e revert recent cleanup, keep useful changes
Don't want to annoy module owner.

What is kept:
- UI_view2d_scale_get with unused y scale
- corrected comment
- unsigned --> unsigned int
2017-04-04 19:36:32 -04:00
Julian Eisel
ebe1b4f11f Fix rotation manipulators not clipping
Added new shader for clipping, also cleaned up rotation manipulator
drawing code a bit.
This code should be replaced by new transform manipulators soon, just
keeping this working in the meanwhile.
2017-04-05 01:33:10 +02:00
Julian Eisel
dd4de189dd Fix blenderplayer compilation 2017-04-04 21:52:28 +02:00
125ce644f2 cleanup
I started cleaning up UI_view2d_scale_get where the y scale was unused, then got carried away...

- for loop scope
- declare variables closer to where they are used
- move early exits closer to function start
- unsigned --> unsigned int
2017-04-04 15:40:21 -04:00
Dalai Felinto
db0f67f464 Collada export cleanup 2017-04-04 20:44:22 +02:00
9ecb196237 fix: Collada export selected worked only for the very first export (needs further testing and cleanup, see comments) 2017-04-04 19:17:52 +02:00
Dalai Felinto
f10219a977 Immediate Mode: handle other cases of glPop/glPushClientAttrib
Those cases were not using ClientAttrib but they should :)
Rather use a OpenGL3.3 alternative anyways.
2017-04-04 18:43:01 +02:00
Dalai Felinto
fa317eb69c Fix collada exporting for Blender 2.8
Instead of exporting all the scene objects, I'm exporting the scene
layer objects instead.
2017-04-04 17:45:55 +02:00
Dalai Felinto
69f7b513b5 Immediate Mode: removing unecessary comment on gpencil (false positive) 2017-04-04 17:04:03 +02:00
Dalai Felinto
a0ef482124 Image Draw: remove unused code since 2009
(removing false positive deprecated OpenGL calls)
2017-04-04 16:47:09 +02:00
7fc84d4e32 Merge branch 'master' into blender2.8 2017-04-04 15:47:58 +02:00
Dalai Felinto
c8cff31922 UV editor using new depsgraph for shadow uv 2017-04-04 14:31:01 +02:00
Dalai Felinto
c87bfb1f7d Immediate Mode / DerivedMesh: Handle UV Shadow 2017-04-04 14:31:01 +02:00
Dalai Felinto
0e95270eb7 Depsgraph: placeholder function for COW objects query 2017-04-04 14:31:01 +02:00
Dalai Felinto
1baa236acb CTX_data_depsgraph(bContext *C); 2017-04-04 14:31:01 +02:00
Dalai Felinto
5eac4e3057 Immediate Mode: glPop/glPushClientAttrib 2017-04-04 14:31:01 +02:00
373d362e4a Fix bad level call. 2017-04-04 11:04:00 +02:00
4fe8395215 Cleanup: avoid long lines (search tools complain!) 2017-04-04 17:38:51 +10:00
0c68c92840 fix node editor drawing (T51086)
Fixed a few issues
- wrong transform matrices
- assert on node with no sockets
- color of collapsed nodes, some title areas

Also includes minor cleanup.
2017-04-04 01:15:35 -04:00
e9944fee33 Draw Manager: Fix engine_type not set 2017-04-03 22:30:34 +02:00
ccaa21df6d Infinite Grid: View angle fade
and show Z axis in special persp views
2017-04-03 21:52:42 +02:00
4a8aaab0b2 Draw Manager: Use engine type pointer instead of engine name.
Faster search
2017-04-03 21:52:42 +02:00
ccd8353d58 Object Engine: Fix multi user lamp data display bug.
Objects that were using the same lamp data were having the same display matrices.
This is fixed by allowing engine to store a memory block inside the object itself.
2017-04-03 21:52:42 +02:00
682c4dcd1e Draw Manager: Fix Cache timers
Also expand the timer average range.
2017-04-03 21:52:03 +02:00
eca256bc32 GPULamp: Separate GPULamp from GPUMaterial
Since we need GPULamps for draw engines, it makes sense to separate them.
2017-04-03 21:52:03 +02:00
8e0bfee1e5 Draw Manager: Fix glBlitFramebuffer error 2017-04-03 21:52:03 +02:00
46cd87f5da Eevee: LTC area lights
Using Linear Transform Cosines to compute area lighting. This is far more accurate than other techniques but also slower.

We use rotating quad to mimic sphere area light. For a better approximation, we use a rotating octogon.
2017-04-03 21:52:03 +02:00
Dalai Felinto
a78e97b206 Layer/Depsgraph: Update depsgraph for new objects 2017-04-03 18:47:50 +02:00
Dalai Felinto
d31c4c5666 Layer/Depsgraph: Fix selectability issues 2017-04-03 18:05:06 +02:00
Dalai Felinto
db6b4639fc Layer: Adding unittest for a problem with selectability evaluation
This is currently failing (and causing the object_delete test to fail). To be fixed separately
2017-04-03 17:46:03 +02:00
Dalai Felinto
ee6f858c91 Layer: Small refactor on layer_collection_add 2017-04-03 17:45:59 +02:00
5884c9f1ba Merge branch 'master' into blender2.8 2017-04-03 15:15:56 +02:00
3b6eaf8d96 Cleanup: style 2017-04-03 22:10:39 +10:00
fbcb920748 Rename circle_partial -> disk_partial
We may have a 'disk' function (not the partial version).
2017-04-03 22:10:38 +10:00
d1e55be96e Add gluPartialDisk replacement (imm_draw_filled_circle_partial)
Needed for custom-manipulators branch but generally useful.
2017-04-03 15:25:43 +10:00
eba09b1520 Blender 2.8: Hook of layer collections evaluation in DEG
This moves selectability/visibility flag flush from some hardcoded
places in the code to depsgraph. This way it is possible to simply
tag depsgraph to update those flags and rest it'll do on its own.

Using depsgraph for such flush is an overkill: those flags are fully
static and can not be animated, so it doesn't really make sense to
hook only those to depsgraph.

However, in the future we will have overrides on collections, which
ideally would need to be animatable and drivable and easiest way
to support this is to do this on depsgraph level, so it ensures
proper order of evaluation for animation and drivers. And it seems
logical to do both overrides and flags flush from depsgraph from
this point of view.

This commit also includes the evaluation of IDProperty for collections,
which basically are just another form of override. So once we implement
the other kind of overrides the flushing and collection evaluation won't
change.

Patch by Sergey Sharybin and Dalai Felinto
2017-04-01 01:27:08 +02:00
Dalai Felinto
97b9afda37 Layers / Depsgraph: Unittesting for selection and visibility evaluation 2017-04-01 01:22:39 +02:00
Dalai Felinto
5bfa6d8455 Fix crash in draw manager when no object active 2017-04-01 01:01:57 +02:00
Dalai Felinto
4c2f5ab33e Bumping version to 2.80
This should have been done earlier. But now that we may see more activity in master due to bcon3 merges, it is even more important to stress out the separation between master and 2.8.

Also I needed the version bump for idproperties doversion (they needed
to happen in _after_linking, and we don't have access to
DNA_struct_elem_find there).

Last but not least, every time I posted a video or image from 2.80, I
got someone confused about the version showing in the infobar.
2017-04-01 00:04:45 +02:00
Dalai Felinto
b0998df608 Layers: Fix scene copying after IDProperty changes
(also unittest: split scene copy in 4 tests)
2017-03-31 17:37:52 +02:00
Dalai Felinto
d9b89ca0d0 Layers unittest: Fix tests breaking since Folded was removed 2017-03-31 17:37:49 +02:00
Dalai Felinto
1f17b72efe Layers unittest: Breaking pep8, but getting tests to work again
I will investigate this further later.

The big problem is that the way I'm running tests if I have any error
(e.g., ImportError) the pass still pass.
2017-03-31 17:37:45 +02:00
Dalai Felinto
d1f402acfd Fix blenderplayer (tm) 2017-03-31 15:02:28 +02:00
70fdf0fe37 Merge branch 'master' into blender2.8 2017-03-31 23:52:22 +11:00
0be064067a Blender 2.8: Cleanup, no need in escape 2017-03-31 10:28:27 +02:00
e254aa8965 Eevee: Codestyle, optimisation and a few fixes
Something is very wrong with the energy factor. For now I tweaked them by hand to fit cycles.
2017-03-31 01:07:51 +02:00
Dalai Felinto
3fdbd78a6b Layer / IDProperty: Prevent previously created demo files from crash 2017-03-30 18:53:46 +02:00
Dalai Felinto
f2c6c831e3 Layer: remove no longer used settings 2017-03-30 18:40:31 +02:00
Dalai Felinto
ce3c7e8ff5 Layers: use IDProperty and override collection properties system
First this replace a custom data struct with IDProperty, and use
IDProperty group merge and copying functions. Which means that a collection
property setting is only created if necessary.

This implements the "Layer Collection settings" override system, as
suggested in the "Override Manifesto" document.

The core is working, with Scene, LayerCollection and Object using a
single IDProperty to store all the render settings data. Next step is to
migrate this to depsgraph.

Note: Clay engine "ssao_samples" was hardcoded to 32 for now. It will come
back as part of "Workspace Settings" later.

Many thanks for Bastien Montagne for the help with the UI template
nightmare ;)

Differential Revision: https://developer.blender.org/D2563
2017-03-30 17:01:23 +02:00
Dalai Felinto
98e69631b0 Remove unused variable (warning since recent Scene/SceneLayer change) 2017-03-30 14:33:57 +02:00
Dalai Felinto
3f6a74560e Layers: Scene->basact > SceneLayer->basact (more work)
This brings back adding hooks among other areas
2017-03-30 11:41:33 +02:00
Dalai Felinto
35b731c9c8 Prevent crash on weight paint
Weight painting is still wrong, but it doesn't crash any more.
2017-03-30 11:25:53 +02:00
Dalai Felinto
f4d597efff Fix breakage when using radial control (shift f) with weight paint
This was likely introduced on rBf90b480f957f . Basically the BLF routines have their own shaders, so any previous programs must be unbind before it
2017-03-30 11:20:54 +02:00
10b27bd30a fix screen layout thumbnails (T51078)
GPU_framebuffer no longer handles transform matrices, which this code was relying on. Made screen_preview_draw responsible for its own ModelView matrix.
2017-03-30 03:01:50 -04:00
126ee42a30 fix OpenGL Render to image (T51082)
This restores the feature for legacy viewport only. Modern viewport, Clay, Eevee, etc. will need further work.

Eventually we should rename this something other than "OpenGL".
2017-03-30 02:32:33 -04:00
0dc30e9dd8 fix build on Mac/clang
Not all code paths returned a value, so we can use a safe default (8-bit RGBA) when the input is bogus.
2017-03-30 01:43:51 -04:00
4743fa52ac Eevee: Diffuse Light (2/2) and GGX low quality lights
GGX is missing sun lamps area.
2017-03-29 23:45:44 +02:00
ccb9f683e5 Eevee: fix HDR buffer 2017-03-29 23:45:44 +02:00
Julian Eisel
15336eb262 Merge branch 'master' into blender2.8 2017-03-29 23:01:16 +02:00
Dalai Felinto
e922e42fe6 Remove BASE_VISIBLE, BASE_SELECTABLE, TESTBASELIB (no longer used) 2017-03-29 22:33:09 +02:00
Dalai Felinto
61134dc02c Base: update localview, however ...
Local view will not be supported in 2.8, at least not at first. This updates the code anyways.
2017-03-29 22:33:09 +02:00
Dalai Felinto
08875452b0 Base: update createTransObject
I was hoping this would fix the issue of the object not moving after you copy it (right now you need to manually grab the object afterwards). But unfortunatelly it does not
2017-03-29 22:33:09 +02:00
Dalai Felinto
9571811b5d Base: update (unused) image_aspect function, copy_attr_menu and its sub-functions
Since this is unused, I didn't test the code. It should be fine though.
2017-03-29 22:33:09 +02:00
Dalai Felinto
63bbf753fc Base: update select_group 2017-03-29 22:33:09 +02:00
Dalai Felinto
328dcae3a9 Fix fit camera view frame to selected objects 2017-03-29 22:33:09 +02:00
Dalai Felinto
40f764f922 Fix viewselected (NUMPAD PERIOD) 2017-03-29 22:21:14 +02:00
Dalai Felinto
539e41f226 Fix T51083: View all is broken in 2.8 2017-03-29 21:04:21 +02:00
Julian Eisel
b0581cd92c Correct own earlier commit for recursive behavior of property groups 2017-03-29 12:53:38 +02:00
Julian Eisel
ac08482886 Fix glitches caused by new outliner versioning code
Mainly caused by TreeStoreElem.flag not being cleared.
2017-03-29 12:31:27 +02:00
Julian Eisel
38d0ea4f69 Alternative fix for crash displaying 'New Window' keymap item
rB870440dee910c9 just did NULL-check for Main pointer, actual issue is
that bContext pointer was NULL. This can be fixed by ensuring
PROP_ENUM_NO_CONTEXT flag is not set by calling
WM_operator_properties_sanitize when creating RNA buttons. Now, layout
previews are visible in keymap editor too.
2017-03-29 12:27:10 +02:00
Dalai Felinto
870440dee9 Prevent crash when seeing the window new on keymaps
CTX_data_main(C) is NULL in those cases :/
2017-03-29 11:39:36 +02:00
2be098a1a0 Merge branch 'master' into blender2.8 2017-03-29 20:20:53 +11:00
Julian Eisel
ff3e1fa760 Merge branch 'master' into blender2.8 2017-03-28 23:11:10 +02:00
855b56b90c Add GL_LINE_STRIP_ADJACENCY support to Gawain
This primitive is used in geometry shaders like new grease pencil stroke shaders
2017-03-28 13:05:45 +02:00
885260117d Merge branch 'master' into blender2.8
Conflicts:
	source/blender/blenloader/intern/readfile.c
	source/blender/windowmanager/intern/wm_window.c
2017-03-28 10:41:10 +02:00
6d21970aa0 Eevee: Diffuse Lights (1 / 2)
I added srgb tonemapping for previewing purpose. Also since the color buffer is still not HDR, there is ugly artifacts (fixed in part2)
2017-03-28 00:09:45 +02:00
4d3d10f625 New Outline: Fix warning. 2017-03-28 00:06:14 +02:00
21d0f71963 New Outline: Fix ATI compile error. 2017-03-28 00:05:41 +02:00
6435983876 New Outline: make it countour the screen. 2017-03-27 16:36:13 +02:00
0396a15cbb New Outlines: fix upper edge 2017-03-27 14:09:55 +02:00
b33693cb44 New Grid: small modification
Fix wrong coord picked when display only one axis.
Small optimizations here and there.
2017-03-27 14:01:47 +02:00
deda6a43fc Draw Engines: Make g_data struct part of the viewport storage
This makes viewport cache construction independant from each others and will allow multithread down the road.
2017-03-27 14:01:47 +02:00
7ee41920fa Draw Manager: New debug timers
Both CPU time and GPU time are printed to spot bottlenecks.

GPU Timers works only if cache is enabled.
2017-03-27 14:01:47 +02:00
e54d8eeab2 Draw Manager: Make Viewport Data passed by the manager call. 2017-03-27 14:01:47 +02:00
Dalai Felinto
522ca18281 Keep base layer around for forward compatibility in 2.78 2017-03-27 12:53:16 +02:00
7979bc4c51 OpenGL: remove gpuMatrixBegin3D_legacy function
It helped during the transition, but we don't need this anymore. Evolution of T49450
2017-03-27 02:06:33 -04:00
ebdff8c3b8 OpenGL: simplify initial state
Client vertex array state is deprecated, and these are the default values anyway.

No need to bind any basic shader. Let drawing code decide which shader it wants to use.

Part of T49165 (general OpenGL upgrade)
2017-03-27 01:49:25 -04:00
8f620f2e85 cleanup unused GPU includes 2017-03-27 01:45:40 -04:00
271471bbe6 OpenGL: remove matrix manip from framebuffer setup
It doesn't really belong here... Any code using framebuffers will set up its own matrices.

Part of T49450
2017-03-27 01:43:12 -04:00
b95ee78ed3 OpenGL: prepare GLSL for version 3.3
- use in/out instead of attribute/varying
- use named output instead of gl_FragColor
- use texture() instead of the multitude of older texture sampling functions

The #if __VERSION__ == 120 paths (needed on Mac) will be removed after we switch to 3.3 core profile.

Part of T49165 (general OpenGL upgrade)
2017-03-27 01:16:18 -04:00
159f56f4ab add missing matrix uniforms to material shader
My bad again! Failed to test this part of 4c08c5b192
2017-03-27 00:28:52 -04:00
2e88237ee6 fix shadow map shader input
My bad! Messed up the conversion from ftransform -- 4c08c5b192
2017-03-26 23:39:17 -04:00
8b204831f2 OpenGL: use new matrix implementation in "Modern" viewport
This change looks small, but it switches the entire 3D viewport from legacy OpenGL functions to our own code.

Kept non-modern viewport on legacy path so we can compare easily (via the Modern Viewport checkbox).

Part of T49450
2017-03-26 21:23:55 -04:00
4c08c5b192 OpenGL: use new matrix names in GLSL
Builtin names staring with gl_ will not be available in core profile. Same with the ftransform function. New matrix API provides the same names minus the gl_ prefix.

Part of T49450
2017-03-26 21:23:55 -04:00
2a7e4c3040 OpenGL: fix & enhance new matrix lib
- init projection matrices with identity
- fix copy/paste mistake in GetProjectionMatrix3D
- add extra matrices needed by material GLSL

Working toward T49450
2017-03-26 21:23:54 -04:00
cc53c180ac GPU_shader automatically uses new matrix values
Whether used from Gawain or from traditional OpenGL draw methods.

TODO: make sure we bind matrices only once per shader change.

Part of T49450
2017-03-26 21:23:54 -04:00
a68cc0dc26 OpenGL: use old API for texture matrix
New matrix API does not support texture matrices. Not sure what the final code will look like, but this at least avoids interference with new ModelView matrix.

Marked each line with TEXTURE so they can be disregarded during searches.

Related to T49450
2017-03-26 21:23:54 -04:00
67ffad8cd2 OpenGL: remove several glMatrixMode calls
A few of these were redundant, others could be converted to new matrix API.
Part of T49450
2017-03-26 21:23:54 -04:00
59c5623372 Draw Manager: fix glitches when setting 3d cursor position by click. 2017-03-25 19:11:01 +01:00
0495e689e6 New Grid : Feature parity with old grid.
Removed infinite details and went for decreasing details with the distance instead (like the axis aligned ortho view auto sized grid).
Separate drawing of the Z axis into 2 pass (using shading group) to render ordered transparency with the main grid pass.
2017-03-25 19:11:01 +01:00
d2c94c7873 New Grid: Fix depth fighting and remove some unused variables. 2017-03-25 19:11:01 +01:00
8f4d58de4a Clay Engine: Cleanup
Remove unused code.
Fixed the amount of sample in the noise texture.
Add a small optimisation.
2017-03-25 19:11:01 +01:00
f730e386eb Merge branch 'master' into blender2.8 2017-03-25 13:49:13 +11:00
edd2c556cd Quiet warnings 2017-03-25 13:48:27 +11:00
0c93bc2b63 Merge branch 'master' into blender2.8 2017-03-25 13:39:47 +11:00
5d6e9f237b OpenGL: viewport background & depth buffer fixes
Untangling some of the logic in view3d_draw.
2017-03-23 16:28:20 -04:00
96e1b46791 OpenGL Immediate Mode: finalize image_draw
The directive `#if 0` was ignored.

Part of T49043
2017-03-23 14:56:42 -03:00
3de5e71501 GLSL viewport: Fix shader compilation error.
Moved the global lib insertion to the draw manager instead
2017-03-23 15:07:53 +01:00
f98d9baea9 Revert own previous commit, the bug is already fixed a fiew commits before. Sorry for the noise. 2017-03-23 16:36:28 +03:00
0b9041905f Fix (unreported) assertion in immBegin. Zerro number of points (Ctrl+LMouse without moving in node space) 2017-03-23 15:54:14 +03:00
09ad684249 cleanup use of GPU matrix API
Take advantage of 2D functions, rotation about the X Y or Z axis, uniform scale factors.

We no longer need to call gpuMatrixBegin_legacy() before using the new API locally in functions.

related to T49450
2017-03-23 01:46:14 -04:00
c2366009c0 OpenGL: paint_cursor port to immediate mode (Part 2)
Part of T49043
2017-03-23 01:33:34 -03:00
b69f0479a4 OpenGL: remove GLU option from build system
Also remove linking in glu libs.

T49042 is now done!
2017-03-22 21:33:53 -04:00
005b7bfbdc remove mention of GLU from comments
related to T49042
2017-03-22 21:33:53 -04:00
559bfd973e convert last remaining GLU calls in BGE
Focus is on getting rid of GLU. We expect UPBGE to replace current BGE.

Part of T49042
2017-03-22 21:33:53 -04:00
cd37248f90 OpenGL: paint_cursor port to immediate mode (Part 1)
Part of T49043
2017-03-22 19:43:06 -03:00
8abc315a23 Object Mode Engine: New grid drawing.
Move the grid drawing to the Object mode engine and implement a new infinite grid.
Everything is done but it needs better parameters to be intuitive.
2017-03-22 21:29:23 +01:00
26c140fbc8 Draw Module: Move the Global Ubo block definition to it's own file. 2017-03-22 21:29:23 +01:00
4646ecf749 OpenGL: use new API for persp & ortho projection
Still using legacy GL within the GPU library itself, but we'll be able to switch soon.

Part of T49450
2017-03-22 15:52:48 -04:00
98a0dd6888 OpenGL: load projection matrix with new API
New API does not share legacy OpenGL's concept of matrix modes.

Part of T49450
2017-03-22 14:48:47 -04:00
0c2fd1357d OpenGL: fix new projection matrix API
Now using the correct GL enum.
Part of T49450
2017-03-22 14:45:35 -04:00
Dalai Felinto
505cc694b3 Layer Unittesting: pep8 2/2
Mass replacing the common code of all tests

```
echo "Fixing $1"

ed "$1" <<'EOF'
1,/Testing/d
i

from render_layer_common import *
import unittest
import os
import sys

sys.path.append(os.path.dirname(__file__))

.
w
q
EOF
```

Using line-width of 120
2017-03-22 15:27:47 +01:00
Dalai Felinto
6883a983e6 Layer Unittesting: pep8 1/2
Manual corrections, using line-width of 120
2017-03-22 15:27:20 +01:00
4e92ed87ac Object Mode Outline: Changed algorithm a bit.
First pass find outline pixel.
Second pass expand it by 1px in each direction.
Subsequent passes fade the occluded outlines inward.
2017-03-22 02:17:16 +01:00
c2f3ec4378 OpenGL: convert one more matrix call
Missed this earlier.
Part of T49450
2017-03-21 19:38:00 -04:00
78878a132f fix blenderplayer build
GPU lib should not depend on editor (glutil) code.
2017-03-21 19:36:29 -04:00
0a274df536 OpenGL: add gpuLoadProjectionMatrix3D function
Make an existing 4x4 matrix the current projection.
Found a need for this while converting code to new API.
Part of T49450
2017-03-21 18:10:20 -04:00
6d2aca5a96 OpenGL: convert to new matrix API (part 5)
Pretty sure source/blender is now finished, with all legacy matrix calls confined to gpu_matrix.c.

This was the easy part, but doing it first makes the next part much easier. TODO and XXX notes describe what is left.

glMatrixMode is still in place, since the new API does not share this concept of modes. Similar for glOrtho and glFrustum which I'll tackle very soon.

Part of T49450
2017-03-21 17:49:21 -04:00
7aad5cf573 OpenGL: generic inputs for new matrix API
For functions that expect a 4x4 matrix, you can pass in that, or array[16], or float*, or... Casting at each call site can get annoying, and obscures the logic.

The C11 section still needs work, but the non-C11 macros help on the system I tested on (Mac/clang).

Part of T49450
2017-03-21 17:27:17 -04:00
20d02be6b8 OpenGL: remove fdrawline & other helper functions
Finally, fdrawline is no more!

Part of T49043 & T49450
2017-03-21 16:11:55 -04:00
3bd831d1d6 OpenGL: convert to new matrix API (part 4)
Part of T49450, fixes a Push/Pop mismatch from part yesterday's 3.
2017-03-21 16:11:55 -04:00
7870bde275 Object Outline: trying something new 2017-03-21 19:29:58 +01:00
80e6638ad3 Object Mode Engine: Support for active color. 2017-03-21 17:47:49 +01:00
d409c48310 OpenGL: convert to new matrix API (part 3)
Part of T49450
2017-03-21 02:51:02 -04:00
8fe9e94a52 OpenGL: remove 'circ' helper function
This was no longer being used.
Part of T49043
2017-03-21 02:27:58 -04:00
4a01ff278d fix use-before-init error + local cleanup
"path" was being used uninitialized. Thanks for the warning, clang!
2017-03-21 01:41:48 -04:00
bef63acbd6 remove gpuMatrixUpdate_legacy function
No longer needed since 231b5d96bb tracks dirty state of legacy matrix stacks.

Part of T49450
2017-03-21 01:36:51 -04:00
54bed786a6 OpenGL: convert to new matrix API (part 2 of x)
Part of T49450

For this batch I focused on usage of gpuMatrixUpdate_legacy.
2017-03-21 01:32:25 -04:00
231b5d96bb track dirty state of legacy matrix API
This is used to send latest matrix values to shader when drawing.

Previously handled by calling OpenGL matrix functions, followed by gpuMatrixUpdate_legacy. With this change that function is no longer needed.

Part of T49450
2017-03-21 00:25:47 -04:00
0c47923fca OpenGL: remove older matrix macros
Some of these were unused, the others are now handled by GPU_matrix.

Part of T49450
2017-03-21 00:11:17 -04:00
938613f720 OpenGL: convert to new matrix API (part 1 of x)
Part of T49450

For this batch I focused on usage of (now-obsolete) macros in BIF_gl.h
2017-03-21 00:09:40 -04:00
06f7fba6aa add missing gpuRotate2D function
Prototype was there, we just weren't using this yet.

Part of T49450
2017-03-21 00:08:09 -04:00
74434beb1c OpenGL: more legacy support for matrix routines
For the sake of forward progress on T49450

We can now replace legacy gl* matrix function calls with their gpu equivalents. "Inactive" in this code means we're using the legacy matrix stacks, not our own. Setting up the proper gpuMatrixBegin2D/3D/End calls can be done afterward.

Most or all of this will be removed after the transition to core profile.
2017-03-21 00:05:03 -04:00
060243a8ae Edit Mode Engine: Remove unecessary matrix. 2017-03-20 15:19:03 +01:00
9ca0e08236 Object Mode Engine: New outline method.
We render selected meshes into another buffer and use a screen space shader to expand the color out of the mesh silouhette.

Pros: only one additionnal render pass is needed (like old outline code), and we have occluded informations.
Cons: memory usage is a problem. This method needs 2 color buffer to ping pong when expanding the outline and 1 depth buffer to test occluded fragments. This gives a 88 bits/pix memory footprint.

Idea: Since we don't need all color range but only some uniform colors (theme colors) we could manipulate only the color ID instead of the whole color this could cut the color buffer size and lower the memory footprint to 58 bits/pix.
2017-03-20 15:19:03 +01:00
fc72a2ff4b Draw module: code style, encapsulate static vars 2017-03-20 15:19:03 +01:00
69a17bce1a Cleanup: remove useless glDisable(GL_LINE_STIPPLE) call.
Note that muted strips have solid border currently, marked as TODO to
add back stippled lines (if with want them back?).
2017-03-20 14:46:26 +01:00
21b361194f Merge branch 'master' into blender2.8 2017-03-20 14:37:44 +01:00
Dalai Felinto
a6d4ac28f5 Layers unittesting: update after doversion changes
Collections now are called "Collection 1", instead of "1"
2017-03-20 10:30:19 +01:00
Dalai Felinto
01c4e598e5 Silence unused vars warning 2017-03-20 09:50:25 +01:00
3f818c7898 Merge branch 'master' into blender2.8 2017-03-20 09:32:40 +11:00
4137f30928 Object Mode: Add stencil test to remove object outlines inside the silouhette.
It also adds nice occluded silouhette information for selected objects that are behind visible objects.
This methods is really heavy because it needs to render the wires twices.
2017-03-18 01:56:34 +01:00
cddde85f2c Fix shader compilation. 2017-03-18 01:56:34 +01:00
c4644b484d GPUTexture: Add support for depth_stencil textures. 2017-03-18 01:56:34 +01:00
b7355425cd Eevee: Initial commit
Basic support for lamps. Only diffuse.
2017-03-18 01:56:34 +01:00
8cad48df28 Draw Manager: Created a general fullscreen shader. 2017-03-18 01:56:34 +01:00
cf62424e47 Gawain: remove PER_THREAD macro
This attempt at TLS was leftover from an earlier prototype. It never worked with Blender's build system, and was defined to just exist, not to actually do anything.
2017-03-17 14:14:22 -04:00
Julian Eisel
2977a8cd21 Add tabs as standard button types
NOTE: This is really a backend-only implementation, nothing is changed in the UI

Adds a tab button-type and the basic drawing and handling code for it.
More work needs to be done on it, but idea is to get in ready for usage in the
topbar.

Differential Revision: https://developer.blender.org/D1371
2017-03-17 17:10:05 +01:00
Julian Eisel
a96008f3aa Merge branch 'master' into blender2.8
Conflicts:
	source/blender/editors/space_outliner/outliner_draw.c
2017-03-17 15:38:45 +01:00
Dalai Felinto
4b190e312f Remote unecessary call to ces_type->callback 2017-03-17 12:12:41 +01:00
722451e146 Merge branch 'master' into blender2.8
Conflicts:
	source/blender/blenloader/intern/writefile.c
2017-03-17 11:00:41 +01:00
a8c7152eea Cleanup: Use proper indentation 2017-03-17 10:26:30 +01:00
63fb57fbc6 fix blenderplayer build after moving Gawain to intern 2017-03-16 23:57:36 -04:00
c669bf126c Gawain: fix compiler warning
This function is only used when strict run-time checks are enabled.
2017-03-16 23:51:18 -04:00
4452bea2f1 move Gawain library to intern
Before now it lived in source/blender/gpu for convenience. Only a few files in the gpu module use Gawain directly.

Tested on Mac, time to push and test on Windows.

Todo: some CMake magic to make it easy to
#include "gawain/some_header.h"
from any C or H file. Main problem here is the many editors that include GPU_immediate.h which includes Gawain's immediate.h -- is there a way to avoid changing every editor's CMakeLists?
2017-03-16 23:32:35 -04:00
b4e8dc8c82 set required MacOS version to 10.9
We could do more to simplify build files, but this is a start.
2017-03-16 15:02:55 -04:00
Julian Eisel
7eecc2e1c4 Fix T50958: template_ID_preview is crashing the blender's UI from branch 2.8
So apparently ID pointer is allowed to be NULL here.
2017-03-16 18:54:11 +01:00
e2df9ab386 Merge branch 'master' into blender2.8 2017-03-16 17:28:04 +01:00
fc61cdf142 Merge branch 'master' into blender2.8 2017-03-16 15:42:49 +01:00
dd3ae7bad7 OpenGL immediate mode: image_draw.c: Draw Sample Line with new imm mode
part of T49043
2017-03-16 10:15:01 -03:00
dd7b60c638 Adds missing immUnbindProgram() in image_draw
This was interruping the execution of the code (To test: Just left click on the UV editing window to read the pixel)
2017-03-16 01:13:18 -03:00
0fc4cf7637 OpenGL: draw navmesh with new imm mode
This is an old stash. Part of DerivedMesh so the whole thing might be removed soon.

part of T49043
2017-03-16 00:05:05 -04:00
0895550d24 OpenGL: more new imm mode for image_draw
plus some minor cleanup

part of T49043
2017-03-15 16:53:45 -04:00
c5f97dfe59 Gawain: bypass strict error checking for release builds
Now that we're almost done with T49043, let's run immediate mode at full speed. Debug builds will still do strict checks.

Developers should still test their changes before committing! Recommended:
$ make debug (or make lite debug)
$ blender --debug-gpu
2017-03-15 16:53:45 -04:00
Julian Eisel
0d0d68d39d Outliner: Don't show master collection itself in "Master Collection Tree"
It would always be the only highest-level element in the tree, without
serving a real purpose. Even collapsing it wouldn't make much sense.
2017-03-15 21:48:18 +01:00
Julian Eisel
a449214854 Outliner: Rename "All Collections" display mode to "Master Collection Tree"
Also don't show alphabetical sorting option for "Active Render Layer" mode.
2017-03-15 20:50:35 +01:00
Julian Eisel
209d4d6993 Merge branch 'master' into blender2.8
Needed for compile fix.
2017-03-15 20:28:23 +01:00
Julian Eisel
7f596d39df Outliner: Change default display mode to "Active Layer"
We concluded this is going to be the display mode users will need to work
with the most, so makes sense to make it the default one.
Also, if the opened file only has one collection in the active render
layer, we expand it (almost empty list would be misleading).

What I had to do to make the expanding work is a bit ugly, but didn't
find a better way. During do_version we don't have access to the
TreeElement instances, and including ED_outliner.h to share code here
should be avoided too.
2017-03-15 20:14:26 +01:00
104a03beed Merge branch 'master' into blender2.8 2017-03-16 04:53:07 +11:00
fce0ff0a31 OpenGL: remove non-GLSL option from basic shader
This code path was only used when Blender was launched with --enable-legacy-basic-shader at the command line.

Part of general OpenGL upgrade (T49165)
2017-03-15 11:53:48 -04:00
Julian Eisel
8892c7869e Fix "search for unknown operator 'WM_OT_window_duplicate'" warning
Mistake in rB7bc76f8a3c1416.
2017-03-15 16:03:01 +01:00
19b3b11c64 Immediate Mode: Fix text color in iuage info line 2017-03-15 15:04:41 +01:00
e016a29ba0 Blender 2.8: Always prefer Occlusion Queries when using AUTO selection mode
GL_SELECT is really slow in this branch and will be removed.

For now we simply change AUTO behavior to avoid possible conflicts with merges
and upcoming color-id-based selection.
2017-03-15 14:55:46 +01:00
6b720dffc9 Merge branch 'master' into blender2.8 2017-03-15 14:19:53 +01:00
6d71169478 De-duplictae fix for lasso with Dalai
Git silently merged our both fixes together. Sure thing it's double safe this way, but cmon.
2017-03-15 14:18:37 +01:00
Dalai Felinto
d78b1147be Layers: handle doversion naming differently
Talked with Pablo Vazquez (venomgfx) and Julian Eisel (Severin), and we came up with this solution instead.

Basically, if the file has only one layer, it is converted to a collection named "Default Collection". Otherwise we name the collections: "Collection 1 [converted from 2.75]"
2017-03-15 14:12:52 +01:00
c10fbc002b Correct assert failure in debug mode with lasso select
Just do early output and don't bother with any GLSL program bind when
there is not enough points of lasso to draw.

This could have happened at the very beginning of the stroke.
2017-03-15 14:04:03 +01:00
Dalai Felinto
c16796089c Remove commented out code from transform_snap.c
Code was commented out in 2012 and it was not working even then. So it makes for an impossible conversion to the new gawain API.
2017-03-15 13:57:52 +01:00
Dalai Felinto
32d90220c2 Remove commented out code from reeb.c
Code was commented out in 2009
2017-03-15 13:57:52 +01:00
Dalai Felinto
f274332bb3 Remove commented out code from pbvh.c
Code was commented out in 2009
2017-03-15 13:57:52 +01:00
Dalai Felinto
6d8a25920d Remove commented out code from editarmature_sketch.c
Code was commented out in 2010
2017-03-15 13:57:52 +01:00
Dalai Felinto
9f366aee3b Immediate Mode: update drawnode.c commented out debug code
It works fine if you uncomment it, it shows a bigger circle around the re-route element, with a different color based on the selection state
2017-03-15 13:57:52 +01:00
Dalai Felinto
e00f52aeab Fix crash on node editor when using lasso to remove nodes connections 2017-03-15 13:57:52 +01:00
Dalai Felinto
279bcd8492 Remove unused code from drawnode.c
The code in question was marked as /* not used in 2.5x yet */.
2017-03-15 13:57:52 +01:00
Dalai Felinto
c72d319b47 Immediate Mode: remove commented out code from drawgpencil.c
Some of this was "tagged" for removal by Dec 2016.
2017-03-15 13:57:52 +01:00
d4b3068f36 Use FTOCHAR rather than CLAMP of uchar output
This makes no sense to clamp after value was assigned to uchar already.
Proper way to do so is to use FTOCHAR.
2017-03-15 13:50:41 +01:00
407f8eed7d OpenGL: Converted gpu_compositing.c to use batches. 2017-03-15 13:17:49 +01:00
79f94674fb Merge branch 'master' into blender2.8 2017-03-15 12:48:48 +01:00
1d5ba269c1 Merge branch 'master' into blender2.8 2017-03-15 06:04:52 +11:00
0f13f5a683 CMake: add missing headers 2017-03-14 18:47:26 +11:00
91837cd5b0 Cleanup: warnings 2017-03-14 18:40:23 +11:00
3ee0723b7d fix warnings from previous commit
Batch struct initializer needed more {{braces}}
2017-03-14 01:41:09 -04:00
225e3a6857 Gawain: multiple VertexBuffers per Batch
So we can store (for example) vertex positions in one buffer and normals + colors in another buffer. Not super exciting right now, but very useful once we start changing some attribute values.

Supports future work by Clément et al. Only tested with one VBO per Batch since that's all our current code uses.
2017-03-14 01:38:42 -04:00
9bf0b246ac OpenGL: remove deprecated calls
glMaterial
glColorMaterial
glPixelTransfer

and glEnable/Disable for
GL_FOG, GL_LIGHTING, GL_COLOR_MATERIAL

All of these were just setting default values, so I don't expect any visible change.

Part of T49165 (general OpenGL upgrade)
2017-03-14 00:44:38 -04:00
ac276e1541 fix "Modern Viewport" regression
GPU_viewport_bind & unbind should be called as pairs. A recent commit -- 3b91989a09 -- called unbind only for some code paths, overflowing OpenGL's matrix & attrib stacks.
2017-03-13 16:10:10 -04:00
b4157dedb0 OpenGL: remove packed imm mode functions from Python API
These are from the ARB_vertex_type_2_10_10_10_rev extension that became part of OpenGL 3.3.

So they are new, but only exist for compatibility with immediate mode, which is old.

Related to T49165 (general OpenGL upgrade)
2017-03-13 14:08:03 -04:00
0e40f1bac4 OpenGL: remove GLU functions from Python API
Part of T49042
2017-03-13 14:08:03 -04:00
Dalai Felinto
ddedcf7ada Outliner/layer: fix users trying to drop a collection into itself (recursion hell) 2017-03-13 17:38:37 +01:00
ecce1fabca Mode Engines: Fix MSVC compilation error. 2017-03-13 11:39:41 +01:00
Dalai Felinto
7bc76f8a3c New Window Operator (to replace Duplicate Window)
A user doesn't want to necessarily create a new Screen only because she
wants a new window.

This patch allows the user to pick the screen to use for the new Window.
If the screen picked is the active one, it duplicates it (as the old
behaviour in Blender).

Patch with contributions and fixes by Julian Eisel (Severin)

Subscribers: venomgfx

Differential Revision: https://developer.blender.org/D2555
2017-03-13 10:45:15 +01:00
4dacda58f9 Merge branch 'master' into blender2.8 2017-03-13 07:51:10 +11:00
6d3d2b15cb Clay Engine: Fix missing grid 2017-03-12 21:16:19 +01:00
9c6b9e889c Clay Engine: Mode engine templates.
Standard Engine layout easy to extend.

Note that most of the work will also happen in mesh_render.c to create geometry batches.
2017-03-12 21:16:03 +01:00
40532b9c3b OpenGL: Convert drawobject.c (cont)
All remaining 28 deprecated calls are derivedMesh related.
2017-03-11 21:09:15 +01:00
acd4fc3b7a OpenGL: Convert drawobject.c (cont)
Edit Particle mode.
2017-03-11 17:15:40 +01:00
e29e63c0ba OpenGL: Convert drawobject.c (cont)
Particle system (not edit mode)
2017-03-11 17:15:40 +01:00
b90a61917a OpenGL: Convert drawobject.c (cont)
This commit have a serrious perf issue when drawing nurbs (+5 times slower) but it gets rid of deprecated functions.
2017-03-11 17:15:40 +01:00
fbb1b311ea Merge branch 'master' into blender2.8 2017-03-12 03:00:06 +11:00
Julian Eisel
cdb7498f66 Cleanup: Add comment about use of ID pointer in TreeStoreElem 2017-03-10 23:29:32 +01:00
Julian Eisel
176698b2eb Fix unwanted expanding/collapsing of collections using drag & drop
Turned out to be a quite easy fix. I thought the issue was that we
couldn't identify the TreeStoreElem when (re)creating its TreeElement item
correctly, because for non-ID elements that would be index dependent (=
bad for drag & drop). Turns out that we're actually allowed to store
custom data within the TreeStoreElem, the thing is just that it gets
stored as ID pointer (highly ugly and highly misleading).
Anyway, seems to work now so I won't complain too much :)
2017-03-10 23:18:19 +01:00
Julian Eisel
736a32e7bf Ouliner drag&drop: Correct/increase margin for triggering insert into 2017-03-10 21:06:10 +01:00
Julian Eisel
fcd3bf5275 Insert into master collection when dragging above it 2017-03-10 21:01:10 +01:00
Julian Eisel
0d7dfd9f46 Outliner: Support dragging objects into different collections
Doing so will remove the object from the old collection and insert it
into the new one.
2017-03-10 20:48:39 +01:00
Julian Eisel
0210df079c Outliner drag&drop: Do generic check if no custom poll callback is defined
And quite some cleanup.
2017-03-10 18:24:14 +01:00
Dalai Felinto
e9dd97405e Layers util function to move objects around
This is required for outliner, so we can move an object from a collection into another
2017-03-10 18:13:19 +01:00
Julian Eisel
6730202510 Improve outliner drag&drop feedback by using drop poll callbacks
This way we can ensure the overlay to indicate where the item would be
placed if it was dropped now is always at the correct place and doesn't
mislead the user.
2017-03-10 17:17:13 +01:00
Dalai Felinto
1100ddeaa9 Layers: fix bug in move layer collection above/below
Reported by Julian Eisel (Severin)
2017-03-10 16:48:09 +01:00
Julian Eisel
13f5bed32e Gaah, managed to undo a previous fix somehow...
Somehow undid rBc70eb873057 in rB8e303aae255.
2017-03-10 16:03:50 +01:00
Julian Eisel
989632417b Draw drag&drop feedback overlays with element indentation
That way users can see better at which hierarchy level the element will
be inserted into.
2017-03-10 15:58:08 +01:00
Julian Eisel
08cde7c785 Fix incorrect positioning of collection when dropping it after expanded one 2017-03-10 15:56:41 +01:00
Julian Eisel
8e303aae25 Support drag & drop of collections across multiple hierarchy levels
Two issues are remaining, they'll be fixed separately:
* Graphical feedback when dragging within the master collection is wrong
* There's some bug where collections swap places instead, Dalai will investigate
2017-03-10 15:24:53 +01:00
b3bb4a6936 Fix lamp draw setting color without checking if its needed 2017-03-11 00:48:56 +11:00
Julian Eisel
c70eb87305 Fix issues in outliner collection reordering function 2017-03-10 13:59:03 +01:00
6a8cb92404 OpenGL: Convert drawobject.c (cont)
- drawDispListwire_ex()
- removed primitive check in Batch_init()
2017-03-10 01:53:57 +01:00
e37538b472 OpenGL: Convert drawobject.c (cont)
removed draw_box
2017-03-10 00:28:00 +01:00
85fa1403f4 OpenGL: Convert drawobject.c (cont)
-Softbody matrix
-EditCurve/NURBS
2017-03-09 22:10:48 +01:00
6ce1d71914 OpenGL: Convert drawobject.c (cont)
Remove drawcircball
Convert texturespace, editfont, metaball (except for displist usage)
2017-03-09 22:10:48 +01:00
55a56a31a0 Merge branch 'master' into blender2.8
Manually merged viewport xray changes
2017-03-10 06:58:29 +11:00
711ac90481 Merge branch 'master' into blender2.8 2017-03-10 06:11:50 +11:00
Dalai Felinto
4c746bb3b0 Immediate Mode: Updated commented out code from textview.c 2017-03-09 19:21:08 +01:00
Dalai Felinto
aca29bcc65 Immediate Mode: Fix text color for Info and Console editors
Bug introduced in rB4b365064cfbd
2017-03-09 19:20:31 +01:00
Dalai Felinto
01b2071c14 Immediate Mode: Fix crash on text editor when going over suggestion list 2017-03-09 18:12:38 +01:00
Dalai Felinto
51737a2c8c Immediate Mode: text_draw.c 2/2
Tackle the remaining parts of the code, mainly the commented out
function `draw_documentation`.
2017-03-09 18:02:25 +01:00
Dalai Felinto
fc53c6f953 Immediate Mode: text_draw.c 1/2
Note 1: renamed draw_cursor to draw_text_decoration, since it was drawing
cursor, margin, selection and line highlight

Note 2: commented out code update coming next

Part of T49043
2017-03-09 18:01:56 +01:00
Dalai Felinto
8a6d055f37 Merge remote-tracking branch 'origin/master' into blender2.8 2017-03-09 17:10:06 +01:00
Dalai Felinto
528cb8877f Building 2.8 again after warning cleanup (696ed6d3ca) 2017-03-09 12:08:44 +01:00
b40a4f66b2 Merge branch 'master' into blender2.8 2017-03-09 16:47:31 +11:00
696ed6d3ca Cleanup: warnings 2017-03-09 16:44:11 +11:00
a68c631cf8 Merge branch 'master' into blender2.8 2017-03-09 16:41:33 +11:00
8d98362710 OpenGL immediate mode: graph_draw.c
This also fixes a little bug, which caused `draw_fcurve_samples` to
never be called, and thus sampled curve range boundaries were not drawn.

Part of T49043
2017-03-09 01:00:59 -03:00
2a62ec8003 OpenGL: drawobject.c (cont) 2017-03-09 03:21:42 +01:00
49ef1a25b8 Edit Mesh overlay: Ported Display Normals option 2017-03-09 01:30:26 +01:00
4b31f1e591 Edit Mesh overlay: remove sizeNormal from ubo. 2017-03-09 01:30:26 +01:00
3b91989a09 Draw Manager: structural change
All engines are now called by the draw manager. Engines are separate entities that cannot interfer with each others.
Also separated draw_mode_pass.c into the mode engines.
2017-03-09 01:30:26 +01:00
Dalai Felinto
d9f42e5fab Layers: move LayerCollection
This is to be used from the Outliner, when dragging and dropping
collections from the Active Render Layer

It also includes a cleanup on the outliner so it calls the new
functions. Note: the outliner still needs fix to allow all the
functionality here exposed.

But this will be tackled by Julian Eisel later.
2017-03-08 23:35:54 +01:00
Dalai Felinto
3a1748146b Layers: move SceneCollection
This is to be used from the Outliner, when dragging and dropping.
It does not include moving LayerCollection (from Active Render Layer)
2017-03-08 23:35:54 +01:00
Dalai Felinto
9b2877ad88 New util function: BLI_listbases_swaplinks 2017-03-08 23:35:54 +01:00
a42a0b5ef3 OpenGl: Converted more of drawobject.c 2017-03-08 15:03:03 +01:00
Dalai Felinto
04a391c2f8 Outliner fix: prevent segfault when there is no active layer collection 2017-03-08 11:27:11 +01:00
1345d29806 OpenGL: convert editarmarture_sketch to new imm mode
Part of T49043, T49042

Reviewers: fclem, merwin

Tags: #bf_blender_2.8

Differential Revision: https://developer.blender.org/D2548
2017-03-07 22:14:27 -05:00
696bb47c6e OpenGL: Converted bit more of drawobject.c. 2017-03-07 18:10:55 +01:00
76ae10f580 OpenGL immediate mode: finish outliner_draw.c
Part of T49043
2017-03-07 01:44:04 -03:00
78d9a0a563 OpenGL immediate mode: finish file_draw.c
Part of T49043
2017-03-07 01:44:04 -03:00
def4ffd1c5 OpenGL immediate mode: finish node_draw.c
Part of T49043
2017-03-07 01:44:04 -03:00
583373f049 OpenGL: Object bound drawing. 2017-03-06 20:57:16 +01:00
517db46b34 OpenGL: A little bit of drawobject() 2017-03-06 20:57:16 +01:00
aa44b77129 Fix T50841: Scene object iterator did not get data from LinkData for the master collection
Debug session with Dalai Felinto.
2017-03-06 17:56:19 +01:00
Julian Eisel
a5cba9aab9 Merge branch 'master' into blender2.8
Conflicts:
	source/blender/editors/space_nla/nla_draw.c
	source/blender/editors/space_view3d/view3d_draw.c
2017-03-06 13:00:46 +01:00
dc9a7f861f Edit Mode overlay: Optimisation
Don't generate more verts than we need if we don't render vertex.
Getting a big boost from 12fps to 20fps on my test scene
2017-03-06 04:07:54 +01:00
d4e7288af9 Edit Mode overlay: Update cache on selection 2017-03-06 03:58:08 +01:00
33c093ef70 Clay Engine: Fix shader linking issue 2017-03-05 20:29:21 +01:00
b36f93fa37 Clay Engine: support draw callbacks 2017-03-05 18:10:08 +01:00
ff96f527fd Edit Mode overlay: fix clear color, and possibly a crash. 2017-03-05 18:10:08 +01:00
747ac66800 Clay Engine: More Lamp drawing work 2017-03-05 18:10:08 +01:00
45b42d3fb7 Clay Engine: Make panels compatible with the new engine 2017-03-05 18:10:08 +01:00
608b96c49b Clay Engine: camera drawing 2017-03-05 18:10:08 +01:00
76c9f1a649 OpenGL: remove fdrawcheckerboard
This helper function was marked DEPRECATED since it uses old OpenGL calls.

Switched last 2 uses to imm_draw_checker_box, which does the same thing, only awesome.

Part of T49043
2017-03-04 01:49:07 -05:00
a514fea932 OpenGL: remove old DrawPixels util functions
a little bit of T49043, mostly related to T49165

Thx to @fclem for marking these as unused & making shader-based replacements.
2017-03-03 18:18:21 -05:00
87d5f670a0 OpenGL: remove glaDrawBorderCorners
This helper function was marked DEPRECATED since it uses old OpenGL calls.

Part of T49043
2017-03-03 17:55:41 -05:00
0215b3e957 OpenGL: draw image render info with new imm mode (part 1)
Part of T49043

This was the last use of glaDrawBorderCorners.

Plenty more to do in this file, I'll keep working on it...
2017-03-03 17:53:53 -05:00
af1635eeb0 OpenGL: remove stipple pattern defines
GPU_basic_shader handles this internally; no other code depends on it.
2017-03-03 17:36:17 -05:00
29683d623c OpenGL: remove glutil_draw_*_arc (lined, filled)
These helper functions were marked DEPRECATED since they use old OpenGL calls. Now they are marked GONE!

Part of T49043
2017-03-03 17:23:35 -05:00
053589da7d OpenGL: paint_draw_cursor with new imm mode
Part of T49043.

This was the last use of glutil_draw_lined_arc.

Plenty more to do in this file, I'll keep working on it...
2017-03-03 17:21:34 -05:00
3fdffc1e95 Gawain: fix for MSVC 2013
<stddef.h> defines offsetof. For some reason MSVC 2015 does not need this. Mystery!
2017-03-03 14:50:35 -05:00
3381cf98cb OpenGL: remove fdrawbox, sdrawbox, sdrawline
These helper functions were marked DEPRECATED since they use old OpenGL calls. Now they are marked GONE!

Part of T49043
2017-03-03 13:26:43 -05:00
6999e82693 OpenGL: remove last uses of fdrawbox
Part of T49043
2017-03-03 13:22:16 -05:00
b3a4b61a3b OpenGL: remove last uses of sdrawline & sdrawbox
Part of T49043
2017-03-03 13:12:49 -05:00
0c5b197447 Edit Mesh overlay: remove one extra buffer. 2017-03-03 13:51:59 +01:00
Julian Eisel
2a82162618 Merge branch 'master' into blender2.8
Conflicts:
	source/blender/editors/armature/pose_select.c
	source/blender/editors/include/ED_armature.h
2017-03-03 12:55:35 +01:00
Dalai Felinto
22df0b2fe2 Fix blenderplayer building (tm) 2017-03-03 10:09:42 +01:00
8cf524cec9 plug ShaderInterface into GPUShader
Renamed existing getter/setter that only FX shaders use. We could convert FX code to use the richer new interface or leave it as is.

Removed unused GPUShader fields. ShaderInterface tracks the same information.
2017-03-02 21:46:54 -05:00
c2baf3e486 OpenGL: draw PBVH bounding box with new imm mode
It wasn't using old immediate mode, but was using
- client vertex arrays (obsolete)
- quads (obsolete)
- state attrib stack (obsolete)
- polygon mode (still allowed, but gross)
2017-03-02 21:40:13 -05:00
e0a2bd43dd Gawain: add ShaderInterface for GLSL introspection
After a GLSL program is linked we can get all its inputs & never have to ask it again.

Several uniforms are considered "built-in". Nothing special about these to OpenGL itself, they just follow conventions of our built-in shaders.

This will help the matrix API, immediate & batch drawing APIs, and allow extra error/compatibility checking.
2017-03-02 21:28:28 -05:00
85945849a9 Edit Mode overlay: backwire "ghost wireframe" with variable intensity 2017-03-03 02:53:16 +01:00
bb8a172dfb Draw Manager: Changed buffer uniform api.
Use a reference to where will the texture be instead of an index.
2017-03-03 02:53:16 +01:00
0c1c646118 clean up clay vertex shader
Clay engine only works on modern GL, so this shader doesn't need compatibility with legacy Mac GL.
2017-03-02 18:11:21 -05:00
33758c7cb8 Gawain: move PRIM types to new file, classify by geometry
PrimitiveClass will help match shaders to draw calls & detect usage errors. For example a point sprite shader only makes sense with PRIM_POINTS.

Updated other files to include new primitive.h
2017-03-02 15:07:14 -05:00
Julian Eisel
a99495d291 Merge branch 'master' into blender2.8
Conflicts:
	source/blender/blenkernel/intern/scene.c
2017-03-02 19:15:32 +01:00
Dalai Felinto
5ce6388f7c Outliner: add hooks for (yet to be implemented) layer reordering routines 2017-03-02 18:12:30 +01:00
Julian Eisel
0322700d87 Get UI ready for using drag & drop to nest a collection into another one
Nothing happen yet when it's supposed to insert the collection into
another one, that part will be handled by @dfelinto.

See gif for demo of how it works UI wise: {F500337}

Also fixed off-by-one error in utility function.
2017-03-02 17:15:30 +01:00
Dalai Felinto
146a88dd60 Remove all instance of OBACT from particle_edit.c and related changes 2017-03-02 17:14:59 +01:00
Dalai Felinto
209021a703 Remove all instances of OBACT from drawobject.c and related changes 2017-03-02 17:09:24 +01:00
Dalai Felinto
083bc48816 Remove OBACT from rigidbody_constraint.c and remove uneeded sanity check 2017-03-02 17:09:24 +01:00
Dalai Felinto
aa845eed1e Remove tons of OBACT
There are now only referenced in:
* drawobject.c
* particle_edit.c
* space_image.c (a single case to be handled on workspace branch)
* rigidbody_constraint.c (to be handled in the following commit)
2017-03-02 17:09:24 +01:00
561d11c5e6 Edit Mesh overlay: pack normals with face centers.
Needed for face normals.
2017-03-02 15:03:40 +01:00
0b6fa1a0fb Mesh batch cache: fix memory leak 2017-03-02 14:20:36 +01:00
Dalai Felinto
7b1de2b407 Revert "Depsgraph: Add placeholder function to handle objects update"
This reverts commit 9023abbf27.
2017-03-02 13:05:17 +01:00
Dalai Felinto
4bf9a65da9 Fix mesh edit wasn't updating for new objects
The problem was that we were updating the mesh cache on
BKE_object_eval_shading, not on mesh change.
2017-03-02 12:58:30 +01:00
Dalai Felinto
007fcfc193 Fixup for layer rename unittest (rB3baa186724) 2017-03-02 09:52:33 +01:00
Dalai Felinto
a65af5d0cf Layers unittest: isolate the depsgraph crash in individual tests
(and re-order the tests alphabetically)
2017-03-02 09:40:17 +01:00
869f2940c2 Gawain: allow use of final 2 bits of 10_10_10_2 format
Requested by @fclem
2017-03-02 03:16:02 -05:00
b463cd2ab8 Edit Mode overlay: Moved Shaders to draw modules and resolved some draw issue.
We don't want to clutter gpu_shader.c with engine specific code
Added face's center dot
Simplified loose vert shader
2017-03-02 01:08:32 +01:00
aa102283da Edit Mode overlay: Added theme color via UBO. 2017-03-02 01:08:32 +01:00
043c90fdcd Edit Mode overlay: fast navigate 2017-03-02 01:08:32 +01:00
26fc6c71c4 Edit Mode overlays: separate multiple shaders for loose edges and verts 2017-03-02 01:08:32 +01:00
Julian Eisel
3baa186724 Add tests for layer renaming
Could have an own file for each test, but this is good enough.
With great help from @dfelinto, thanks!
2017-03-01 20:14:20 +01:00
Julian Eisel
0f7a664731 Fix collection renaming not checking for unique name in entire hierarchy
Only checked for unique name in direct children of the master
collection.

Also added missing listener for outliner.
2017-03-01 20:13:40 +01:00
Julian Eisel
18684e546f Outliner: Make sure collection name is unique after renaming 2017-03-01 16:34:16 +01:00
Julian Eisel
b00b9dadd8 Outliner: Support dragging object into collection
Doing this will add the object to the collection.
2017-03-01 15:35:21 +01:00
c1f43c9dc6 Cleanup: warnings 2017-03-02 00:36:33 +11:00
8901263b5f Merge branch 'master' into blender2.8 2017-03-02 00:22:13 +11:00
f64df0e102 Fix error moving keyframes in graph editor after refactor base 2017-03-01 13:08:15 +01:00
3626521346 Base Refactor Tasks: Fix some legacy bases for dopesheet 2017-03-01 11:41:23 +01:00
e142793815 Base Refactor Tasks: Change selection flags 2017-03-01 11:31:10 +01:00
14627cc2ee Base Refactor Tasks for gpencil filter 2017-03-01 11:21:06 +01:00
Dalai Felinto
6ee70312bb Dopesheet: fix crash when dragging keyframes 2017-03-01 10:43:04 +01:00
Julian Eisel
0b0347dcca Cleanup: Rename outliner enum 2017-03-01 11:28:17 +01:00
Julian Eisel
512fb74980 Outliner: Make deleting collections from "All Collections" mode work 2017-02-28 22:18:11 +01:00
Julian Eisel
fcbae6c3b3 Outliner: Highlight active layer collection in "All Collections" mode 2017-02-28 21:58:07 +01:00
Julian Eisel
f35907444e Cleanup: Add outliner_utils.c, move functions into it 2017-02-28 21:37:15 +01:00
3176bb8346 clean up GL / GPU #includes 2017-02-28 15:30:39 -05:00
2a8dd3c5ff remove GPU_basic_shader calls from wm_gesture
Gestures are drawn with specific built-in shaders now.
2017-02-28 15:30:39 -05:00
7b1e5e8620 remove unused code from interface_icons
No longer depends on basic shader API
2017-02-28 15:30:39 -05:00
2fcdb6df10 remove unused code from uvedit_draw
Keep USE_EDBM_LOOPTRIS code paths, remove not-USE_EDBM_LOOPTRIS paths.

Discussed with @LucaRood in IRC since he worked on this file recently.
2017-02-28 15:30:39 -05:00
Julian Eisel
c0e055fa7e Outliner: Delete all selected collections, not just active one
There were some issues with how we store outliner tree elements:
Apparently the only removable elements have been data-blocks so far.
When recreating the TreeElements, their TreeStoreElem instances were
mainly identified by their ID pointer. However non-data-blocks mostly
depend on an index. For collections, such an index isn't a reliable
measure though if we want to allow removing items. Depending on it for
identifying the TreeStoreElem instance would cause some quite noticeable
glitches (wrong highlights, two elements sharing highlight, etc).

For now I've solved that by actually removing the TreeStoreElem that
represents the removed element. A little limitation of this is that
after undoing the removal, some information might get lost, like
flags to store selection, or opened/closed state.
A better solution that would also fix this issue would be having a real
unique identifier for each non-data-block element, like an idname or even
its data-pointer. Not sure if we can get those to work reliable with
file read/write though, would have to investigate...

Also added a general Outliner tree traversal utility.
2017-02-28 21:15:51 +01:00
5e889ebf19 OpenGL: no more display lists
Part of the OpenGL core profile upgrade (T49165)

Use the Batch drawing API (GPU_batch.h) when you want do draw something multiple times.
2017-02-28 13:15:11 -05:00
54ed1b7324 Fix Dopesheet and Curve editor to use new bases in SceneLayer instead of old base.
(see D2538)

Thanks to dfelinto for his support.
2017-02-28 17:16:46 +01:00
7175838b61 Draw Manager: Fix ortho grid in front of overlays. 2017-02-28 15:15:34 +01:00
96d63d2232 Edit Mesh overlays: fix half cut vertices.
Artifacts still remained when 2 vertices were linedup in orthographic mode or with very acute vertex angles.

This commit fix that by adding even more geometry.
2017-02-28 15:00:16 +01:00
677f066634 Edit Mesh overlays: added looses edges and verts as triangle.
We loose a bit of memory for (more?) performance.
2017-02-28 14:31:16 +01:00
Julian Eisel
6af21b4e7f Highlight active collection in outliner 2017-02-28 14:11:15 +01:00
2de9bf1138 skip OpenGL debug logic on Apple
ifdef out most debugging code since Apple does not implement any debug extensions. We can revisit this if they ever do (don't expect that).

Changed output message so Mac users don't think --debug-gpu is broken.
2017-02-28 04:38:30 -05:00
811e90c957 OpenGL: enable use of AMD_debug_output
This extension is the best we have on some older supported GPU + OS combinations.

All the code was in place, just disabled.
2017-02-28 04:05:53 -05:00
08e654935c OpenGL: remove GPU_state_print function
I was removing deprecated/obsolete state from this function. About halfway through I started questioning the need for the whole thing.

GPU_state_print is not called anywhere, but is (was) available as a development aid.

External GL debugging tools are really good these days! We should use those to examine state & not roll our own.
2017-02-28 03:19:53 -05:00
6a3dd21edd OpenGL: remove obsolete GL_POINT_SMOOTH
Was only used in one place, to show the 3D mouse rotation center.
2017-02-28 03:09:44 -05:00
8a76049e84 rename built-in point shaders, SMOOTH --> AA
Updated shader names and code that uses them.

All of these shaders produce round points that are anti-aliased and blended against the background.

These were initially named SMOOTH because they replace glEnable(GL_POINT_SMOOTH). But SMOOTH in shader-land refers to vertex attribute interpolation (like glShadeModel(GL_SMOOTH)).

Using SMOOTH to mean two things is confusing, so we now use AA to mean "the point is anti-aliased".
2017-02-28 02:18:52 -05:00
e7d57628c9 OpenGL: keyframe shape fixes
- Size parameter is total size of the shape, not its radius (half size). Updated hard-coded sizes to match this.
- Shader expands size to include outline.
- Fixed fringe between outline color and transparent background.
2017-02-28 01:21:27 -05:00
Julian Eisel
5138fe3c0a Outliner: "All Collections" mode showing the master collection hierarchy
Reordering is disabled for now. Link, unlink and override operators
are only available while in "Active Layer" mode, not in "All
Collections".
2017-02-27 22:24:59 +01:00
Julian Eisel
c24b4e0cd0 Outliner: Rename "Collections" display mode to "Active Render Layer" 2017-02-27 21:15:49 +01:00
6ab9af0083 Merge branch 'master' into blender2.8 2017-02-27 16:08:25 -03:00
Dalai Felinto
bf243752fc Immediate Mode: Lattice drawing
Part of T49043
2017-02-27 18:31:03 +01:00
Dalai Felinto
b5dd04b7e7 Immediate Mode: force fields
Part of T49043
2017-02-27 17:57:07 +01:00
416bd1bbe8 Clay Engine: Edit Mesh overlay fix jaggy edges.
We do a strip of triangles around the triangle of interest and modify the variying vars to "trick" the fragment shader into rendering what we need.
This keeps the compatibility for both shaders.
Vertex still get half displayed when angle at the vertex is very acute.

This patch is only for the simple, no vert clipped case.

This is 2.5x slower than without the trick (on my hardware with 1million tris).
2017-02-27 17:41:35 +01:00
Dalai Felinto
35290f5d4e Bring back border selection 2017-02-27 12:16:27 +01:00
Dalai Felinto
edba025c92 Prevent crash when copying object
ob->collection_settings is to be handled by depsgraph, but we may as well make sure things do not crash meanwhile
2017-02-27 11:18:11 +01:00
Julian Eisel
aff8ce438a Outliner: Don't use alphabetical sorting for collections
Order of collections matters, so sorting the outliner entries to be
alphabetical is misleading.
2017-02-26 22:34:58 +01:00
16b2005bfb Clay Engine: fix shader :/ 2017-02-26 21:33:29 +01:00
6dabcdf69e Clay Engine: Replace if() by assert() 2017-02-26 21:12:56 +01:00
712530eb93 Clay Engine: Edit mesh overlays
Based on the previous overlay shader from merwin.
This shader takes care of clipped vertex cases and do all edit mode face info in one pass (except face centers).
As the shading is done one the triangle itself the visual can't go beyond the surface of the mesh. That leads to half displayed edges on the outline of the mesh.
This problem can be fixed by a second pass.

This is work in progress.
2017-02-26 21:12:56 +01:00
Julian Eisel
fabde06b37 Fix outliner "Sort Alphabetically" having not working 2017-02-26 19:24:01 +01:00
Julian Eisel
20a105d54c Fix errors in new immediate mode for interface_widgets.c
Text editing cursor, text editing selection highlights and pie menu
direction indicator weren't visible.

Caused by rB4f2375b82f72.
2017-02-26 16:53:04 +01:00
2724fad582 OpenGL: replace gluProject and gluUnProject, and simplify surrounding code.
Part of T49042.
2017-02-26 00:16:46 +01:00
e9011100f7 Fix compiler warnings on macOS / clang / c++11. 2017-02-26 00:16:21 +01:00
3cf2821f2f Merge branch 'master' into blender2.8 2017-02-26 00:15:59 +01:00
bda0456933 OpenGL: wm_gesture uses new imm mode
D2376 by @ianwill, part of T49043
review by @merwin

Box select, circle select, etc. Introducing the dashed-line shader! See D2376 for more info.
2017-02-24 15:33:32 -05:00
1f453a8909 OpenColorIO: Update glsl implementation to be ready for ogl 3.3 core 2017-02-24 12:38:50 +01:00
1e7475a5d7 Opengl glaDrawPixels removal: More descriptive setup. 2017-02-24 12:38:50 +01:00
Dalai Felinto
0584c82ad7 Fix break in drawscredge_area_draw when in fullscreen 2017-02-24 11:05:52 +01:00
Dalai Felinto
2f9a0dfe64 Fix T50714: Collections: Adding object to scene without an existing collection
This was causing blender to segfault.

We now add create a new collection and link to the layer before adding
the new object

(also included unittests, and requires updated lib/tests)
2017-02-24 10:10:24 +01:00
Dalai Felinto
8261a84ffb Unittest: split object_add in individual test files
(and small cleanup in unittest)

This is required to the upcoming unittest + bugfix
2017-02-24 10:10:24 +01:00
Dalai Felinto
4c8d8da2e7 Silence warnings in draw_armature.c
Also add note about incomplete functions there
2017-02-24 10:10:24 +01:00
9dd86e2758 OpenGl immediate mode: drawnode.c
Part of T49043
2017-02-24 01:09:51 -03:00
4c6190d08f Add immDrawBorderCorners function
This replaces `glaDrawBorderCorners`.
2017-02-24 01:09:50 -03:00
c2453007f4 Opengl glaDrawPixels removal: #if 0 glDrawPixels... 2017-02-24 01:26:45 +01:00
7b744f9e1a Opengl glaDrawPixels removal: mask_draw.c 2017-02-24 01:26:45 +01:00
ab8958bbd5 Opengl glaDrawPixels removal: image_draw.c
Using float buffer is still laggy because of the data volume we have to transfer to the GC.
2017-02-24 01:26:45 +01:00
2ea5446197 Opengl glaDrawPixels removal: interface 2017-02-24 01:26:45 +01:00
ccec97ea0a Opengl glaDrawPixels removal: editors/spaces 2017-02-24 01:26:45 +01:00
c9e8584e7f Opengl glaDrawPixels removal: windowmanager 2017-02-24 01:26:45 +01:00
6628446bdf Opengl glaDrawPixels removal: editors/render 2017-02-24 01:26:45 +01:00
44ea6fb857 OpenGL: Make glaDrawImBuf_glsl functions compatible with new immDrawPixels
And change relevant function calls.
2017-02-24 01:26:45 +01:00
45711c3fde OpenGL immediate mode: new shader image shuffle color
new shader to draw an image with one isolated channel
2017-02-24 01:26:44 +01:00
071fdfbfb3 OpenGL immediate mode: fix asserts in clip dopesheet 2017-02-24 01:26:44 +01:00
e437841239 OpenGL immediate mode: modifying immDrawPixelsTex
This way OCIO can be used with it.
2017-02-24 01:26:44 +01:00
3d8f4fedd0 Clay Engine: fix format (3D instead of 2D) 2017-02-24 01:26:44 +01:00
e5799d1389 OpenGL immediate mode: gpu_framebuffer.c
I had to make some changes to the sep_gaussian_blur shader to be compliant for gl 3.3 leap
2017-02-24 01:26:44 +01:00
34c07c0d6d Fix Py API doc generation - missing new context members definition. 2017-02-23 22:27:49 +01:00
dec323659d Merge branch 'master' into blender2.8 2017-02-23 22:09:09 +01:00
2e83814e18 OpenGl immediate mode: clip_draw.c and clip_graph_draw.c fixes
Fixed little typo in clip_draw.c and special case assert in
clip_graph_draw.c (track segments with single point).

Part of T49043
2017-02-23 16:12:08 -03:00
ef60979029 Rework of BKE's mesh_render to support BMesh directly.
Note that since there is no (efficient) ways to get arrays of
MVert/MEdge/etc. out of a BMesh, I refactored quite heavily internals of
BKE_mesh_render.

Now, when you do need acess to mesh data to generate cached batches, you
create an abstract struct from mesh (either Mesh or BMesh if available),
and then use advanced helpers to extract needed data, on a per-item
basis (no more handling of arrays of verts/edges/... in batches code).

This allows to:
* Avoid having to create arrays of BMesh elements.
* Take advantage of existing advanced BMesh topology and connectivity data.

Reviewers: dfelinto, fclem, merwin

Differential Revision: https://developer.blender.org/D2521
2017-02-23 11:54:40 +01:00
d751676cf3 Fix building full. 2017-02-23 11:03:56 +01:00
b46b2834b9 Merge branch 'master' into blender2.8 2017-02-23 10:56:28 +01:00
Dalai Felinto
53a9dec2bf Silence "defined but not used" warnings 2017-02-23 10:24:59 +01:00
3b3ed19c18 OpenGl immediate mode: remove imm_draw_line
Replaced all calls to `imm_draw_line` by plain `immVertex2f` calls, and
removed `imm_draw_line`, as that function was not supposed to exist in
the first place, and causes unnecessary calls to `immBegin`/`immEnd`.

Part of T49043
2017-02-23 03:21:58 -03:00
30420845b9 OpenGl immediate mode: fix screen_draw.c
* Fix several wrong coordinates, causing things to be drawn in the wrong places.
* Remove unexpected return.
* Slight peformance improvement, by reducing number of shader binds.
* Minor code style stuff.

Part of T49043
2017-02-23 00:27:35 -03:00
Julian Eisel
a8d6e41bbc Fix issues when reordering nested collections
Item was inserted at the head of the top-level collection list, instead
of parent-level one.
2017-02-23 00:09:43 +01:00
Julian Eisel
9c106ff211 Cleanup: Style 2017-02-22 18:54:56 +01:00
efc499cb99 OpenGL immediate mode: paint_stroke.c 2017-02-22 18:20:16 +01:00
Julian Eisel
f1d59073cc Disallow renaming master collection from Outliner
Shows warning when trying to do so.
2017-02-22 17:50:10 +01:00
Julian Eisel
910b7dec8d UI: Support drag & drop reordering of collections
This adds initial support for reordering collections from the Outliner
using drag & drop.
Although drag & drop support is limited to collections for now, this
lays most foundations for general drag & drop reordering support in the
Outliner. There are some design questions to be answered though:
* Would reordering of other data types (like objects) be a purely visual change or would it affect the order in which they are stored? (Would that make a difference for the user?)
* Should/can we allow mixing of different data types? (e.g. mixing render layers with objects)
* How could we realize this technically?

Notes:
* "Sort Alphabetically" has to be disabled to use this ("View" menu).
* Reordering only works with collections on the same hierarchy level.
* Added some visual feedback that should work quite well, it's by far not a final design though: {F493806}
* Modified collection orders are stored in .blends.
* Reordering can be undone.
* Did minor cleanups here and there.
2017-02-22 17:25:00 +01:00
e003499f6f OpenGl immediate mode: uvedit_smart_stich.c
This is a quick fix. A better fix should be to store the batches inside the StitchPreviewer struct.
2017-02-22 17:22:28 +01:00
3952349a81 OpenGl immediate mode: fix false positive (again) 2017-02-22 14:27:04 +01:00
48752d8802 OpenGL: Fix Object Axes color 2017-02-22 14:24:09 +01:00
d4f0e10cc4 OpenGl immediate mode: Fix false positive 2017-02-22 14:23:20 +01:00
eff5924c75 OpenGl immediate mode: screen_draw.c 2017-02-22 14:05:56 +01:00
cd0d335183 Clay Engine: Started Armature drawing
This should give the overall direction to whom wants to finish it.

- Renamed EDIT mode engine to EDIT_MESH mode engine
- Introduce EDIT_ARMATURE mode engine
- Started to port legacy drawarmature.c to draw_armature.c
2017-02-22 13:00:15 +01:00
48aeb0b640 Clay Engine: Renaming shader. 2017-02-22 12:50:03 +01:00
6dbc6dfc14 Clay Engine: Prepare for Armature drawing.
- Added runtime display matrices to EditBone and bPoseChannel
- Added Object space instance vertex shader and modified the simple lighting shader accordingly
2017-02-22 12:46:27 +01:00
e05d3d5d9b Clay Engine: Fix Memory Leak. 2017-02-22 12:19:10 +01:00
4f2375b82f OpenGL immediate mode: interface_widgets.c
Added rgba_float_args_set_ch to BLI_math_color.h
2017-02-20 21:21:47 +01:00
5c39aad283 OpenGL immediate mode: interface_panel.c 2017-02-20 21:21:47 +01:00
86d8dc12c1 Use Git submodule tracking feature
This way we can point submodules to different branches.

There are two side-effects to this:

- Git 1.8.2 becomes the minimal required version now
  to support this feature.

- Not sure how doing local changes in submodules followed
  by `make update` will behave. We don't use explicit rebase
  now.

  Perhaps this is not so bad, since it was already quite
  dangerous thing to do.
2017-02-20 10:16:58 +01:00
22119f976e Point addons to 2.8 branch 2017-02-20 10:14:25 +01:00
446625c561 Clay Engine: Use G.debug_value to test cache performance
Use debug 666 for cache without instance buffer caching.
Use debug 667 for cache with instance buffer caching.
2017-02-19 14:31:02 +01:00
c8b7e7973a OpenGL immediate mode: transform_manipulator.c 2017-02-19 14:00:21 +01:00
9f839a2ff5 OpenGL: fix MVP matrix order
Numbers were correct but names were mixed up.
2017-02-18 19:53:55 -05:00
fae895125e fix OpenGL line count in VSE backdrop 2017-02-18 15:39:21 -05:00
Dalai Felinto
ab6993811f Fixup for last commit :/ 2017-02-17 22:29:53 +01:00
Dalai Felinto
b30044d4af Fix crash introduced in engine separation (50fb3ea3)
Basically DEG_OBJECT_ITER (or rather,
BKE_scene_layer_engine_settings_update) wasn't creating
Object->collection_settings data for invisible objects.

Now I'm removing those objects from the loop entirely. If we are to
bring them back we need to either create CollectionEngineSettings dat
from them or to skip them in DRW_mode_cache_populate.
2017-02-17 22:26:40 +01:00
39e212eb05 OpenGL: further mask_draw tweaks
- smooth round points
- fewer state changes
- minor cleanup & warning fix

This is a follow-up to rB84141f27a668
2017-02-17 15:42:11 -05:00
b41c5c81c6 Fix bplayer (c) 2017-02-17 20:07:13 +01:00
a54e461b84 Fix building without Clay engine. 2017-02-17 20:06:31 +01:00
322b1d3187 Merge branch 'master' into blender2.8
Conflicts:
	source/blender/editors/animation/anim_draw.c
2017-02-17 20:03:55 +01:00
Dalai Felinto
cb36dbe606 bug in DEG_OBJECT_ITER 2017-02-17 19:37:11 +01:00
Dalai Felinto
7868c0aa8b Layers: Fix unittest after 65a75e11 2017-02-17 18:27:32 +01:00
Dalai Felinto
df56721931 Layer/Outliner: add a few operators that I need for the video demo 2017-02-17 17:54:05 +01:00
Dalai Felinto
65a75e112c Layer: change default name of doversion layer (Viewport now) 2017-02-17 17:54:05 +01:00
Dalai Felinto
1ed20a692f Follow up on mode engine code separation
The settings initialization belong within the engines
2017-02-17 17:54:04 +01:00
50fb3ea3de Clay Engine: Separate mode drawing to different files/engines. 2017-02-17 17:30:15 +01:00
Dalai Felinto
9cb44cbba1 Layers: Fix visibility evalution + Unittesting
test_evaluation_visibility_a failed before, but it is now fixed
test_evaluation_visibility_b passed before and was used as control to make sure it was not broken
2017-02-17 14:08:31 +01:00
Dalai Felinto
7884406f33 Layers: ob.visible_get()
Similar to ob.select_get(), but for BASE_VISIBLED.
2017-02-17 12:57:14 +01:00
Dalai Felinto
5a14578116 Layers: Fix crash on opening files saved in clay
Basically we were not tagging the layers and bases as dirty. As usual this will likely change once Depsgraph kicks in. But this will do for now.
2017-02-17 11:02:25 +01:00
84141f27a6 OpenGL: mask_draw uses new imm mode
Based on D2371 from @ryry. Mostly T49043, a little T49042.
Deleted some unused drawing code instead of updating it.
I have a few more things in mind for this file... tomorrow!
2017-02-17 03:23:46 -05:00
23e51f4734 OpenGL immediate mode: sequencer_draw.c (finished)
Converted the remaining diagonal stripes thingies...

Part of T49043
2017-02-17 00:07:16 -02:00
ff53949145 Add diagonal stripe shader (GPU_SHADER_2D_DIAG_STRIPES)
Reviewed By: merwin

Differential Revision: https://developer.blender.org/D2512
2017-02-17 00:07:16 -02:00
077988dd44 blender2.8: New immediate mode for sculpt_uv.c
[Note: this patch functionality was implemented in parallel, independently at bf83f097ad
That said, the original patch was also removing an unnecessary include,
so here it is]

Replaced the one call to `glutil_draw_lined_arc`.
This seems to be the only draw call in this file.

Reviewers: merwin

Tags: #bf_blender_2.8

Maniphest Tasks: T49043

Differential Revision: https://developer.blender.org/D2497
2017-02-16 22:05:27 +01:00
cbc5388a4a Minor cleanup in sequencer_draw.c
Minor style cleanup, and also replaced manual checker drawing by a call
to `imm_draw_checker_box`.

Part of T49043
2017-02-16 18:48:37 -02:00
34d3ae9d5b OpenGL immediate mode: clip_draw.c
Part of T49043
2017-02-16 18:48:37 -02:00
b5cae50376 Add imm_draw_checker_box function
This replaces `fdrawcheckerboard` in drawing a standard gray
checkerboard for alpha backgrounds.
2017-02-16 18:48:19 -02:00
Dalai Felinto
e3dd2b1591 Doversion: merge collection engine properties
This is a more complex approach, which makes me really want to use
IDProperty instead (assuming we handle their merging nicely).

In fact I would expect this to happen in readfile.c, not during
doversion, but I can revert this later.

For now this allow for demo files saved with 2.8 to keep working even
after we add/remove engine settings properties.

The values are merged. There is no purge though, so
old CollectionEngineSettings and CollectionEngineProperty will live
forever (for the time being).
2017-02-16 20:02:35 +01:00
Dalai Felinto
6d58f1e87d Doversion: reset layer collection properties when needed
This prevents crashes when a file was saved with 2.8, but a new
engine settings property was created.

In those cases any previous collection settings are wiped out. We can do
an elegant merge soon.
2017-02-16 20:02:35 +01:00
Dalai Felinto
9f4004261e Layer: add name to mode engines 2017-02-16 20:02:35 +01:00
db2a05999a Clay Engine: Fix Cursor too bold 2017-02-16 16:22:44 +01:00
b512c2a794 Clay Engine: Correct Mesh Normals 2017-02-16 16:22:44 +01:00
268670cdee Clay Engine: Fix Axis Name shader 2017-02-16 16:22:44 +01:00
Dalai Felinto
d8df7ce6a4 Outliner collection operators: linking! 2017-02-16 16:02:44 +01:00
Dalai Felinto
011c8c730f Outliner collection operators, all but collection link
Note: It may be missing a notifier to prevent Outliner from crashing
when deleting collections.
2017-02-16 14:39:56 +01:00
3d63b9a88f Clay Engine: Hidden wire 2017-02-16 14:00:55 +01:00
eeeb1aa658 Clay Engine: Wire and Backface cull collection settings. 2017-02-16 14:00:55 +01:00
f5ab4bc339 Clay Engine: Fix grid not showing. 2017-02-16 14:00:55 +01:00
dbe23c5456 OpenGL immediate mode: sequencer_draw.c
Other than the general conversion:
* Made some slight aesthetic improvements.
** Removed gradients.
** Replaced stipples with transparency for hidden strips.
** Made strip borders less harsh.
** Removed stripes from offsets and made them brighter.
* Made only the visible parts of waveforms be drawn.
* Fixed a few drawing bugs.
** Background was not being drawn when buffer is NULL, and no
grease pencil is being drawn.
** Offset drawing ignored strip visibility.

Also, note that diagonal stripes for locked and error strips, are still
being drawn with the old api, as they await a new shader in order to
be converted.

Part of 49043
2017-02-15 17:10:19 -02:00
10d2ee6287 Remove redundant draw call (sequencer)
`SEQUENCER_OT_slip` was calling `draw_sequence_extensions` to redraw the
extensions during modal operation, but that is redundant, as it is
already called by the regular draw loop. Because it was called on top of
the draw loop, it was actually obscuring other parts of the strip that
would normally be drawn on top of it.

Somewhat part of 49043
2017-02-15 17:10:19 -02:00
Dalai Felinto
45bebbf5ad Remove "Object List" panel from collection context tab 2017-02-15 19:29:09 +01:00
Dalai Felinto
5a10c64e8c Layers: Show collection objects in Outliner 2017-02-15 19:29:09 +01:00
Dalai Felinto
a428daada0 Layers: Separate between scene render layer (F12) and context render layer (everything else)
For now they are the same. However with workspaces they will be
different, and should be treated differently.
2017-02-15 19:29:09 +01:00
883ef2c9ce Clay Engine: New collection settings (not working yet) 2017-02-15 18:54:31 +01:00
69b96e27ee Collections Settings: Added Bool type. 2017-02-15 18:18:43 +01:00
Dalai Felinto
574d6011f4 Revert "Collection Editor based on patch by Julian Eisel"
This reverts commit 3da834e83c.

We will use the outliner for this now.

I'm also moving the collections_ops.c to outliner_collections.c
2017-02-15 18:17:34 +01:00
Dalai Felinto
a47235f5fd Add note to RNA about layer/engine macros 2017-02-15 18:12:05 +01:00
Dalai Felinto
bf83f097ad Immediate Mode: sculpt_uv.c 2017-02-15 15:52:28 +01:00
Dalai Felinto
226ba44775 Fix sculpt brush draw crash on Blender2.8
Temporary solution by Sergey Sharybin, it needs further investigation.
This should not be necessary, specially since this works fine in master.
2017-02-15 15:52:28 +01:00
f9e4d8e93a Clay Engine: Replace Manual depth test by depth copy.
This avoid glitches due to float comparison precision.
2017-02-15 15:16:06 +01:00
Dalai Felinto
bdd3fd64e9 Bring rendering back (update all references to SETLOPPER) 2017-02-15 14:40:56 +01:00
Dalai Felinto
c694aedcad Update SETLOOPER to account for layers
The idea is to iterator over the active layer of the current scene and
then over the active layer of the set scenes.

In the future, once we get workspace we will get the initial renderlayer
from context, while the background sets will still use their active
renderlayer.
2017-02-15 14:40:56 +01:00
310593def1 Clay Engine: Support vertex normals (smooth shading), no face normals yet. 2017-02-15 13:32:35 +01:00
b0c125bcd3 Clay Engine: draw Speaker 2017-02-15 12:28:26 +01:00
cd472bc7de Clay Engine: Fix Grid depth write. 2017-02-15 12:28:26 +01:00
021f8d56d0 OpenGL immediate mode: Fix assert when using camera.show_sensor 2017-02-15 12:28:26 +01:00
9f03718a5b Clay Engine: drawaxis names drawn with shaders & instance 2017-02-15 12:28:26 +01:00
ee2a718763 Clay Engine: Fix empty drawing 2017-02-15 12:28:26 +01:00
e813ebab71 Clay Engine: new draw_view.c containing all dynamic drawing routines. 2017-02-15 12:28:26 +01:00
0f7dee19ed Viewport: Ported info drawing to from legacy code. 2017-02-15 12:28:26 +01:00
1f139beee3 Clay Engine: Added immUniform functions...
for vec3 arrays and matrix4.
2017-02-15 12:28:26 +01:00
Dalai Felinto
e30bc6f517 Layer Unittest: use macro for tests 2017-02-15 12:12:59 +01:00
Dalai Felinto
7e3d2a8baa Sorted BaseLegacy > Base convertions
Including bring back UV Edit show other objects
2017-02-14 18:21:47 +01:00
Dalai Felinto
a76d45cf72 Layer DNA_scene_types _NEW defines, protect macro parameters 2017-02-14 18:21:47 +01:00
Dalai Felinto
1ff3d5bc9a Layer Macros: create the instance as part of the macro
Instead of pre-initializing an instance prior to the macro, we do it as part of the macro itself now.
2017-02-14 18:21:46 +01:00
Dalai Felinto
b9762fed93 Layers: Unittesting - make them granular
Some tests may break Blender, which makes the entire unittest routine to fail.
They are now I isolate the tests into individual files

Kudos to Sybren Stüvel and Sergey Sharybin for the advice.

Note: at the moment test_link.py is failing (since a41bbfb7)
2017-02-14 18:21:46 +01:00
Dalai Felinto
6906a884ee Immediate Mode: make triangles smooth again
Instead of bothering with matrix transformations, I am simply adding the jitter to the vertices.

Related to: rB31a21135cf72c8623be7f5aee2bfdac983ceae2e
2017-02-14 14:35:18 +01:00
Dalai Felinto
c80b760d4a Immediate Mode: particle_edit.c 2017-02-14 14:27:31 +01:00
Dalai Felinto
31a21135cf Immediate Mode: area.c and UI_draw_icon_tri, ui_draw_anti_tria
Note: This makes the jittering to not work :/

@merwin, would you know how to use gpuMatrixBegin2D for this case? I
think it must be the reason behind the lack of jittering. But I couldn't
get it to work (the 2D shader is asking for a 3D Matrix).

Part of T49043
2017-02-14 13:02:58 +01:00
Dalai Felinto
9151f12dad Immediate Mode: animation markers 2017-02-14 11:10:51 +01:00
1089294439 OpenGL immediate mode: Remove unecessary light shader 2017-02-14 00:49:16 +01:00
7fc632a856 OpenGL immediate mode: drawarmature.c (end)
No deprecated call left.
2017-02-14 00:35:25 +01:00
22df54acb6 OpenGL immediate mode: drawarmature.c (cont)
All (except for stick and wire) are now rendered using batch or immediate API.
Using simple front facing lighting for now, waiting for gpu_basic_shader.c to be recoded.
2017-02-14 00:35:25 +01:00
0790976b6c OpenGL immediate mode: fix inverted normal in sphere batch 2017-02-14 00:35:25 +01:00
8c09fa3be2 OpenGL immediate mode: added gpuRotate3f to GPU_matrix 2017-02-14 00:35:25 +01:00
9c35907ca2 OpenGL immediate mode: Replacement for gluCylinder 2017-02-14 00:35:25 +01:00
Dalai Felinto
1634cef2b3 Immediate Mode: timeline cached frames
This involved some refactoring. The original code was relying on a cache of pre-allocated arrays which in turn were still re-populated every redraw loop.

We now ditch those arrays, and make the draw "on the fly".

Part of T49043

@merwin can you just check if you foresee any performance impact with this approach?
2017-02-13 18:10:28 +01:00
Dalai Felinto
d4e9c27e4e Immediate Mode: curve draw stroke
How to test this drawing: create and edit a curve and press shift + drag your mouse (or tablet). The Curve needs a Bevel Depth > 0.0.

Note: The ideal solution would be to use a different shader, that takes
no lighting. However according to Clément Foucault there is an assert preventing the same batch to
me used with different attributes (or something like that). Il wait
until the end of such resolution before revisiting this. That said, it
is working fine.

Part of T49043

Differential Revision: https://developer.blender.org/D2501
2017-02-13 12:41:05 +01:00
Dalai Felinto
4e64151787 Outliner: allow for renaming of collection and small touch ups in the
code

Note: Master Collection should not be renamable, but also, it should be marked as MasterCollection (with an icon probably)
2017-02-13 11:16:23 +01:00
Dalai Felinto
8a92277a31 Layers: Per-Collection edit mode parsing
Note: we are now merging all the collection engines (mode and render), which eventually may get slow. But as stated before, this is to expose the functionality, while waiting for proper depsgraph integrated solution.
2017-02-13 00:25:30 +01:00
Dalai Felinto
adf355849f Layers: Per-Collection edit mode settings
I didn't manage to get the proper object context in the collection
properties editor. That said I got it working for now in a temporary way
since this will change once we get workspaces anyways

(see changes in buttons_context.c and
rna_scene.c::rna_LayerCollection_mode_settings_get)

I still need to handle the merging of the settings. I will find a
provisory solution while we wait for depsgraph.

(also layer_collection_create_mode_settings_object and layer_collection_create_mode_settings_edit could probably be elsewhere - under draw/engines likely)
2017-02-12 20:47:34 +01:00
b104057d00 OpenGL: enable program point size for keyframes
Allows vertex shader to determine how large to rasterize each point sprite. Forgot to do this before.
2017-02-12 01:56:08 -05:00
09bfc37889 OpenGL: convert NLA editor to new imm mode
Plus plenty of C99 cleanup.

Part of T49043. Needs more testing, I don't really use the NLA editor.
2017-02-12 01:30:21 -05:00
24703c97a1 GPU shaders / Clay engine : small renaming / cleanup 2017-02-11 21:15:46 +01:00
737d349dbc Clay Engine: fix instancing (again) 2017-02-11 20:36:20 +01:00
e05800d23b Clay Engine: converted Empties to the new instancing method 2017-02-11 20:36:20 +01:00
1abd2f279d Clay Engine: Small instancing fixes 2017-02-11 20:36:20 +01:00
eb473143a8 Clay Engine: Convert Lamp to use new instancing feature. 2017-02-11 20:36:20 +01:00
1976fd7af1 Clay Engine: Fix instance attrib. 2017-02-11 20:36:20 +01:00
08c1afb088 Clay Engine: Separate batch for Z straight line 2017-02-11 20:36:20 +01:00
fc0797142d Clay Engine: Refactoring of the dynamic batches
Support more attribs for interesting instancing
2017-02-11 20:36:20 +01:00
c5f2380be7 OpenGL immediate mode: drawarmature.c (cont)
Cube bone wire.
Fix do_const_color.
This breaks the selection in glSelect mode. Occlusion queries are fine.
2017-02-11 14:19:23 +01:00
e008ca13f1 OpenGL: updated clip_utils.c to new immediate mode
D2391 by @darwin, part of T49043

Reviewed by @merwin who made some small changes before committing.
2017-02-11 00:59:43 -05:00
768e4e991c fix warning
Strip start & end are floating-point values, so clang expected fabsf here. Casting to int since we want a discrete number of vertices.
2017-02-11 00:27:43 -05:00
bbc31e8929 OpenGL: draw keyframe markers as point sprites
Also some conversion to new imm mode (T49043).

Multiple editors affected.
We could push this even further & draw all keyframes in an editor with a single draw call.

Something is strange with keyframe markers in blender2.8 -- they're not showing up before or after this commit. They do appear in master. This commit probably needs some follow-up work after keyframes are showing again. Better to share this code now instead of sitting on it.
2017-02-11 00:24:59 -05:00
a161d45cfb add builtin GPU_SHADER_KEYFRAME_DIAMOND
Now we can draw keyframe markers as point sprites, with fewer draw calls and state changes.

Based on the builtin shader for round points with anti-aliased outline. This one is more pointy.
2017-02-11 00:02:28 -05:00
f7b1b87ba9 Gawain: minor cleanup 2017-02-10 22:27:20 -05:00
1c09c8f32f OpenGL immediate mode: drawarmature.c
Changed the color function to output a float[4] to use with shaders.
Temporary leaving the UI_ThemeColor/glColor function.
Porting draw_bone_octahedral (wire) to Batch API.
2017-02-11 00:43:03 +01:00
b97864203e Gawain : Added Batch_init()
to init a batch without allocating memory
2017-02-11 00:43:03 +01:00
af2df36248 OpenGL immediate mode: interface_draw.c (cont)
ui_draw_but_TRACKPREVIEW

Changed stipple shader usage to a bunch of GL_LINES with flat color

OpenGL immediate mode: interface_draw.c (end)

Eradicate leftover legacy functions.
Fix a crash with histogram resolution.
2017-02-11 00:43:00 +01:00
7252049cba OpenGL immediate mode: Added replacement for glaDrawPixelsTex_* 2017-02-11 00:42:59 +01:00
13ab43afcf OpenGL immediate mode: interface_draw.c (cont)
ui_draw_but_CURVE
2017-02-11 00:42:59 +01:00
ae3646cd9f cleanup from recent commits
coding style, float literals

Converted some (expr / literal) to (expr * literal) where it does not impact readability.

Simplified a few function calls.
2017-02-11 00:42:55 +01:00
ef600e8ccf OpenGL immediate mode: clip_graph_draw.c
Part of T49043 and T49042
2017-02-11 00:39:18 +01:00
dfadb45254 OpenGL immediate mode: gluSphere replacement
Updated interface_draw.c to use the new sphere batch.
2017-02-11 00:39:17 +01:00
5b10a6bb8e OpenGL immediate mode: fix Waveform Font color 2017-02-11 00:39:17 +01:00
b4a01e7f4f OpenGL immediate mode: interface_draw.c (cont)
ui_draw_but_COLORBAND
Introduced a new checker shader to be used mostly on transparent areas.

OpenGL immediate mode: interface_draw.c (cont)

ui_draw_but_UNITVEC
Introduced a new shader to be used for simple lighting.
2017-02-11 00:39:09 +01:00
8fbf1c4d77 OpenGL immediate mode: Convert leftover UI_ThemeColor calls
Some `UI_ThemeColor` calls were left in converted files, in some cases
because they were just overlooked, and in the case of text drawing,
because the new BLF color functions were not yet implemented at the
time of conversion.

Also converted one `drawcircball` call that was left in
transform_constraints.c

Part of T49043
2017-02-11 00:36:06 +01:00
3f9f82f3c4 fix clang warning
uninitialized variable (glGen functions set the value)
2017-02-11 00:18:36 +01:00
8add4cc900 OpenGL immediate mode: uvedit_draw.c
Still has one `UI_ThemeColor` call, because drawing is happening in a DM
drawing callback which hasn't been converted yet.

Also has some old gl calls that are #ifdef'ed out.

This also changes active face drawing in UVs from stippled to a solid
color, which makes active faces much more visible, and also looks nicer.
The same should probably be done for active face drawing in the 3d view.
(has been discussed with merwin on IRC)

Part of T49043
2017-02-11 00:18:36 +01:00
Dalai Felinto
0b27b65f24 Use OBACT_NEW to show the object edit mode 2017-02-10 20:46:16 +01:00
f9329997c3 Complete immUniform functions to support 2float and 3float 2017-02-10 17:29:12 +01:00
26f8095384 Alembic: fixed mistake in bounding box computation
By performing the Z-up to Y-up conversion, the change in sign of the
Z-coordinate swaps "minimum" and "maximum".
2017-02-10 11:52:51 +01:00
ae6e9401ab Alembic: using Base* instead of Object* to get selection
I also added some remarks & TODOs to indicate work in progress.
2017-02-10 11:52:33 +01:00
48a6aa3499 Alembic: don't use parent_selected() to determine which object to export
The parent_selected() function mixed semantics of "needs to be exported"
and "is selected", which is confusing. Now just selected objects are
exported to Alembic; any parent transforms that are required were already
taken care of by other code.
2017-02-10 11:52:33 +01:00
Julian Eisel
0c0bdd83a4 Cleanup: Use const for array argument 2017-02-10 00:20:46 +01:00
Julian Eisel
4b365064cf Remove most (maybe all?) remaining yellow text
Decided to request the text color as argument for UI_fonstyle_draw
functions, rather than keeping it being another state to keep track of.
2017-02-10 00:17:50 +01:00
Julian Eisel
0ce76a4274 Fix missing highlights in 3D View
Things like selection outlines didn't work at all.

Caused by rBc973e8d2da5cf3f.
When splitting up bitflags, the equivalent to `foo->flag & (bar1 + bar2)` is
`(foo->flag1 & bar1) || (foo->flag2 & bar2)`, *not*
`(foo->flag1 & bar1) && (foo->flag2 & bar2)`.
Also, let's please avoid using '+' operator for bitwise operations, a
binary addition is a binary OR *with* cary, which can cause quite some damage.
2017-02-09 21:26:38 +01:00
Julian Eisel
ca9c1de33e Fix object selection in 3D View 2017-02-09 20:49:53 +01:00
Julian Eisel
9e3cf0c2e8 Draw buttons for editing collections in outliner 2017-02-09 20:39:58 +01:00
Julian Eisel
c80f9822fd Support activating collections from outliner 2017-02-09 20:31:40 +01:00
Dalai Felinto
d82bb1f634 Main fix for outliner, but still need changes
Fix outliner related crashes. Basically in some functions bContext was
not passed around, so CTX_data_scene_layer(C) was crashing.

Right now we still rely on ob->flag SELECT in some places. In order to use the base flag we will need to bring back the Bases to the outliner.
2017-02-09 17:52:53 +01:00
Julian Eisel
1bcf199d2e Support displaying collections in outliner
Adds a new outliner display mode "Collections" which draws the active
collection. We might want to rename it to "Active Collection" if we don't
plan to support showing other collections there.
Also added the buttons for restricting visibility and selectability.

@dfelinto, code in restrictbutton_collection_hide_cb and
restrictbutton_collection_hide_select_cb is duplicated from
rna_LayerCollection_hide_update and
rna_LayerCollection_hide_select_update, maybe utility functions would be
handy for this?
2017-02-09 17:25:21 +01:00
Dalai Felinto
a41bbfb7f3 Depsgraph fix for scene layers
Objects can be moved around freely now
2017-02-09 16:46:05 +01:00
Dalai Felinto
1045026ea2 More housecleaning (BASACT > BASACT_NEW) 2017-02-09 16:34:26 +01:00
Dalai Felinto
cb490561d3 Layers: set active object in doversion for all render layers 2017-02-09 15:57:06 +01:00
Dalai Felinto
5bee553b1f Update get_camera_with_movieclip 2017-02-09 15:51:30 +01:00
Dalai Felinto
ff4dc7abfa Change ITER_BEGIN to work in C++ (include object type in the macro) 2017-02-09 15:26:28 +01:00
Dalai Felinto
0b473168cd Fix widget not showing up
(and more Scene.base > SceneLayer.object_bases changes in transforma code)
2017-02-09 14:49:56 +01:00
Dalai Felinto
8ff7f14c76 Temporary fix for object panel 2017-02-09 14:30:35 +01:00
Dalai Felinto
f20cc9e54c Fix logic in CollectionEngineSetting update
Now Clay engine can show different materials per collection o/
2017-02-09 12:48:39 +01:00
08399aca62 Clay Engine : fix 2017-02-09 12:04:37 +01:00
Dalai Felinto
0692fc9665 CollectionEngineSettings calculate: set COLLECTION_PROP_USE for combined property
This way the render engines can have a fallback value (scene or layer default value) for the shader values that were never set.
2017-02-09 11:48:09 +01:00
6b372e3a22 Clay Engine: support for overrides (not working yet) 2017-02-09 11:25:51 +01:00
Dalai Felinto
09af91e096 Fix crashes on outliner (fixup for rB2a16a4ee)
FOREACH_SCENE_OBJECT was wrong (skipping an object), but rB2a16a4ee made it crash. Things should be better now.
2017-02-09 11:22:56 +01:00
Dalai Felinto
9e95b5edd9 Fix active object name not showing in viewport 2017-02-09 10:28:50 +01:00
Cyrax
f2ea319316 OpenGL: outliner_draw_tree_element uses new imm mode
D2438 by @cyrax
review by @merwin
part of T49043
2017-02-08 18:36:03 -05:00
Cyrax
6444ba2635 added UI_GetThemeColorShade4ubv function
And updated UI_ThemeColorShade to use it.

Part of D2438 by @cyrax
2017-02-08 18:34:02 -05:00
Cyrax
b08483defa Update outliner_draw_hierarchy_lines to use new imm mode
Patch D2437 by @cyrax
review by @merwin
2017-02-08 15:02:55 -05:00
Cyrax
525937cc39 OpenGL: outliner_draw_highlights uses new imm mode
Patch D2433 by @cyrax, part of T49043
reviewed by @merwin
2017-02-08 14:37:37 -05:00
61df9fdb2f Cleanup: warnings 2017-02-09 02:39:31 +11:00
2a16a4ee43 Fix uninitialized var with FOREACH_SCENE_OBJECT 2017-02-09 02:25:27 +11:00
Dalai Felinto
3f7ca93490 Fix breakage when saving files from the UI
The problem was with offscreen buffer rendering
2017-02-08 16:06:11 +01:00
Dalai Felinto
260f97b3d9 create BKE_scene_layer_active 2017-02-08 16:05:24 +01:00
Dalai Felinto
a38298f4dd Bring back Lasso and Circle selection back
(and replace more instances of BaseLegacy/scene->base with Base/sl->object_bases)

Still need mouse selection, box selection, and menu selection

Also, there is still a problem with BA_WAS_SEL, at the moment only the
objects centers are highlighted.
2017-02-08 14:44:37 +01:00
d4913af846 Merge branch 'master' into blender2.8
# Conflicts:
#	source/blender/blenloader/intern/writefile.c
2017-02-08 13:10:16 +01:00
Dalai Felinto
c973e8d2da Partial "fix" for objects not being selected
To bring this fix a step further we need to address all the BA_WAS_SEL instances, and make sure they follow the new design.

This commit allow you to see the object selected (its center anyways) when you do select all.

Note: in the clay engine selection (a) was already working fine.
2017-02-07 19:11:17 +01:00
Dalai Felinto
6432c8cc00 Layers: get/update CollectionEngineSettings (depsgraph placeholder)
Every time:
  * A collection settings is set
  * A collection visibility changes
  * An object is added/removed/ ...

We need to recalculate the "accumulated" CollectionEngineSettings that
the render engine should use for an object.

This is to be handled by the depsgraph. Meanwhile this code should allow
us to start using those settings in the render engines.

Note: We are storing this in the objects, which means we can only have
one active calculated option every time.

This is intended to get the conversation with the Depsgraph department
going.
2017-02-07 16:54:09 +01:00
6bf9c8ac89 Fix broken COLLADA building. 2017-02-07 12:05:23 +01:00
83adc54438 Clay-Engine (merge clay-engine)
Initial work by Clément Foucault with contributions from Dalai Felinto
(mainly per-collection engine settings logic, and depsgraph iterator placeholder).

This makes Blender require OpenGL 3.3. Which means Intel graphic card
and OSX will break. Disable CLAY_ENGINE in CMake in those cases.

This is a prototype render engine intended to help the design of real
render engines. This is mainly an engine with enphasis in matcap and
ambient occlusion.

Implemented Features
--------------------

* Clay Render Engine, following the new API, to be used as reference for
future engines

* A more complete Matcap customization with more options

* Per-Collection render engine settings

* New Ground Truth AO - not enabled

Missing Features
----------------

* Finish object edit mode
  - Fix shaders to use new matrix
  - Fix artifacts when edge does off screen
  - Fix depth issue
  - Selection sillhouette
  - Mesh wires
  - Use mesh normals (for higher quality matcap)
  - Non-Mesh objects drawing
  - Widget drawing
  - Performance issues

* Finish mesh edit mode
  - Derived-Mesh-less edit mode API (mesh_rende.c)

* General edit mode
  - Per-collection edit mode settings

* General engines
  - Per-collection engine settings
    (they are their, but they still need to be flushed by depsgraph, and
    used by the drawing code)
2017-02-07 11:31:22 +01:00
Dalai Felinto
aeb8e81f27 Render Layers and Collections (merge from render-layers)
Design Documents
----------------

* https://wiki.blender.org/index.php/Dev:2.8/Source/Layers

* https://wiki.blender.org/index.php/Dev:2.8/Source/DataDesignRevised

User Commit Log
---------------

* New Layer and Collection system to replace render layers and viewport layers.

* A layer is a set of collections of objects (and their drawing options) required for specific tasks.

* A collection is a set of objects, equivalent of the old layers in Blender. A collection can be shared across multiple layers.

* All Scenes have a master collection that all other collections are children of.

* New collection "context" tab (in Properties Editor)

* New temporary viewport "collections" panel to control per-collection
visibility

Missing User Features
---------------------

* Collection "Filter"
  Option to add objects based on their names

* Collection Manager operators
  The existing buttons  are placeholders

* Collection Manager drawing
  The editor main region is empty

* Collection Override

* Per-Collection engine settings
  This will come as a separate commit, as part of the clay-engine branch

Dev Commit Log
--------------

* New DNA file (DNA_layer_types.h) with the new structs
  We are replacing Base by a new extended Base while keeping it backward
  compatible with some legacy settings (i.e., lay, flag_legacy).

  Renamed all Base to BaseLegacy to make it clear the areas of code that
  still need to be converted

  Note: manual changes were required on - deg_builder_nodes.h, rna_object.c, KX_Light.cpp

* Unittesting for main syncronization requirements
  - read, write, add/copy/remove objects, copy scene, collection
  link/unlinking, context)

* New Editor: Collection Manager
  Based on patch by Julian Eisel
  This is extracted from the layer-manager branch. With the following changes:

    - Renamed references of layer manager to collections manager

    - I doesn't include the editors/space_collections/ draw and util files

    - The drawing code itself will be implemented separately by Julian

* Base / Object:
  A little note about them. Original Blender code would try to keep them
  in sync through the code, juggling flags back and forth. This will now
  be handled by Depsgraph, keeping Object and Bases more separated
  throughout the non-rendering code.

  Scene.base is being cleared in doversion, and the old viewport drawing
  code was poorly converted to use the new bases while the new viewport
  code doesn't get merged and replace the old one.

Python API Changes
------------------

```
- scene.layers
+ # no longer exists

- scene.objects
+ scene.scene_layers.active.objects

- scene.objects.active
+ scene.render_layers.active.objects.active

- bpy.context.scene.objects.link()
+ bpy.context.scene_collection.objects.link()

- bpy_extras.object_utils.object_data_add(context, obdata, operator=None, use_active_layer=True, name=None)
+ bpy_extras.object_utils.object_data_add(context, obdata, operator=None, name=None)

- bpy.context.object.select
+ bpy.context.object.select = True
+ bpy.context.object.select = False
+ bpy.context.object.select_get()
+ bpy.context.object.select_set(action='SELECT')
+ bpy.context.object.select_set(action='DESELECT')

-AddObjectHelper.layers
+ # no longer exists
```
2017-02-07 11:11:00 +01:00
97fa285ae1 OpenGL: add gpuMatrixUpdate_legacy function
Marks matrix state as dirty so shader will use the latest values from glScale, glTranslate, etc.

We'll remove this after transitioning 100% to the new matrix API, which handles this sort of thing automatically.

Part of T49450
2017-02-06 23:24:10 -05:00
d23c57b84c fix unused var warnings
follow-up to earlier patch
2017-02-06 23:24:10 -05:00
6c95e97e64 OpenGL: convert clip_dopesheet_draw to new imm mode
D2486 by @TCMBoby, part of T49043
2017-02-06 23:24:10 -05:00
9b742ff61b OpenGL immediate mode: interface_draw.c (cont)
ui_draw_but_WAVEFORM
ui_draw_but_VECTORSCOPE
2017-02-07 00:24:44 +01:00
a54110751a OpenGL immediate mode: interface_draw.c (cont)
ui_draw_but_HISTOGRAM
UI_draw_text_underline (untested)
2017-02-06 16:54:26 +01:00
e58359c26f OpenGL immediate mode: interface_draw.c (cont)
Replaced GL_POLYGON in various places.
Ported UI_draw_roundbox_unfilled
2017-02-06 15:19:45 +01:00
8dbd961a3e OpenGL immediate mode: interface_draw.c 2017-02-06 14:06:13 +01:00
Dalai Felinto
cb3daaf355 Immediate mode: edit_curve_paint 1/2
Part of T49043
2017-02-06 12:43:24 +01:00
c3e2faaad5 BLF: simplify API for default font
We had two versions of several BLF functions -- one for a specific font ID & another for the default font.

New BLF_default function lets us simplify this API & delete the redundant code.
2017-02-05 01:01:41 -05:00
5ad5bb235b fix most UI text color
There are still many places to fix. I'll miss the bright yellow!

This commit also uses the new BLF_default function where possible.

Part of T49043 since we call glColor less often.
2017-02-05 00:54:21 -05:00
5908382011 add BLF_default function
So we don't need two versions of all other BLF functions -- one for specific font ID & another for the default font.
2017-02-04 23:12:53 -05:00
627566cb9a OpenGL: use GL4 on Linux when available
Minimum target is still 3.3

On AMD pro driver, asking for a 3.3 context gives us *exactly* 3.3, not 3.3+ as desired.

Have not tested proprietary NV or Intel drivers, but this fix should work on all vendors.
2017-02-04 19:35:54 -05:00
520ced4ad5 Modifications to GPU_texture:
-Remove NPOT check as it should be supported by default with OGL 3.3
-All custom texture creation follow the same path now
-Now explicit texture format is required when creating a custom texture (Non RGBA8)
-Support for arrays of textures

Reviewers: dfelinto, merwin

Differential Revision: https://developer.blender.org/D2452
2017-02-03 16:01:32 +01:00
b1b5ded37f Fix shaders in some immBindBuiltinProgram calls
Had mistakenly used 3D shaders for some 2D drawings...
Replaced those now.

Part of T49043
2017-02-02 23:21:08 -02:00
d85295534b Merge branch 'master' into blender2.8 2017-02-02 21:50:12 +01:00
47b21dd4c6 OpenGL immediate mode: transform_snap.c and part of drawnode.c
Also converted ED_node_draw_snap from drawnode.c
Committing these together, as they are inter-dependent.

Part of T49043
2017-02-02 14:28:46 -02:00
9a22b32e7e Make imm_drawcircball public
(Approved by merwin in IRC)

Required by part of T49043
2017-02-02 14:28:26 -02:00
57ac20d5b7 OpenGL immediate mode: space_graph.c
Part of T49043
2017-02-02 14:24:43 -02:00
3b71d5c0ae install_deps.sh: don't use backticks
The script complained that it could not find the executable "--build-all".
2017-02-02 16:04:49 +01:00
2e8be8ac6b OpenGL immediate mode: view3d_ruler.c
Differential Revision: https://developer.blender.org/D2485

Part of T49043
2017-02-01 22:23:49 -02:00
8e05a5bf8c fix build: BLF Theme color
blenderplayer uses BLF but not Editor UI, so we got a link error for the missing UI_GetThemeColor function.

Moved the new function from BLF to UI.

@Blendify reported problem in IRC
2017-02-01 19:00:51 -05:00
64b4a3185c OpenGL immediate mode: drawanimviz.c
Differential Revision: https://developer.blender.org/D2484

Part of T49043
2017-02-01 20:58:56 -02:00
57573df0d3 Add GetThemeColorBlendShade3ubv function
Differential Revision: https://developer.blender.org/D2484

Used by part of T49043
2017-02-01 20:40:49 -02:00
4935e2449b BLF can use Theme colors
For anything fancier than regular Theme colors (shading, alpha, etc.) do this:

unsigned char color[4]
UI_GetThemeColor[Fancy]4ubv(... color)
BLF_color4ubv(fontid, color)

That way the BLF color API stays simple.
2017-02-01 16:44:00 -05:00
7493a2b3c0 set default color for BLF fonts
Set to an annoying bright color so we can see where to add BLF_color calls.
2017-02-01 16:21:08 -05:00
ba551014f8 add BLF_color functions
Needed a way to pass main font color to BLF without using obsolete glColor. Could not use immUniform since BLF binds its shader internally.
2017-02-01 16:21:08 -05:00
13399d471e OpenGL immediate mode: editmesh_knife.c
Differential Revision: https://developer.blender.org/D2481

Part of T49043
2017-02-01 18:52:10 -02:00
fd089843b3 OpenGL immediate mode: transform_constraints.c
Differential Revision: https://developer.blender.org/D2483

Part of T49043
2017-02-01 17:32:33 -02:00
eca2f918a7 OpenGL immediate mode: transform_generics.c
Differential Revision: https://developer.blender.org/D2482

Part of T49043
2017-02-01 17:03:58 -02:00
be72d7a9f5 OpenGL: use new matrix API for Loop Cut
Follow-up to rB85174329d9f5
Part of T49450
2017-01-31 17:10:25 -05:00
adb422e500 OpenGL: fix MultMatrix order
Partial revert of rB06d4aca87956

Problem found while converting old GL matrix calls to new API (T49450)
2017-01-31 17:10:25 -05:00
3e9ade6e31 Merge branch 'master' into blender2.8
Conflicts:
	source/blender/blenkernel/intern/depsgraph.c
	source/blender/blenkernel/intern/library_query.c
2017-01-31 10:47:43 +01:00
85174329d9 blender 2.8: OpenGL immediate mode: editmesh_loopcut.c
Reviewers: merwin

Reviewed By: merwin

Subscribers: dfelinto

Tags: #bf_blender_2.8

Maniphest Tasks: T49043

Differential Revision: https://developer.blender.org/D2480
2017-01-31 03:07:47 -05:00
b997914f80 OpenGL: remove NPOT texture rescaling logic
This code was already disabled.

We might be able to simplify GPU_check_scaled_image even further. Maybe even delete it? Just removing the obvious stuff now.

Keeping is_power_of_2_resolution function since it is still used in DXT logic.
2017-01-31 02:52:43 -05:00
Dalai Felinto
2081dac93b Mesh batch caches should not be stored in file 2017-01-27 15:21:14 +01:00
Dalai Felinto
8d04f49d0e Mesh batch caches update from depsgraph
We no longer need to rely on Derived mesh flag since the mesh is
properly flushed from the depsgraph
2017-01-26 19:14:39 +01:00
Dalai Felinto
9b7b9d6ae9 Depsgraph: mesh cache depends needs updates when geometry changes (patch by Sergey Sharybin) 2017-01-26 19:06:17 +01:00
Dalai Felinto
4c43dddeb7 Use the ultimate depsgraph callback function
Note: when in edit mode this depsgraph update is not being called. We are using DerivedMesh in those cases, so it is fine. I would like to investigate this though
2017-01-26 18:56:52 +01:00
9023abbf27 Depsgraph: Add placeholder function to handle objects update
This way @dfelinto can do some special trickery in there.
2017-01-26 17:24:57 +01:00
5ef2f21963 Merge branch 'master' into blender2.8 2017-01-26 17:23:33 +01:00
d812e0cb64 Blender 2.8: Apparently auto-merge worked incorrect in the merge commit 2017-01-26 17:04:25 +01:00
9e48cafd6d Merge branch 'master' into blender2.8 2017-01-26 17:02:28 +01:00
Dalai Felinto
290e080db4 Fix T50530: Crash on Info Editor "console"
Introduced on rB2de882e8 - the original size of the array was neglected
2017-01-26 09:41:40 +01:00
Dalai Felinto
99cfad6a01 Convert MBC_ API to Mesh (instead of derived mesh) and move it to mesh_render
This includes a few fixes in the MBC_ api.

The idea here is for this to be the only interface the render engines
will deal with for the meshes.

If we need to expose special options for sculpting engine we refactor
this accordingly. But for now we are shaping this in a per-case base.

Note:
* We still need to hook up to the depsgraph to force clear/update of
batch_cache when mesh changes

(I'm waiting for Sergey Sharybin's depsgraph update for this though)

* Also ideally we could/should use BMesh directly instead of
DerivedMesh, but this will do for now.

Note 2:
In the end I renamed the `BKE_mesh_render` functions to `static
mesh_render`. We can re-expose them as BKE_* later once we need it.

Reviewers: merwin

Subscribers: fclem

Differential Revision: https://developer.blender.org/D2476
2017-01-25 10:01:48 +01:00
5be2a62ca3 Merge branch 'master' into blender2.8 2017-01-24 14:56:56 +01:00
f286e7e017 Depsgraph: Make it more clear and explicit compile fail when required features are not found 2017-01-24 12:57:33 +01:00
769d189ff1 Depsgraph: Remove legacy code from new depsgraph
Now we have no remaining WITH_LEGACY_DEPSGRAPH in the code.
2017-01-24 12:55:37 +01:00
610af632a9 Depsgraph: Remove command line argument to use new depsgraph 2017-01-24 12:54:21 +01:00
a2d609331b Depsgraph: Remove more legacy code from viewport 2017-01-24 12:52:20 +01:00
218b06eb83 Depsgraph: Remove legacy updateDepgraph callbacks from modifiers 2017-01-24 12:49:23 +01:00
55e6d5428d Depsgraph: Remove legacy implementation of depsgraph 2017-01-24 12:47:23 +01:00
f20b8ae5aa Depsgraph: Remove legacy calls from scene update routines 2017-01-24 12:42:56 +01:00
46d6992907 Depsgraph: Remove special exception in update logging 2017-01-24 12:34:28 +01:00
9e40027110 Depsgraph: Remove special version of pose builder 2017-01-24 12:34:24 +01:00
23122ca889 Depsgraph: Remove legacy depsgraph code from viewport 2017-01-24 12:34:18 +01:00
991bda6959 Depsgraph: Remove legacy depsgraph code from transform 2017-01-24 12:34:14 +01:00
08ca32093a Merge branch 'master' into blender2.8 2017-01-23 18:11:42 +01:00
Julian Eisel
1814241526 Merge branch 'master' into blender2.8
Conflicts:
	source/blender/editors/space_action/action_draw.c
2017-01-22 21:16:00 +01:00
cdaed4d360 Fix compilation error with strict flags and gcc-6 2017-01-20 17:43:13 +01:00
8aa8165e85 OpenGL: convert legacy calls in transform.c
Took pieces from D2316 and D2359, changed a few more things.

- use new immediate mode
- use new matrix stack
- remove state push/pop

Part of T49043 and T49450
2017-01-19 00:46:20 -05:00
3216831c76 T50457 Remove temporary solution for animation types and put in definitve position
After revert the commit rB4b99958ca12642, the line added at the end of the enum is not necessary anymore because it is replaced by the corresponding element in the list in the right position.
2017-01-17 20:01:59 +01:00
3df30c34c3 Revert "Remove particle expander"
This reverts commit 4b99958ca1.
2017-01-17 19:46:05 +01:00
61b52f6d90 Fix previous commit because there are some code using this define, but really it is not used in editors. This is a temporary fix to broken editors, but this entry must be removed or moved to the right place when particles are in place again. 2017-01-17 15:53:31 +01:00
276e36a59f Remove unused definition. This enum must be synchronized with the registration ANIM_init_channel_typeinfo_data function in anim_channels_define.c
If the list is not equal, weird things start to happend in animation editors.
2017-01-17 13:33:37 +01:00
43872f59b9 Merge branch 'master' into blender2.8 2017-01-16 21:03:12 +01:00
af9e99763c OpenGL: convert anim_channel_defines.c to new imm mode
This is part of T49043

fixed up some color/rect calls

fixed up ANIM_channel_draw()

Reviewers: krash, merwin

Reviewed By: merwin

Tags: #bf_blender_2.8

Maniphest Tasks: T49043

Differential Revision: https://developer.blender.org/D2377
2017-01-16 00:18:28 -05:00
7d55761c5d OpenGL: fix immRect usage & convert more glRect calls
part of T49043
2017-01-15 23:48:46 -05:00
4e2c6ad8ee Updating outliner_draw_struct_marks to retained mode
Had to add a few utility functions to replace existing functions. Let me know if these are duplicates.

Reviewers: merwin

Reviewed By: merwin

Tags: #bf_blender_2.8

Maniphest Tasks: T49043

Differential Revision: https://developer.blender.org/D2434
2017-01-15 19:30:05 -05:00
7eb4c850d3 Merge branch 'master' into blender2.8 2017-01-12 12:59:45 +01:00
Dalai Felinto
77dcf0fbc5 Merge remote-tracking branch 'origin/master' into blender2.8 2017-01-11 09:44:25 +01:00
Dalai Felinto
80865bd583 Fix building with INPUT_NDOF after warning cleanup
Reported by Clément Foucault
2017-01-11 09:43:40 +01:00
Dalai Felinto
9533eb4908 Fix warnings (mostly unused arguments) 2017-01-10 18:36:00 +01:00
Dalai Felinto
5ed5ed59c3 Fix T49861: Interlace stereo drawing
This does not address stapling shader in 2.8, though the solution can be
similar (own shader, not polutting interlace shader).

part of T49043

Reviewers: merwin

Differential Revision: https://developer.blender.org/D2440
2017-01-09 17:58:13 +01:00
Julian Eisel
e42e1769b3 Merge branch 'master' into blender2.8
Conflicts:
	source/blender/editors/gpencil/drawgpencil.c
2017-01-05 00:31:15 +01:00
Dalai Felinto
329879239e Merge remote-tracking branch 'origin/master' into blender2.8
I'm deliberately ignoring/reverting rB070f22c4 which in turns means T49861 is happening on 2.8
2017-01-02 11:47:26 +01:00
Dalai Felinto
d78f51a4c2 Merge remote-tracking branch 'origin/master' into blender2.8 2017-01-02 11:31:03 +01:00
fb20cbe04c Fix missing particlemode context mode, after recent particle-removal revert.
This caused the particle mode tools panel to appear in object mode, where it
misses some contextual data and spews python exceptions.
2016-12-30 12:13:21 +01:00
f874aeef70 Merge branch 'master' into blender2.8
Please **DO NOT** add changes from master when it's totally uneeded!

Changes to BLI_ area most certainly shall *always* be done in master,
there is absolutely no point in adding more diff between the two
branches than needed, will only makes merging more cumbersome!

Conflicts:
	CMakeLists.txt
	source/blender/blenlib/intern/math_vector_inline.c
2016-12-29 20:05:22 +01:00
6ecab6dd8e Revert particle system and point cache removal in blender2.8 branch.
This reverts commit 5aa19be912 and b4a721af69.

Due to postponement of particle system rewrite it was decided to put particle code
back into the 2.8 branch for the time being.
2016-12-28 17:30:58 +01:00
Dalai Felinto
605263177b Merge remote-tracking branch 'origin/master' into blender2.8 2016-12-23 15:36:16 +01:00
76c4f0ec6c Fix parameter error (changes by Mike Erwin) 2016-12-19 22:36:56 +01:00
3af98b4c04 Merge branch 'master' into blender2.8
Conflicts:
	intern/cycles/blender/CMakeLists.txt
	source/blender/editors/gpencil/drawgpencil.c
	source/blender/editors/physics/physics_ops.c
2016-12-17 13:07:00 +01:00
1bfe359802 OpenGL fixes
- mixing of old & new APIs
- vertex format mismatch
2016-12-14 02:43:26 -05:00
1e21b8dc1b OpenGL: another way to set uniform theme color 2016-12-13 16:45:59 -05:00
0fa887ae35 OpenGL: finish area action zone todo
Replace outlined circle (24 vertices) with a point sprite (1 vertex).

Replace one todo with another todo.
2016-12-13 15:43:13 -05:00
3b98b44223 small fix for previous commit 2016-12-13 15:03:58 -05:00
fe59296361 OpenGL: new immediate mode in area.c
D2361 by @punya, part of T49043
2016-12-13 14:51:39 -05:00
9be6d5ff18 Merge branch 'master' into blender2.8
Conflicts:
	source/blender/blenkernel/intern/depsgraph.c
	source/blender/blenloader/intern/versioning_270.c
	source/blender/depsgraph/intern/builder/deg_builder_relations.cc
	source/blender/makesrna/intern/rna_main_api.c
	source/blender/makesrna/intern/rna_particle.c
2016-12-12 16:17:57 +01:00
Julian Eisel
54528079e3 Correction to previous commit
Accidentally included some changes from workspaces branch.
2016-12-08 23:27:56 +01:00
Julian Eisel
35c18e4871 Move screen drawing functions into new screen_draw.c 2016-12-08 23:17:45 +01:00
47c6047873 3D cursor & mini axis for modern viewport
Shuffle existing code, hook it up to the new (& old) viewport.

Also the 3D mouse rotation guide for NEW viewport only. Minor feature not worth enabling for legacy 3D view.
2016-12-05 02:50:28 -05:00
6ab42eb0bd OpenGL: delete bl_debug_draw
Eliminating this chunk of legacy GL as part of T49043.

We can introduce some sort of "debug plate" to fill this need in the future.
2016-12-04 20:34:44 -05:00
5de33c3b64 cleanup: C99 for view3d_draw
Mostly for clarity & to declare things close to where they are used.

I'm getting ready to do substantial work in these files.
2016-12-04 20:11:12 -05:00
7458a022aa OpenGL: cleanup function parameters & state
glDepthMask takes GLenum
glLineWidth & PointSize take float
glCullFace has no effect when GL_CULL_FACE disabled
2016-12-01 18:18:07 -05:00
Julian Eisel
52ec962516 UI: Previews for screen layouts
Basically all this does is drawing layout previews into the opened layout search menu.
https://youtu.be/RHYWtZP7pyA

The previews are drawn using offscreen rendering so they can't use multi-threading (yet!). But that shouldn't be an issue since only a handful of previews are drawn at the same time. Normally we only need to redraw the preview if a screen layout was changed. Would be nice if PreviewImage could store if it supports threaded rendering.
Previews are saved in files, might be useful if you later want to support appending layouts.
Adds a new file screen_draw.c.
2016-12-01 17:19:58 +01:00
4ff4dbc0ab Immediate mode replacement for compositor node backdrop elements.
Part of T49043.
2016-12-01 17:08:29 +01:00
ff2a74906a Merge branch 'master' into blender2.8 2016-12-01 10:29:46 +01:00
73c1c92c0e Fix C++11 building on MSVC 2015
Newest 2017 not yet supported because i don't know its version symbol...
2016-11-29 02:35:46 -05:00
a76f1a7449 Default to C++11 for all compilers (2.8)
This fixes multiple problems on latest Mac OS + Xcode. Hopefully does not cause any on other platforms.

The Xcode detection logic could use further cleanup. It's checking several old versions that are unsupported for Blender 2.8+ development.
2016-11-29 01:01:38 -05:00
8d4421b0fc DerivedMeshes clean up their draw-batch caches
No more "Not freed memory blocks"!

This code was almost ready 1 month ago, waiting for other pieces to fall into place.
2016-11-29 00:26:21 -05:00
9f35495a26 Gawain: batch mode uses buffer ID funcs
The _discard functions now free their resources! These were waiting on thread-safe ID management, which we now have.
2016-11-29 00:12:50 -05:00
4af42f06c3 Gawain: immediate mode uses buffer ID funcs
These functions are called very infrequently.
2016-11-29 00:08:07 -05:00
328a47fa2c Gawain: manage GL buffer IDs in a thread-safe way
Needed because deps graph can destroy objects from any thread. We ran into the same problem & solved it in GPU_buffers.

Implemented in C++11 since it provides the needed machinery. The interface is in C like the rest of Gawain.
2016-11-29 00:03:54 -05:00
e369b85e2f Replacing UI_view2d_scrollsers_draw() to immedaite mode
Part of T49043

Reviewers: krash, merwin

Reviewed By: krash, merwin

Differential Revision: https://developer.blender.org/D2364
2016-11-28 20:14:15 -05:00
c6d6f39153 Moved UI_view2_multi_grid_draw() to Gawain
Part of T49043, to replace gl immediate calls with Gawain

Reviewers: krash, merwin

Reviewed By: krash, merwin

Tags: #bf_blender_2.8

Differential Revision: https://developer.blender.org/D2363
2016-11-28 20:11:13 -05:00
Julian Eisel
2821da5b70 Enable multi-selection editing by default (Alt-key behavior)
This means editing a property will now always affect all selected objects, bones or sequencer strips. Support for this was added in rBdfbb876d4660 but you had to hold the Alt-key to use it. The old behavior of only editing the active object will not be kept like decided in the 2.8 workflow meeting (reports comming). If you only want to edit the active object, you have to deselect others.

There are still a couple of issues to be resolved (listed below), but having it enabled by default helps testing and getting used to it and should motivate us to fix them ;)
To be fixed:
* Give users hint when edits are applied to all objects/bones/strips ("Applying to x objects") - there are ideas but we need to finalize and implement them
* Make it work better in corner cases (material editing, modifier property editing, etc)

Note: Values usually override the initial value of the object/bones/strips, except of number buttons where it depends if you enter the value (absolute override) or drag the value (add value change). This behavior is consistent with multi-button editing.
2016-11-27 16:28:56 +01:00
Julian Eisel
a796a84a43 Use const for color array arguments 2016-11-22 14:51:34 +01:00
Julian Eisel
60ce602380 Fix missing conversion of uchar color to float
Decided to just pass float [4] args, so no type conversion is needed at all.
2016-11-22 14:40:57 +01:00
559bd75766 Merge branch 'master' into blender2.8
Conflicts:
	source/blender/blenloader/intern/versioning_270.c
	source/blender/depsgraph/intern/builder/deg_builder_nodes.cc
	source/blender/depsgraph/intern/builder/deg_builder_relations.cc
	source/blender/editors/space_view3d/drawobject.c
2016-11-19 16:28:39 +01:00
Martijn Berger
5cbc7b6ed2 bgl do not bind parts of OpenGL that are not exposed in core profiles 2016-11-19 15:07:01 +01:00
Martijn Berger
53267d2579 convert icon_draw_texture to gawain imm mode replacements 2016-11-18 16:04:25 +01:00
e0bea34c51 fix problem from D2360
I was too eager to get patch in after a last-minute change. My bad!
2016-11-18 00:40:40 -05:00
43ed3079e2 Moved UI_view2d_grid_draw() to immediate functions
Part of T49043

Reviewers: krash, merwin

Reviewed By: krash, merwin

Differential Revision: https://developer.blender.org/D2360
2016-11-17 22:49:22 -05:00
2de882e8cb OpenGL: textview port to immediate mode -> T49043
Updated the GL calls to the new immediate mode.
I left some glcolor calls which I'm not sure wether thats right?
Part of T49043

warm regards,
Sebastian Witt

Reviewers: merwin

Reviewed By: merwin

Tags: #bf_blender_2.8

Maniphest Tasks: T49043

Differential Revision: https://developer.blender.org/D2305
2016-11-17 22:05:49 -05:00
fe73b8c29c use new enum types in glutil & imm_util 2016-11-17 16:10:53 -05:00
d915e89ec8 delete deprecated fdrawXORcirc function
Only one place used it, and that place was dead code already.
2016-11-17 15:03:55 -05:00
feccadd81b mark certain glutil functions as deprecated
These will be removed before we ship 2.8
2016-11-17 14:44:15 -05:00
86f435d6c8 Gawain: small note for future Vulkan work 2016-11-16 18:25:36 -05:00
Martijn Berger
b757e8298a Convert console_draw.c to Gawain
Reviewers: merwin

Reviewed By: merwin

Tags: #bf_blender_2.8

Differential Revision: https://developer.blender.org/D2276
2016-11-16 22:56:39 +01:00
b1f700dad3 Gawain: use PRIM_ and INDEX_ enums instead of GLenum
For a few reasons:
- separate enum sets for separate concepts
- debug with symbolic names instead of 0x4e72
- prepare for a Vulkan future
2016-11-16 16:03:15 -05:00
36ac979ee0 Gawain: use COMP_ instead of GL_ internally
Because GLenum could be ANYTHING. We use our own enum type for components.
2016-11-16 15:18:06 -05:00
7aa82e7ed2 Gawain: re-enable strict error checking in release builds
Makes it easier for new volunteers to catch errors early.
2016-11-16 12:14:55 -05:00
472e2c5acf Blender 2.8: Added immVertex2s() and immAttrib2s()
Just as mentioned in title. Need new functions for calls found in `transform.c`

T49043

Reviewers: merwin

Tags: #bf_blender_2.8

Differential Revision: https://developer.blender.org/D2358
2016-11-16 11:53:41 -05:00
Dalai Felinto
2bcb1b208a Merge remote-tracking branch 'origin/master' into blender2.8 2016-11-16 17:04:21 +01:00
930f999f6e Part of T49043: Convert drawsimdebug.c to use the new Gawain API.
This conversion is pretty straightforward.

The code for debug drawing is not great, but it does the job.
Rewriting it is for another day, if it becomes more widely used.
2016-11-16 12:18:12 +01:00
15b2a64d0a Add stdlib.h include to fix missing 'abort' prototype. 2016-11-16 11:31:35 +01:00
3b06c42616 Blender2.8 convert UI_view2d_constant_grid_draw to new immediate mode
Convert UI_view2d_constant_grid_draw to new immediate mode.

Part of T49043.

Reviewers: merwin

Reviewed By: merwin

Tags: #bf_blender_2.8

Differential Revision: https://developer.blender.org/D2298
2016-11-15 18:59:24 -05:00
edddd2c6f5 Use new immediate mode for ED_region_grid_draw
Convert ED_region_grid_draw to new immediate mode.

Part of T49043

Reviewers: merwin

Reviewed By: merwin

Tags: #bf_blender_2.8

Differential Revision: https://developer.blender.org/D2289
2016-11-15 18:37:03 -05:00
2653758adc blender 2.8: OpenGL immediate mode: anim_draw
Reviewers: merwin

Reviewed By: merwin

Maniphest Tasks: T49043

Differential Revision: https://developer.blender.org/D2353
2016-11-15 12:19:47 -05:00
b78ddd43a5 start using COMP_* instead of GL_* in viewport
Gawain can accept either enum, but its own COMP_ values are recommended.
2016-11-15 11:49:00 -05:00
093b6c9e6e blender 2.8: OpenGL immediate mode: action_draw
Updated action_draw to use imm mode.

Reviewers: merwin

Subscribers: LazyDodo

Differential Revision: https://developer.blender.org/D2351
2016-11-14 23:02:57 -05:00
665aa6a2a0 blender 2.8: Opengl: UI_draw_roundbox
all is in the title too..

Reviewers: merwin

Reviewed By: merwin

Subscribers: Blendify, Severin

Tags: #bf_blender_2.8, #opengl_gfx

Maniphest Tasks: T49043

Differential Revision: https://developer.blender.org/D2337
2016-11-14 20:27:54 -05:00
8859aa3828 OpenGL: use packed normals for fancy wireframes
Consumes much less memory (1/3 for both normals = 32 bytes less per edge). Same visual result.

We can pack normals for other draw modes to get similar savings.

Part of T49165
2016-11-13 20:27:50 -06:00
ffc26fc5a8 Gawain: add support for 10_10_10 vertex format
Most useful for packed normals, which take 1/3 the space of float32 normals.

2-bit alpha|w component is ignored for now.

Batch API can use these now, will add support to immediate mode API if desired.

Enabling on Windows first. Will enable on all platforms after we switch Blender to core profile.
2016-11-13 20:18:51 -06:00
1dbe26f76c OpenGL: simplify debug, use only newer features
Drop SciTech support & workarounds for WinCE and OpenGL ES.

AMD_debug_output is still in the code but disabled. Once I verify the newer extensions are available on all the GPU + OS combos we support we can delete this disabled code.
2016-11-12 17:18:13 -06:00
eb880f280d Gawain: strict error checking in debug builds
Not release builds. Fix 66d7f01ecc to match what I meant to do.
2016-11-11 23:53:58 -06:00
8fd510f4b8 Gawain: new enum type for vertex attrib components
Motivations:
1) GLenum is too broad; tightly-defined enum just for this is safer.
2) enable a Vulkan future

New code should use these instead of GL_FLOAT etc. When all existing code has been updated to use new enum, we can drop compatibility with GLenum values.

Early work towards 10_10_10 format, more to come soon.
2016-11-11 19:39:56 -06:00
Julian Eisel
82ba89b042 Fix T49961: Blender 2.8 Crashes on saving an image
Caused by 4811b2d356 which caused the event handler hack that is used to fire up the file browser from other operators to fail. Basically the context from before the file browser is opened gets stored and used later for executing the actual file read/write operation (in this case, saving image). This context storage is cleared when exiting an editor since 4811b2d356, which is technically correct, but causes usage of NULLed context data in this case, because the file browser is exited before the file read/write operation is executed.

For now I solved this by moving the fileselect handler to list of normal handlers, instead of modal ones. 4811b2d356 only touches list of modal handlers so we avoid the crash. Ideally we'd completely refactor how the file browser opening works to get rid of these event handler hacks.

Note that I wouldn't be suprised if this causes other regressions, but I couldn't find one so worth a try.
2016-11-10 20:34:35 +01:00
Dalai Felinto
69655a1103 Merge remote-tracking branch 'origin/master' into blender2.8 2016-11-09 14:36:59 +01:00
a0ae6d7116 OpenGL: manage built-in shaders better
As our library of built-in shaders grows, it's important to create, access, and discard them efficiently.

Lookup via GPU_shader_get_builtin is now constant time instead of linear (# of built-in shaders). This is called very often with our new immediate mode.

Creation and discard are unified.

Adding a new shader requires fewer steps.

365 lines shorter  :D
2016-11-08 22:53:59 -06:00
2b726b054e blender 2.8: OpenGL immediate mode: node_draw_preview_background
all is in the title.

Reviewers: merwin

Tags: #bf_blender_2.8, #opengl_gfx

Maniphest Tasks: T49043

Differential Revision: https://developer.blender.org/D2336
2016-11-08 11:12:29 -05:00
12bce04b2f Blender 2.8: OpenGL: new immediate mode for paint_image.c
This one is for the straight line (white with width 2.0 over a black with width 4.0) drawn when you use the gradient tool.

To test: Image editor, create / open an image, choose image paint mode and on the tool shelf: choose the Fill brush and enable "Use Gradient" for it. Then click and drag on the image.

From what I checked, calls to glLineWidth are not being removed yet, so I kept them.

Reviewers: dfelinto, Severin, merwin

Reviewed By: merwin

Tags: #bf_blender_2.8, #opengl_gfx

Maniphest Tasks: T49043

Differential Revision: https://developer.blender.org/D2312
2016-11-08 11:08:16 -05:00
f90b480f95 OpenGL: wm_operators.c uses new immediate mode
D2311 by @ianwill

This is the radial control that appears when we change the size of a brush in sculpt and vertex and texture painting modes, by pressing "f".

Also includes a new built-in shader that can be useful in other places.

Part of T49043
2016-11-08 10:55:23 -05:00
4e80bd2d6d Blender 2.8: OpenGL: new immediate mode API for screendump.c
It's the screencast cursor, tested here, compared to original, seems to be working fine.

Reviewers: dfelinto, Severin, merwin

Reviewed By: merwin

Tags: #bf_blender_2.8, #opengl_gfx

Maniphest Tasks: T49043

Differential Revision: https://developer.blender.org/D2306
2016-11-08 10:10:55 -05:00
66d7f01ecc Gawain: less error checking in release builds
Gawain does very strict runtime checking to help us catch coding errors. Final release should disable most of these checks, so I'm disabling now for all non-debug builds.

When writing Blender code that uses Gawain, always make debug builds and test there! "make lite debug" is my favorite.
2016-11-08 05:28:40 +01:00
de101fe9a8 OpenGL: mesh edit mode uses edge overlays
Legacy GL uses GL_LINES, modern GL uses the good stuff.

Edit mode still has a long way to go...
2016-11-08 05:22:17 +01:00
0b83680d85 OpenGL: support for edge overlays
Has some obvious opportunities for improvement. This is my second attempt. First attempt used MLoopTri and sort of worked...
2016-11-08 05:06:09 +01:00
016aca7427 OpenGL: fade other objects during edit mode
Right now this only affects other objects in wireframe. The idea is to do something similar for other draw modes, and keep focus on the edit object.

As seen at #bcon16
2016-11-07 20:32:27 +01:00
a3277ae384 OpenGL: simple mesh edit mode for new viewport
Very very simple. Needs a lot of work to reach "legacy viewport" capabilities.
2016-11-07 20:24:03 +01:00
5abf1a4e9d OpenGL: enable fancy wireframes
Most of this was already in place, just enabling & adding comments.

One fix was needed to make batch uniforms stick between multiple draws.

Added comments to selection outline; no functional changes there.
2016-11-07 20:07:31 +01:00
1cd754ad31 OpenGL: simple batch of all mesh triangles
Can be used for drawing basic surfaces, hit testing, depth pre-pass, ...
2016-11-07 20:07:31 +01:00
c1ba58c44d Merge branch 'master' into blender2.8
Conflicts:
	intern/cycles/blender/addon/properties.py
2016-11-07 15:46:27 +01:00
93dbd81796 Gawain: manage batch API's current shader program + uniform funcs
Typical pattern:
Batch_set_program
Batch_Uniform(s)
Batch_draw
2016-11-05 21:03:26 +01:00
5b26c36008 OpenGL: edge overlay shaders
As seen at #bcon16. These were produced quickly and probably need further work.

SIMPLE variant draws triangle mesh edges. Based on this research:
http://www2.imm.dtu.dk/pubdb/views/edoc_download.php/4884/pdf/imm4884.pdf
http://developer.download.nvidia.com/SDK/10/direct3d/Source/SolidWireframe/Doc/SolidWireframe.pdf

Non-SIMPLE variant can adjust thickness per edge. This can be used to draw only some edges, or accentuate some edges. Given the right inputs this is a general n-gon perimeter shader.

Part of T49165
2016-11-05 19:26:13 +01:00
a85f68e9c7 OpenGL: further wireframe shaders
As seen at #bcon16

Geometry shader version is automatically used on modern GL runtimes. Legacy version is used on pre-3.2 systems (Mac, Mesa compat profile). They have the same inputs and visual result.

TODO: specialized versions that are less flexible -- draw ALL edges or draw JUST silhouette edges.

Part of T49165
2016-11-05 18:56:57 +01:00
Dalai Felinto
c25c3bb6cb Fix UI for smoke cache
(this was probably broken since we got rid of point cache in 2.8)
2016-11-02 11:09:27 +01:00
Dalai Felinto
a41bbd3053 Merge remote-tracking branch 'origin/master' into blender2.8 2016-11-02 10:59:52 +01:00
fb6f42dc4f OpenGL: draw NLA strip curves with new imm mode
Part of T49043.
2016-10-31 17:42:11 +01:00
1556a28108 OpenGL: draw filebrowser dropshadow with new imm mode
Part of T49043.
2016-10-28 20:46:10 +02:00
Dalai Felinto
a25d3d7de2 Viewport: Set outline color for mesh based on active/select state
(also, fix warning regarding const float being written)

You only see the color if you use the "modern" viewport option
(otherwise I believe Blender is drawing the old on top of the new outline).

That said, in the "modern" viewport we have unfreed mem. To be
investigated separately.
2016-10-26 13:57:22 +00:00
2783d5df61 OpenGL: follow up on mesh wire TODOs
- depth test on (affects scene depth for now)
- color variations
- object outline  does not need GL_BLEND with latest shader
2016-10-26 04:18:19 -04:00
a394f4e545 OpenGL: edge shader discards fragments of unused edges
Discarded edges should not update depth buffer or blend with color buffer.

Geometry shader version will make this obsolete.
2016-10-26 03:57:14 -04:00
222ba0247f fix edge shader input 2016-10-25 19:38:22 -04:00
456d145d07 OpenGL: new mesh draw routines for new viewport
Totally WIP.

Started with copies of legacy routines, modified to use the new shaders & batch cache. Not all features are implemented; this is why we keep legacy viewport around during development!
2016-10-25 19:34:17 -04:00
Dalai Felinto
821fa24876 Viewport: fix depth not being cleared in ortho mode 2016-10-25 11:18:56 +00:00
Dalai Felinto
b4f849b9c6 Merge remote-tracking branch 'origin/master' into blender2.8 2016-10-25 11:18:41 +00:00
392551bd95 OpenGL: mesh batch cache (WIP)
Gawain batches are built on demand while drawing, then kept in this per-DerivedMesh cache.

A mesh's batches try to share vertex buffers as much as possible.

Not sure if this file is the best home for this code, but functions in this file are the only users of the cache. So maybe.

Big part of T49165
2016-10-25 05:31:25 -04:00
d8d42e1702 make View3D depth debug code optional
Quick hack to optionally disable depth buffer debugging at compile time.

Will this be useful for users or just during development?
2016-10-25 04:46:07 -04:00
bc566e9393 OpenGL: 3D View background & depth buffer details
Surveying buffer usage & clears for new viewport. Not yet perfect, but closer. Committing from Mac so I can test this on Windows.

Using new matrix API (T49450) for gradient background.
2016-10-25 04:39:55 -04:00
94e14a2c43 OpenGL: new built-in shaders for mesh edges 2016-10-25 03:19:10 -04:00
c5072941c3 OpenGL: clean up glActiveTexture usage
Removed some of my earlier glActiveTexture calls. After reviewing the
code I now trust that GL_TEXTURE0 is active by default. Fewer GL calls,
same results.

Fixed some misuse of glActiveTexture & glUniformi, mostly my fault.
Caught by --debug-gpu on Windows. Don't know why this appeared to be
working previously!

Plus some easy cleanup nearby.
2016-10-25 01:02:41 -04:00
Dalai Felinto
4d11b2fb91 Viewport: original gradient background
Last but not least, fix the original 3d view background based on
@merwin's comment.
2016-10-24 19:40:37 +00:00
Dalai Felinto
1458f0136d Viewport: move the background to the "modern" viewport
This also leaves room for the gradient background Mike Erwin wants to
implement.
2016-10-24 19:05:49 +00:00
Dalai Felinto
744718f635 immediate mode: background
There is a problem here, which is that we can't use immediate mode here
until we rely on `GPU_material_bind`.

(cc: @merwin)
2016-10-24 17:26:27 +00:00
Dalai Felinto
a3b69c8131 Viewport: fix depth filled before solid plates 2016-10-24 12:58:23 +00:00
6388d0c4a0 OpenGL: triple buffer tweaks
Works great on Mac now. Will test on Windows & Linux (Mesa) tomorrow. Related to T49505

Main fix is glActiveTexture and immUniform1i.

TEXTURE_2D vs TEXTURE_RECTANGLE is now a compile-time option. Both are available starting in GL 3.1 so there's no need for a run-time check.

Removed glClears that I don't think are necessary.

Prevent TEXTURE_2D from creating extra mipmap levels. We only need level 0.

Some minor cleanup: booleans and variable declarations.
2016-10-24 05:06:45 -04:00
1abdb0c2ee OpenGL: add NormalMatrix & inverse to new API
Part of T49450
2016-10-23 23:37:53 -04:00
2cb45c9938 a place to cache draw data in DerivedMesh
DerivedMesh owns this cache and cleans up as part of DM cleanup. DM has no idea what is stored in this cache. Loose coupling FTW
2016-10-23 23:22:16 -04:00
e53ab2b9ec Gawain: fixups & progress for batch API 2016-10-23 23:16:54 -04:00
Julian Eisel
dabbe6eb22 Fix memory leak when using depth-only shader 2016-10-24 00:03:55 +02:00
Julian Eisel
46257e01a7 Fix compiling with blenderplayer (once again...) 2016-10-22 00:30:28 +02:00
Dalai Felinto
5ff586610a Viewport: use depth shader to debug the depth
At the moment this already shows that the depth is the same after the solid plates and in the very end of drawing, while they should be different. Later on we can adapt this to show different buffers we want to debug.

I am using near=0.1, far=2.0 for my tests. I decided not to make a doversion for near/far because this is for debugging only
2016-10-21 20:51:12 +00:00
Dalai Felinto
deb77c0e74 Viewport: create a shader to show depth images linearized 2016-10-21 20:51:10 +00:00
Dalai Felinto
4c3624a7a0 Viewport: add missing alpha for stereo 2016-10-21 20:51:05 +00:00
Dalai Felinto
af20ca51a1 Viewport: Bring camera, speaker, rigid body shape and bounding box 2016-10-21 20:50:36 +00:00
cdcddddd96 OpenGL: disable GL_CULL_FACE state only when needed
The active camera has a solid "up" triangle instead of the usual outline. We want to see both sides of this triangle. Disable face culling only when drawing the active camera, not for every camera.
2016-10-21 16:25:17 -04:00
Dalai Felinto
01872d7f5d Fix build for gameengine 2016-10-21 12:50:04 +00:00
Dalai Felinto
dd23e52817 Merge remote-tracking branch 'origin/master' into blender2.8
Conflicts:
	source/blender/blenloader/intern/versioning_defaults.c
2016-10-21 12:22:50 +00:00
224d70c978 OpenGL: draw lamp objects with new imm mode
Previous commit in blender2.8 branch had some... unintended
consequences. This one should be better.

Part of T49043. Also uses new matrix API (T49450)
2016-10-20 16:55:40 -04:00
4ea6917468 OpenGL: box & circle outline functions that work with 3D position (z=0)
New immediate mode API is strict about attribute formats. These new functions make existing code easier to port.

Supports T49043
2016-10-20 14:33:32 -04:00
c6abbb40ad Gawain: closer integration of immediate mode & matrix APIs
- any shader program can use matrix state (not only built-in shaders)
- you can mix matrix & begin/end calls, and the bound shader will use the latest matrix state

Part of T49450 & T49043
2016-10-20 14:29:59 -04:00
a92d20a0a4 OpenGL: dirty bit for GPU matrix API
Have matrices changed since the most recent bind?

Part of T49450
2016-10-20 14:18:34 -04:00
Dalai Felinto
225edf4e66 immediate mode: outliner background
I tried using immRecti instead, but it didn't work. The current approach
should be more efficient anyways (since GL_TRIANGLE_FAN wouldn't work
here).
2016-10-20 01:44:49 +00:00
Dalai Felinto
33d99bdfe6 immediate mode: ed_util.c
note: I switched one of the glVertex2iv into glVertex2fv to use the same attrib_id
2016-10-19 23:59:22 +00:00
9941bc3041 OpenGL: draw empties with new imm mode
Part of T49043
2016-10-19 04:01:15 -04:00
625f1a1c30 OpenGL: draw cameras using new matrix API
Also removed some extra push/pops.
Ref T49450
2016-10-18 20:57:36 -04:00
05117d71a3 OpenGL: draw cameras with new immediate mode
Mostly the same as before. Except:
- avoid drawing same lines multiple times
- helper functions take "bool filled" argument instead of GLenum
- drawcamera_volume draws its own near & far planes
2016-10-18 20:27:24 -04:00
54a0ff3ab5 Gawain: yet another way to set uniform color 2016-10-18 20:22:22 -04:00
e9268abf4a fix narrow text entry fields
widget_draw_text was calculating wrong display length when field is too narrow to show entire input string. Gawain assert caught this 11 function calls away!

Thanks to @ianwill for reporting.
2016-10-18 17:34:29 -04:00
117af2356a skip drawing of gpencil strokes with overall thickness <= zero
Fixes an assert in drawing code.

Might need further work to support variable-thickness strokes (from pressure-sensitive stylus). This all is due for geometry shader overhaul anyway.
2016-10-18 13:12:40 -04:00
46a069822a draw gpencil dots smooth
Some strokes are just single dots. Draw these smooth / antialiased.
2016-10-18 13:07:35 -04:00
827ad4125c OpenGL: new built-in shader for smooth round 3D points 2016-10-18 13:03:30 -04:00
70ff63e63f OpenGL: tweak image shaders & code that uses them
- rename image shaders to describe exactly what they do
- rename inputs to match other built-in shaders
- set & use active texture unit
- no need to enable/disable textures with GLSL
- pull vertex format setup out of loops
2016-10-18 00:08:34 -04:00
0c6939f5f5 minor cleanup & deprecation 2016-10-17 23:48:12 -04:00
8327795f8d OpenGL: draw image empties with new API
This extensive rewrite caches the image texture in VRAM. Can handle images up to OpenGL limits (8K or 16K).

Part of T49043 & T49450
2016-10-17 23:28:51 -04:00
Dalai Felinto
6a0292cc19 Fix for gpu_shader_2D_texture_2D_frag.glsl
Report and patch by Willian Padovani Germano (ianwill)
2016-10-17 19:24:08 +00:00
Julian Eisel
4811b2d356 Proper fix for crash when joining areas that doesn't break manipulators
Turns out CTX_wm_region returns mostly NULL in wm_manipulatormaps_handled_modal_update. Now propertly unsetting area/region data of handlers when deleting area/region.
2016-10-17 19:28:09 +02:00
e7fddc0772 OpenGL: disable checks for NPOT texture support
Non-power-of-two textures are always allowed. Keeping the disabled checks in the code in case we support OpenGL ES in the future. Even then it should be a compile-time check, not at run-time.
2016-10-17 02:36:51 -04:00
42677fa937 Gawain: tweak tracking of unassigned attributes (no API change)
Hoping for a small performance win.
2016-10-16 23:50:18 -04:00
ca369e6f0c OpenGL: draw object centers nicer
Shaders + new immediate mode = very nice dots.

Part of T49043
2016-10-16 18:49:48 -04:00
61ca73ea10 OpenGL: new built-in shader for smooth round 3D points w/ outline 2016-10-16 18:43:24 -04:00
36d2365ac3 OpenGL: new immUniformThemeColorShadeAlpha function
Plus some naming cleanup.

Supports T49043
2016-10-16 17:48:35 -04:00
9cdf4afb76 Gawain: new immUniform4fv function 2016-10-16 17:48:35 -04:00
f7414b7412 fix IS_VIEWPORT_LEGACY macro 2016-10-16 17:48:35 -04:00
Julian Eisel
d1a35b7a08 Fix outliner items sometimes not opening
Own mistake in 9a9a663f40. Guessed there is a case where we have to rebuild the tree but everything seemed fine... It didn't work in display modes like "Data-Blocks".
2016-10-16 22:23:50 +02:00
Julian Eisel
fa39ec9e46 More fixes for keyframe theme options
Couple of issues here:
* Missing initialization for 3D view keyframe options for "Reset to Default Theme"
* Alpha values not reset correctly on "Reset to Default Theme"
* Alpha values of timeline keyframe options not reset correctly for old files
Also corrected old version patches even though they're overridden later, to avoid more issues in case people copy this code.

Corrections to d7af7a1e04 and 8d573aa0ec
2016-10-16 20:47:44 +02:00
Julian Eisel
196654ad08 Fix crash when joining areas (caused by manipulators)
Manipulator code tried to access the removed region from handler->op_region. Use context region now.
2016-10-16 19:31:57 +02:00
Julian Eisel
69713aa2da Cleanup: Quiet warnings, use RAD2DEG macro 2016-10-16 17:28:12 +02:00
Julian Eisel
b557ceb2c1 Merge branch 'master' into blender2.8
Conflicts:
	source/blender/editors/space_outliner/outliner_draw.c
	source/blender/editors/space_outliner/outliner_edit.c
	source/blender/editors/space_outliner/outliner_intern.h
	source/blender/editors/space_outliner/outliner_select.c
2016-10-16 15:33:00 +02:00
Julian Eisel
9a9a663f40 Outliner: Rework element selection behavior
* LMB now replaces selection instead of adding to it. Shift+LMB adds to selection (or removes if already selected). This is usual selection behavior Blender.
* Outliner selection isn't completely separate from object/sequencer-strip/render-layer/... selection anymore, when selecting an outliner item we now always try to select (and activate) the object it belongs to. Previously you had to click the name or icon of an item to select the object (or whatever) and on empty space within the row to set outliner selection.
* Collapsed items may show click-able icons for their children (nothing new). Clicking on such an icon will also select the hidden item it represents now, you'll notice after opening the parent. This valid from a technical POV, I'm not sure if this is wanted from user POV though. Changing would be easy, feedback welcome!
* Code cleanup.

Part of T37430.
2016-10-16 14:29:38 +02:00
Julian Eisel
f929045c2c Outliner: Avoid rebuilding tree when mouse-hover highlight changes 2016-10-16 14:10:30 +02:00
3999910b19 OpenGL: add GLSL #version 330, drop 140 and 150
GL 3.3 is the new minimum. Compatibility profile for now, core profile eventually. During development, GL 3.0 (on Mesa) and 2.1 (on Mac) will still work.

Part of T49012
2016-10-16 03:18:17 -04:00
1deab69e0a BLF/OpenGL: more text drawing optimization
Make color values compact. Set color once per primitive. Use new immSkipAttrib to avoid useless color copies.

All of this should make text drawing less CPU hungry.
2016-10-16 02:08:16 -04:00
741965615d Gawain: new immSkipAttrib function
Now you can explicitly skip a vertex attribute -- you don't give it a value and it won't get a copy of the previous vert's value. Useful for flat interpolated per-primitive values.

This is an advanced feature. Expect garbage in the empty spaces, and copies of garbage if you rely on the attrib copy behavior after skipping.
2016-10-16 01:58:26 -04:00
a4fe823416 BLF/OpenGL: accurate vertex count for drawing
We still need to BeginAtMost instead of simple Begin, since some glyphs could be clipped & not drawn.
2016-10-15 20:04:25 -04:00
a8dc3f4596 BLF: make blurry text an optional (disabled) feature
While trying to simplify text drawing, noticed no Blender code uses the blur feature. Hopefully scripts don't use it!
2016-10-15 19:40:41 -04:00
878938f203 OpenGL: remove some unused legacy matrix calls
Part of T49450
2016-10-15 19:08:19 -04:00
3996fbc564 OpenGL: bump Windows to GL 3.3 compat profile
Part of T49012
2016-10-15 14:41:29 -04:00
cf5750a85e Gawain: improve immediate mode performance
This was already fast on Apple, but @Severin and @dfelinto noticed slowdowns in user prefs, which is text heavy.

The problem was immBeginAtMost not being smart about VBO write flushing. immBeginAtMost can use all of its allocated range or only a subrange. The previous code was forcing back-to-back draw calls and buffer writes to serialize. This commit lets OpenGL know that our VBO writes never overlap, so there's no need to wait.

Should be much faster now!
2016-10-15 14:41:29 -04:00
Julian Eisel
5e428b3b3f Fix unitialized variable use
Own mistake in ae8e845470.
Patch by @efi0ng, thanks!
2016-10-15 18:59:31 +02:00
fcff984338 Merge branch 'master' into blender2.8 2016-10-15 10:05:03 +02:00
9632ca0a13 OpenGL: draw node sockets more efficiently
1 or 2 draw calls per node instead of 1 per socket (inputs + outputs).
Rearranged draw order so we set uniforms less frequently.
Some style & dead code cleanup.

Part of T49043
2016-10-15 02:49:00 -04:00
2df27995f9 OpenGL: new built-in point shader, clean up other shader names
Smooth round point with outline (uniform color) and fill (varying color).

Updated shader naming scheme: a shader that doesn't deal with color does not have to say "no color". Vertex shaders do not have to say "uniform color" since their frag counterpart actually has the uniform. Each name should describe what that shader *does*, not what it *doesn't do*.
2016-10-15 02:30:59 -04:00
48db35468f blender 2.8: OpenGL: node_circle_draw use now immediate mode
I use your new point shader to draw the node's soket

Reviewers: Severin, merwin

Maniphest Tasks: T49043

Differential Revision: https://developer.blender.org/D2286
2016-10-15 00:14:28 -04:00
29b47924dd OpenGL: bump Linux to GL 3.3 compat profile
fall back to 3.0 if needed (during development)

Part of T49012
2016-10-14 23:42:45 -04:00
4f4c7808e4 fix pointer type warning
thanks, gcc
2016-10-14 22:40:55 -04:00
Julian Eisel
325b21c1d5 Outliner: Fix missing indentation for search-match highlight
Own mistake in ae8e845470.
2016-10-15 02:08:38 +02:00
4736f19000 BLF: early exit when drawing empty strings
Avoids all kinds of setup & preparations to draw nothing.
2016-10-14 20:00:31 -04:00
3f0c0ed87d BLF: fix crash on text input fields
Some strings have known length, others are NULL terminated (len = INT_MAX in this case).

Now font drawing knows to treat INT_MAX special.
2016-10-14 20:00:31 -04:00
Julian Eisel
9904d73d9a Outliner: Draw highlights over entire row
Previously, highlights (mouse hover, selection, search-match) didn't affect background of restriction icons, now the entire line gets highlighted.
2016-10-15 01:38:44 +02:00
Julian Eisel
ae8e845470 Outliner: Element mouse hover feedback
Some little UI polish to get familiar with outliner code (but also because it's a useful feature). Committing to blender2.8 branch but can also port to master (2.7) if wanted.

This basically causes the mouse hovered element to be highlighted. Contrast of the highlight should be fine, even with a non-default theme. Also did some minor cleanup.
2016-10-15 01:03:25 +02:00
Dalai Felinto
ee54a6f130 viewport: draw non-mesh objects for a starter
This starts to decouple non-mesh objects and the legacy draw pipeline.
It shows how we can mix e.g., Cycles and lamps and empties.
2016-10-14 19:00:59 +00:00
Dalai Felinto
608e2402ef viewport: move border drawing code to new file 2016-10-14 19:00:45 +00:00
Dalai Felinto
4a10eb38a3 immediate mode: convert render border code and move to new drawing
routine
2016-10-14 19:00:32 +00:00
Dalai Felinto
e1e97bbb98 Immediate mode: use new util functions, and border draw functions
Part of T49043

Reviewers: merwin
2016-10-14 18:58:58 +00:00
Dalai Felinto
11653f85ff Immediate mode: new util functions (imm_cpack and imm_draw_line_box) 2016-10-14 18:57:38 +00:00
34dc660a76 OpenGL: draw text with fewer draw calls
Was one draw call per glyph,  now one per line.

Still room for improvement here.
2016-10-14 14:41:36 -04:00
dd350c0b37 GPencil: Avoid assert error if the immEnd is called with only one point for lines
This function will be replace by geometry shader, but we need this fix until the shader will be ready. The problem is similar to T49614.
2016-10-14 19:24:27 +02:00
6855ba4034 Fix T49614: Grease Pencil GPF error if stroke thickness change too much between stroke points
The problem was the function tried to draw a line with one point only. This fix will be replaced by new geometry shaders, but we need while this change is not ready.
2016-10-14 18:35:01 +02:00
f23db59e48 GPencil: Display stroke filling while drawing
Before this change, the stroke was filled only after complete the stroke drawing. For artist is better to get a feedback of the area he is filling while drawing, so this commit draws the filling area while drawing.

The triangulation of the stroke is recalculated every time the function is called because using a cache is not useful because the points information is changing all the time while the stroke is being drawing.
2016-10-14 12:06:30 +02:00
Dalai Felinto
58f0af965c viewport: fix rv3d->viewport mem free issue 2016-10-14 05:17:55 +00:00
Dalai Felinto
3cecf39069 immediate mode: starting using new immUniformThemeColorBlendShade and more conversion 2016-10-13 20:08:52 +00:00
Dalai Felinto
05cf74622f more theme color functions: UI_GetThemeColorBlendShade4fv, immUniformThemeColorBlendShade 2016-10-13 20:08:51 +00:00
945f8e3f93 Gawain: vertex format now uses fixed allocations (CPU perf++)
API stays exactly the same.

Attribute names can still be of variable length, as long as the average length does not exceed AVG_VERTEX_ATTRIB_NAME_LEN. Since this includes unused attributes (length = 0) the current avg of 5 might even be too high.
2016-10-13 15:15:40 -04:00
Dalai Felinto
dfa5b32c8c Merge remote-tracking branch 'origin/master' into blender2.8 2016-10-13 16:42:54 +00:00
Dalai Felinto
ecbedce81e viewport: barebones to handle viewport compositing in gpu_viewport.c 2016-10-13 16:26:29 +00:00
14d0549295 Gawain: fix build when TRUST_NO_ONE is disabled 2016-10-13 12:24:01 -04:00
Julian Eisel
916e631fc9 Fix compiling with Blenderplayer 2016-10-13 17:17:17 +02:00
Dalai Felinto
3579350481 immediate mode: small cleanup on timeline
(no need to unbind/rebind the same program)
2016-10-13 14:18:47 +00:00
6f220c1c55 inform immediate mode when switching OpenGL context
Longstanding to-do is now to-done.

Heinous bug reported by @dfelinto pushed me to fix this.
2016-10-13 00:38:29 -04:00
71656ac222 Gawain: fix immediate mode for multiple GL contexts
New functions activate & deactivate immediate mode. Call these when switching context and the internal VAO will be handled properly. VAOs are one of the few things *not* shared between OpenGL contexts.
2016-10-13 00:38:29 -04:00
Dalai Felinto
d5b75256e0 Fix for crash on dopesheet drawing with immediate mode (rB7a552612c) 2016-10-13 04:23:58 +00:00
Dalai Felinto
c565f7b5fd viewport: bring the manipulators 2016-10-13 02:50:42 +00:00
Dalai Felinto
165bdfb672 Fix timeline break after recent immediate mode change (rBf6e7e46f) 2016-10-13 02:19:04 +00:00
Dalai Felinto
b5c539f9fa gawain: assert for immBeginAtMost(..., 0) 2016-10-13 02:16:55 +00:00
Dalai Felinto
84ed9d9829 Draw depth even when in wire mode (for OB_RENDER)
Note: this is not working at the moment, but the logic is sound.
Since we will still change the drawing code a lot I think the commit is valid.
2016-10-13 00:36:58 +00:00
Dalai Felinto
69b1b95356 immediate mode: use new ThemeColor functions 2016-10-13 00:36:56 +00:00
Dalai Felinto
e79f302f16 gawain/immediate mode: new util functions for color uniforms 2016-10-13 00:36:52 +00:00
Dalai Felinto
f6e7e46fac Immediate mode: timeline (keyframes and range)
Part of T49043
2016-10-12 22:36:54 +00:00
683656681c BLF/OpenGL: use new matrix API when drawing text
First test of matrix API. This will eventually use the 2D part of this API, but the 3D part is ready now.

Part of T49450
2016-10-11 21:21:02 -04:00
06d4aca879 OpenGL: matrix fixes & compatibility
Was multiplying matrices backward, so concatenation was broken. Fixed!

Also a way to mix legacy matrix stacks with the new library. Just during the transition! Anything within SUPPORT_LEGACY_MATRIX will go away after we switch to core profile.

Part of T49450
2016-10-11 21:16:26 -04:00
c330f37135 quiet GPU matrix debug printing
Will be needed soon but turn it off by default.
Part of T49450
2016-10-11 14:44:12 -04:00
53d82c3e8d BLF/OpenGL: draw text with new immediate mode
Part of T49043
2016-10-11 14:36:16 -04:00
2fe7e70e92 install_deps: make c++11 building mandatory on blender2.8 branch. 2016-10-11 12:19:04 +02:00
0c43567a5a Merge branch 'master' into blender2.8 2016-10-11 12:09:59 +02:00
587a16352a Gawain: add immRect utility functions (replaces legacy glRect)
Caller is responsible for setting up vertex format, binding a shader program, and setting the color *before* calling immRect.
2016-10-10 12:31:38 -04:00
6371f8ff8a Merge branch 'master' into blender2.8
Conflicts:
	source/blender/blenloader/intern/readfile.c
	source/blender/editors/space_view3d/view3d_draw.c
2016-10-10 12:41:32 +02:00
ecbad54df9 blender 2.8; OpenGL. ui_panel_category_draw_tab with immediate API
Reviewers: dfelinto, Severin, merwin

Reviewed By: merwin

Tags: #bf_blender_2.8, #opengl_gfx

Maniphest Tasks: T49043

Differential Revision: https://developer.blender.org/D2281
2016-10-10 01:41:31 -04:00
22f59b81d7 OpenGL: remove GLSL support query (it's always supported) 2016-10-10 01:13:03 -04:00
78abbdf264 remove call to GLSL support query (it's always supported)
Reworked logic in the one place that still called this. Deleted the "GLSL not supported" fallback.
2016-10-10 01:11:03 -04:00
5fc9bed8b3 BGE: remove calls to GLSL support query (it's always supported)
Reworked logic in the few places that still called this. Deleted the "GLSL not supported" fallbacks.

Also removed some nearby checks for ARB_multitexture and OpenGL 1.1. Blender 2.77 removed checks like this, but game engine still has some.
2016-10-10 01:08:49 -04:00
7a60f889d3 OpenGL: plug new matrix system into shaders (WIP)
Built-in shaders now use uniforms instead of legacy built-in matrices. So far I only hooked this up for new immediate mode.

We use the same matrix naming convention as OpenGL, but without the gl_ prefix, e.g. gl_ModelView becomes ModelView.

Right now it can skip the new matrix stack and use the legacy built-in matrices app-side. This will help us transition gradually from glMatrix functions to gpuMatrix functions.

Still some work to do in gpuBindMatrices. See TODO comments in gpu_matrix.c for specifics.
2016-10-09 23:03:35 -04:00
e636529e33 OpenGL: Draw dividers in space_file with the new immediate mode
Thanks to @merwin for the review

Part of T49043
2016-10-09 18:20:52 +02:00
99db1b8d95 fix shaders for picky GLSL compilers
@zeauro reported this issue:
texture2DRect needs the ARB_texture_rectangle extension.
But isn't that an OpenGL 2.1 feature and should be part of GLSL 1.2+?

This should fix it, and future shaders should do something similar.
2016-10-09 10:53:03 -04:00
a2471d2b37 Gawain: validate inputs to add_attrib
Should help prevent errors when building vertex formats.
2016-10-08 16:58:06 -04:00
187d8f473a OpenGL: fix smooth point fringe
Smooth edge was fading to transparent black instead of transparent color. My bad.
2016-10-08 03:34:05 -04:00
7a552612c3 OpenGL: draw f-curve points and handles with new imm mode
Got rid of GLU and some matrix manipulation. Everything is shader driven now, drawn with point sprites.

Still plenty to do in this file...

Part of T49042 and T49043
2016-10-08 03:27:02 -04:00
25e4dc45e5 OpenGL: shaders for smooth round points
Solid color with an optional outline.

size (diameter) and outlineWidth are in pixels.
2016-10-08 03:11:53 -04:00
b071ac315c Gawain: allow immBeginAtMost, immEnd with no vertices
The whole point of BeginAtMost is to avoid counting before drawing. Sometimes the uncounted count is zero, and that's ok!
2016-10-07 23:50:52 -04:00
2a76da9ec2 draw region emboss with new immediate mode
Simple convert of drawing emboss lines to new immediate mode.

Part of T49043

Reviewers: merwin

Reviewed By: merwin

Subscribers: dfelinto

Tags: #bf_blender_2.8

Differential Revision: https://developer.blender.org/D2271
2016-10-07 23:46:52 -04:00
a398cdedfa Gawain: code cleanup & inline docs
Made function categories more clear & added more notes about how to use this API.

immEndVertex is no longer part of the public API.

Minor cleanup & organizing of recent additions.
2016-10-07 18:51:42 -04:00
b613d25354 Blender 2.8: OpenGL: replace old GL with the new immediate API in UI_draw_roundbox_gl_mode
I change UI_draw_roundbox_gl_mode to use immediate API.
The rest of the change is the call to the function.
I also make some change in UI_ThemeColor4(int colorid) for eg to make convenience to use.
I would really like to know if it's the good way to do, if yes I will make all the change in the node_daw.c after, else say me what's wrong and how to deal with color else.

Reviewers: merwin, dfelinto, Severin

Reviewed By: merwin

Subscribers: fablefox, Severin

Tags: #bf_blender_2.8, #opengl_gfx

Maniphest Tasks: T49043

Differential Revision: https://developer.blender.org/D2274
2016-10-07 15:03:21 -04:00
5c23b863f8 fix grid floor drawing assert
@dfelinto reported crash when setting grid subdivisions too low.

Code was setting color twice and Gawain was catching this. Fix is to only set regular grid color when we have regular grid lines to draw.  Then emphasized grid lines are free to set their own color further down.
2016-10-07 13:00:23 -04:00
Julian Eisel
6e358a1d06 Custom Manipulators Core Backend
This commit lands the core backend of the Custom Manipulators project onto the blender2.8 branch. It is a generic backend for managinig interactive on-screen controls that can be integrated into any 2D or 3D edito. It's also already integrated into the window-manager and editor code where needed.

NOTE: The changes here should not be visible for users at all. It's really just a back-end patch. Neither does this include any RNA or Python integration.

Of course, there's still lots of work ahead for custom manipulators, but this is a big milestone. WIP code that actually uses this backend can be found in the 'custom-manipulators' branch (previously called 'wiggly-widgets').

The work here isn't completely my own, all the initial work was done by @Antony Riakiotakis (psy-fi) and - although it has changed a lot since them - it's still the same in essence. He definitely deserves a big credit! Some changes in this patch were also done by @Campbell Barton (campbellbarton). Thank you guys!

Merge accepted by @brecht and @merwin.
Patch: https://developer.blender.org/D2232
Code documentation: https://wiki.blender.org/index.php/Dev:2.8/Source/Custom_Manipulator
Main task: https://developer.blender.org/T47343
More info: https://code.blender.org/2015/09/the-custom-manipulator-project-widget-project/
2016-10-07 16:59:55 +02:00
Julian Eisel
53d1dbbe5c Merge branch 'master' into blender2.8 2016-10-07 15:14:49 +02:00
4639664b3c Merge branch 'master' into blender2.8 2016-10-07 11:50:17 +02:00
107b585a41 OpenGL/gpencil: delete unused utility functions
Part of T49043  -- done with this file!
2016-10-07 03:17:23 -04:00
9d40c3dc32 OpenGL: draw gpencil fill with new imm mode
Part of T49043
2016-10-07 03:04:34 -04:00
1865bcd3cf OpenGL: draw 2D gpencil strokes with new imm mode
Part of T49043
2016-10-07 00:56:28 -04:00
1f6d704008 OpenGL: draw 3D gpencil strokes with new imm mode
Part of T49043
2016-10-07 00:06:20 -04:00
0fbe35c674 OpenGL: fix shader input typo 2016-10-07 00:00:12 -04:00
70a16298ea gpencil: disable / remove some legacy drawing
Want to avoid updating code we no longer use anyway.

Comments for areas to investigate or deadlines for deletion.

also some minor bool cleanup

Part of T49165
2016-10-06 22:05:28 -04:00
Julian Eisel
fc77787f6f Avoid possible compatibility issues with tmp viewport flags
We can't prevent users from using this branch, so I'd say it's reasonable to be a bit careful about what we store to files. In this concrete case we were storing a bit-flag for temporary use (only during early viewport transition) in a bit-field that's saved in files. Doing so would mean we either can't reuse this bit later or we risk breaking files (admittedly, likely in a pretty minor way). Moved the bit-flag to a new bit-field which can be removed later.
2016-10-07 03:56:32 +02:00
Dalai Felinto
49beb714c5 Viewport: support for external render engines (e.g., Cycles) with depth
(it is still a rough approach, but you can already see Cycles with Floor (when using board render or full render)
2016-10-07 01:47:30 +00:00
Dalai Felinto
4539c2b173 Viewport: floor cleanup 2016-10-07 01:47:30 +00:00
Dalai Felinto
82d069c232 Viewport: draw floor routine should not use GL_ALWAYS for depth
(talked with merwin about that, and he agrees on it, we are not supposed to write to the scene depth buffer
but we should read its depth)
2016-10-07 01:47:30 +00:00
Julian Eisel
490a938c8b Move panel for new viewport up
Makes it easier to enable it and avoids jumping of the panel when activating/deactivating it (because some panels disappear then). Also changed how panel title is drawn to make it behave like other panels.
2016-10-07 03:22:48 +02:00
Julian Eisel
1997b0f03c Use theme color for clearing viewport background
We'll obviously do more fancy stuff here later, but we don't have to look at pure blackness either ;)
2016-10-07 03:11:08 +02:00
1b4b4dfd0c OpenGL/GPencil: draw stroke-in-progress with new imm mode
We should revisit this later and use geometry shader to draw one continuous tapered stroke.

Part of T49043
2016-10-06 20:51:31 -04:00
fe654a93c7 Gawain: allow strips of 1 line, fans of 1 triangle
My initial tests were stricter than necessary, and blocked some valid uses. Fixed!
2016-10-06 20:51:31 -04:00
e01b1eac84 cleanup: C99, const, blank lines 2016-10-06 20:51:30 -04:00
Julian Eisel
553b4faac8 Merge branch 'master' into blender2.8 2016-10-07 00:22:21 +02:00
ffc46668c4 OpenGL: modernize gp_draw_strokes_edit
Single draw call per stroke!

Part of T49043
2016-10-06 17:41:23 -04:00
Dalai Felinto
ea89b4a918 Viewport: bring grid over to the new viewport
We will keep the old system working as long as we can. At the moment even the visibility flags we are getting from the old system. That will continue like this until we have decided on the new UI
2016-10-06 20:35:41 +00:00
Dalai Felinto
6b88f3118f Viewport: Starting to port over the principles of the draw flux into placeholder functions
A lot of the work still have to done on space_view3d.c for initialize the data and buffers properly, but it is a start
2016-10-06 20:35:40 +00:00
198e3a35c8 OpenGL: another built-in shader for 2D points
GPU_SHADER_2D_POINT_VARYING_SIZE_VARYING_COLOR
2016-10-06 16:32:02 -04:00
86e439e311 OpenGL: convert gp_draw_stroke_point to new immediate mode
and constify some static utility functions

Note: 2D shader will ignore position's z value, but making pos a vec3 lets us unify code in this function.
2016-10-06 14:40:47 -04:00
edcce96d97 OpenGL: more built-in GPU_SHADERs for points
No new GLSL shaders were needed! Just combined existing vertex & fragment shaders in new ways.
2016-10-06 14:20:33 -04:00
360cb87007 OpenGL: modernize more volumetric gpencil drawing
Main goal is to get rid of GLU.

Part of T49042, touches on T49043 and T49450
2016-10-06 12:45:04 -04:00
e86bd78745 Gawain: more ways to set uniform color 2016-10-06 09:37:04 -04:00
1731e94d0c draw gpencil erase cursor with new imm mode
Part of T49043 and T49450.
2016-10-05 14:05:55 -04:00
e874f3cdc5 draw gpencil sculpt cursor with new imm mode
Part of T49043 and T49450.
2016-10-05 13:45:28 -04:00
c462500618 Gawain: more ways to set uniform color 2016-10-05 13:12:18 -04:00
Dalai Felinto
5e8c4ae75b Barebones for viewport code apart from 2.7x drawing code
A new option (set in the properties region) allows the user to pick the
"new viewport" for the rendering  (in the UI: Modern Viewport).

For now we have a semi-blank file (view3d_draw.c) that can starts to take
over the drawing pipeline.

I can't guarantee we will be able to keep both drawing systems working
through the entire 2.8 development, but it should do for now.

also, we can use branches for some of the viewport development, but it's
better to keep things in 2.8 whenever we can, so people can test it.
2016-10-04 22:02:05 +00:00
3a4c1db14b fix Linux build
My mistake. Breakage reported by @mont29
2016-10-04 01:31:24 -04:00
79b8242fd1 Gawain: fix bug in immUniformColor4ubv
Reported by @kgeogeo
2016-10-04 01:24:33 -04:00
Dalai Felinto
ae44e24fed Merge remote-tracking branch 'origin/master' into blender2.8 2016-10-03 20:54:22 +00:00
55aadccbde Merge branch 'master' into blender2.8 2016-10-03 20:48:00 +02:00
72473a61b0 Fix compile errors with Alembic. 2016-10-02 20:52:25 +02:00
c50ccc8476 Merge branch 'master' into blender2.8 2016-10-02 18:53:01 +02:00
ba30b852f3 OpenGL: draw volumetric gpencil with point sprites
Transition away from GLU and legacy matrix stack. Using point sprites eliminated the need for most of the matrix math!

Depends on decent support of large aliased points. NVIDIA is good at this, must test limits on AMD & Intel systems.

Still needs proper scaling based on view zoom.

Part of T49042, touches on T49043 and T49450.
2016-10-01 18:11:58 -04:00
b8e3d81f31 OpenGL: fix point sprites
Apparently GL_POINT_SPRITE is important to GL 3.2+ compatibility profile, not just to GL 2.1 as thought.

We'll remove this during the core profile transition.
2016-10-01 17:34:41 -04:00
875d63ccb5 OpenGL: one more point shader
Added a built-in shader for points that vary both size and color.
2016-10-01 17:32:29 -04:00
5753a1462f OpenGL: new built-in shaders for drawing points
Both of these draw round points with jaggy edges, but treat color & size differently.
2016-09-30 20:44:22 -04:00
d1b21d1278 OpenGL: add support for programmable point size
And enable point sprites always. Fragment shaders can use gl_PointCoord now.
2016-09-30 19:51:04 -04:00
82648a8f91 OpenGL: make platform requirements explicit
At context startup, make sure our assumptions about the OpenGL version are true. Should match since we set up the contexts... but this is what asserts are for, to check "should"s!

Part of T49012
2016-09-30 19:10:30 -04:00
Julian Eisel
42ed1f0e3c Merge branch 'master' into blender2.8
Conflicts:
	source/blender/blenloader/intern/writefile.c
2016-09-30 01:18:41 +02:00
47bba7e15f OpenGL: draw nurbs control verts with new imm mode
patch P397 by @lichtwert + minor const by @merwin

Notes from drawvertsN function:
this used to be called twice (once for selected/active, once for unselected -- guess: to avoid state switches[color]?)
this used to be called in a loop, too (subcurves), moved the loop here to avoid multiple init stuff

Part of T49043
2016-09-29 15:23:13 -04:00
Julian Eisel
35bd833e02 Cleanup: Style 2016-09-29 21:15:27 +02:00
bbf32980b0 OpenGL: draw speaker with new immediate mode
patch P388 by @lichtwerk, I tweaked a few things.

Since speaker theme color is opaque we leave blend mode alone.

Part of T49043
2016-09-29 14:47:38 -04:00
Dalai Felinto
9bac74c27b Complement fixup for 4a1feaa555 (texture shaders)
We now multiply the alpha by the image alpha (as per severin
suggestion).
That still doesn't solve the main question of user preference drawing
black.
2016-09-28 19:11:11 +00:00
Dalai Felinto
4c7ff8fb1e Fix animation transition in region overlay not working since 4a1feaa5
We still have stills with the User Preference window, though.
2016-09-28 18:48:51 +00:00
83d5a919e2 modernize basic shader a tiny bit
"varying" is redundant here, all GS inputs & outputs vary.

Any code that uses this will be GLSL 1.3 or newer.
2016-09-27 21:25:38 +02:00
0ca2118851 safety checks in GPU shader library
If shader compilation fails, or for some other reason the shader is NULL or 0, we need to know.
2016-09-27 21:25:38 +02:00
ad32b774cb fix basic shader syntax when drawing lines
Fixed on GL 3.2+, Mac still lays an egg due to the geometry shader.
2016-09-27 21:05:48 +02:00
Julian Eisel
88aa42a6f7 Fix most toolbar panels not visible
Was likely in here since initial blender2.8 branch commit (particle removal).
2016-09-27 03:38:24 +02:00
Dalai Felinto
fc485302cc immediate mode: using texture shader for stereo drawing
(for side-by-side and top-bottom stereo modes)
2016-09-26 15:38:24 +00:00
8cff9c20ff Merge branch 'master' into blender2.8
WARNING! Full build is broken, alembic has not been merged in correctly and has some references to particle stuff.
Don't have time to tackle this now (and probably would be better if someone knowing what he's doing does it anyway).

Conflicts:
	release/scripts/startup/bl_ui/properties_particle.py
	source/blender/blenkernel/intern/library_remap.c
	source/blender/blenkernel/intern/smoke.c
	source/blender/editors/physics/particle_object.c
	source/blender/editors/physics/physics_intern.h
	source/blender/editors/physics/physics_ops.c
	source/blender/editors/space_outliner/outliner_intern.h
	source/blender/editors/space_view3d/drawvolume.c
	source/blender/makesrna/intern/rna_smoke.c
2016-09-26 17:19:03 +02:00
628ef78e8a overhaul gpuMatrix API
Complete (for our needs) 2D & 3D transformation API. Should be easy to port legacy OpenGL matrix stack-based code to this. Still needs testing.

Ported ortho, frustum, lookAt functions from Viewport FX (rB194998766c65). Kept plenty of Viewport FX code from previous commit.

Stack API and 2D routines ported from Gawain. This version uses BLI_math library so everything is licensed under GPL instead of the usual MPL.

Part of T49450
2016-09-25 19:29:45 +02:00
a731c75442 port math function from Viewport FX
mul_v4_m4v3(r, M, v) means r = M * vec4(v, 1.0)
Based on rB194998766c65
2016-09-25 19:01:18 +02:00
9bea012b8c specialize mat3 multiply routines
Same as 5c6baf1ee9 but for 3x3 matrices.
2016-09-25 18:48:11 +02:00
5c6baf1ee9 specialize mat4 multiply routines
mul_m4_m4m4(R, A, B) gives us R = AB in general. Existing code assumed the worst, that A and B both alias the output R. For safety it makes internal copies of A and B before calculating & writing R.

This is the least common case. Usually all 3 matrices differ. Often we see M = AM or M = MB, but never M = MM.

With this revision mul_m4_m4m4 is called in exactly the same way but copies inputs only when needed. If you know the inputs are independent of the output use the "uniq" variant to skip the saftety checks.
2016-09-25 14:27:48 +02:00
addc666999 constify BLI_math_matrix inputs
GPU_matrix needs this very soon, and it's good practice in general.

also sprinkled in some TODOs for later
2016-09-24 16:21:38 +02:00
36bbdf142c OpenGL: fix new shader for Mac
Follow-up to rB4a1feaa5558ed60388fd3be41db74fbc54f2ab08
2016-09-23 18:16:45 +02:00
7fc2e333bb small merge fix
Follow-up to rB1dfb89d22930
2016-09-23 18:12:24 +02:00
Julian Eisel
1dfb89d229 Merge branch 'master' into blender2.8
Conflicts:
	intern/ghost/intern/GHOST_ContextCGL.mm
	intern/ghost/intern/GHOST_WindowCocoa.mm
	source/blender/makesrna/intern/rna_main.c
2016-09-23 01:40:19 +02:00
Dalai Felinto
4a1feaa555 immediate mode: Triple Buffer and two new shaders for TEXTURE_2D and TEXTURE_RECT
Use the same vertex shader for both fragment shaders
2016-09-22 13:40:33 +00:00
1d469f3780 OpenGL: remove double precision matrix functions
Proper fp64 is a GL 4.x feature. Pretending to support it in our API is just clutter.
2016-09-22 12:19:24 +02:00
0e7c3dfe75 OpenGL: matrix code from viewport-fx
Bringing over whole files from rB194998766c65
2016-09-22 12:11:40 +02:00
825150605e GPU_basic_shader uses GLSL by default
switch back to old mode at runtime:
blender --enable-legacy-basic-shader
2016-09-21 20:24:02 +02:00
9047717b3f Gawain: support triangle strips & fans in immediate mode
fixes crash in Vertex Paint (color picker)
2016-09-21 15:47:08 +02:00
0f759da370 Gawain: batch drawing works
Forgot to tell OpenGL which shader program the batch is using. Now it works!
2016-09-20 18:03:59 +02:00
Dalai Felinto
284398e517 immediate mode refactor: walk navigation cross 2016-09-20 14:50:24 +00:00
Dalai Felinto
04bc828fb6 gawain update: immAttribute for 2i 2016-09-20 14:50:20 +00:00
Dalai Felinto
6ebf5c18c3 immediate mode refactor: fly navigation square 2016-09-20 14:47:14 +00:00
d3365c5c72 OpenGL: fix GPU_SHADER_TEXT on non-Mac
Developed on Mac and committed quickly.. oops
2016-09-20 16:13:01 +02:00
Julian Eisel
42ad5952ff Quiet warning with -Wformat-signedness
Is actually a redundant cast since Blender uses -funsigned-char, however I think it's fine to be explicit about it in new code so cast is required to make compiler happy. Am not a fan of -funsigned-char anyway...
2016-09-20 14:23:15 +02:00
34bd89a9f6 OpenGL: draw_view_axis with new immediate mode
Changed drawing to use smooth lines, and to fade away when axis points toward / away from screen. (transform manipulators do this already)

Also fixed a nearby (but unrelated) missing immUnbindProgram.

Part of T49043
2016-09-17 15:52:32 +02:00
e21853abb9 OpenGL: streamline font rendering
Ignore texture matrix in the shader, stop messing with texture matrix in BLF code.

Use linear screen-space interpolation instead of perspective.

Avoid redundant call to glMatrixMode.
2016-09-17 13:54:30 +02:00
1b1275f0db add GPU_SHADER_TEXT for font rendering
With USE_GLSL enabled, GPU_basic_shader(TEXTURE|COLOR) always rendered black. New shader uses a solid color + alpha channel of texture (which in our case is a font glyph). See fragment shader for details.

I prefer this approah -- multiple shaders that each do one thing well (and are easy to read/write/understand), instead of one shader that can do many things given the right options.
2016-09-17 13:33:48 +02:00
c3034afa58 OpenGL: simplify basic_shader_bind
No need to enable/disable texturing with GLSL, just use textures in the fragment shader.
2016-09-17 13:33:48 +02:00
834cb93f40 Blender 2.8: Fix some strict aspects on Linux 2016-09-16 17:18:19 +02:00
d96b8e168f Merge branch 'master' into blender2.8 2016-09-16 17:09:28 +02:00
76c99f361f Gawain improvements
Fixed compile error in debug build (thanks mont29)

Renamed some functions for consistency.

New features:

Create a Batch with immediate mode! Just use immBeginBatch instead of immBegin. You can keep the result and draw it as many times as you like. This partially replaces the need for display lists.

Copy a VertexFormat, and create a VertexBuffer using an existing format.

Resize a VertexBuffer to a different number of vertices. (can only resize BEFORE using it to draw)
2016-09-15 21:45:10 +02:00
5eddb80513 Extend Gawain to use Blender's built-in shaders
Was already done for immediate mode, but rearranged code to make a clean separation. Cleaned up #includes for code that uses this feature.

Added same for batched rendering.
2016-09-15 18:41:28 +02:00
39f7a81176 Gawain: batch rendering API
Follow-up to rBddb1d5648dbd

API is nearly complete but untested.

1) create batch with vertex buffer & optional index buffer
2) choose shader program
3) draw!
2016-09-15 16:51:10 +02:00
0d54d32dd6 Gawain: simplify attrib binding API
This API is used internally by the immediate and batch drawing systems.
2016-09-15 12:57:07 +02:00
2fb5a959e9 Gawain: delete bind_attrib_locations
This function modifies the GL program object, which reduces our ability to share a shader among meshes with different vertex formats. Recommended approach is to use get_attrib_locations.
2016-09-15 12:24:06 +02:00
110d68ca1d Gawain: flesh out VertexBuffer
create, specify, fill with data
2016-09-14 16:29:01 +02:00
df7be04ca6 fix Mac build with Xcode 8
Small issues in GHOST
- use NSApplicationDelegate protocol for our app delegate
- make sure NSApp is initialized before using
2016-09-14 16:29:01 +02:00
54b00657ca Gawain: fix Windows compile error
MSVC was NOT happy about uint64_t, now it is.
2016-09-13 03:21:16 -04:00
1b5b899228 OpenGL: add built-in GPU_SHADER_3D_DEPTH_ONLY
We’re discussing several techniques that require a depth pre-pass.
2016-09-13 02:51:38 -04:00
ddb1d5648d Gawain: geometry batches (unfinished)
Vertex Buffer to store vertex attribute data.
Element List (AKA Index Buffer) to select which vertices to use.
Batch combines these into an object that can be built once then drawn
many times.

Porting over from the C++ version… Most of this C code is compiled but
unused. Some of it is not even compiled. Committing now in case I’m
lost at sea.
2016-09-13 02:41:43 -04:00
b6bd299359 Gawain: reorganize source code
Put Gawain source code in a subfolder to make the boundary between the
library and the rest of Blender clear.

Changed Gawain’s license from Apache to Mozilla Public License. Has
more essence of copyleft — closer to GPL but not as restrictive.

Split immediate.c into several files so parts can be reused (adding
more files soon…)
2016-09-13 02:18:33 -04:00
18d49a8283 Gawain: add immBeginAtMost
immBegin requires us to know how many vertices will be drawn. Most times this is fine, but sometimes it can be tricky. Do we make the effort to count everything in one pass, then draw it in a second?

immBeginAtMost makes this simple. Example: I'll draw at most 100 vertices. Supply only 6 verts and it draws only 6.

Any unused space is reclaimed and given to the next immBegin.
2016-09-06 16:56:08 -04:00
031c5bad87 Gawain: fix GL_POINTS in immediate mode
Was using GL_NONE to mean "no primitive" but GL_NONE and GL_POINTS are both defined as 0x0000.

Introducing PRIM_NONE = 0xF which does not clash with any primitive types.
2016-09-06 15:45:10 -04:00
3c29aad787 Merge branch 'master' into blender2.8
Conflicts:
	intern/cycles/blender/blender_particles.cpp
	source/blender/blenkernel/intern/particle.c
	source/blender/gpu/intern/gpu_shader.c
2016-09-04 16:41:06 +02:00
498583844f OpenGL: use new uniform color functions
Color picker code motivated these convenience functions. looks much better now.
2016-08-27 14:14:01 -04:00
9d3813e602 Gawain: convenience functions for uniform color
Application code can pass ubytes, Gawain converts to float vec4 expected by shader.

For now the conversion is simple linear. We can add sRGB support later if needed.
2016-08-27 14:10:37 -04:00
42bbfe7f0a OpenGL: draw grid floor & axes with new immediate mode
Significant rewrite with some improvements.

Maintain visual hierarchy of the grid:
- emphasized lines draw atop normal lines
- axes draw atop all lines (same as before)

Draw axes only once, not twice.

Return early if nothing to draw.

Single draw call for the default case (grid floor with X and Y axes).

Z axis needs a second draw call because it uses 3D coordinates.

Part of T49043
2016-08-26 01:12:44 -04:00
060bf1bd28 OpenGL: draw empties without GLU
Also reduced number of matrix ops by generating final positions directly.

Also removed a display list (deprecated in modern GL).

Tried to reuse sinval & cosval tables but those values are skewed (last value repeats first value, middle values are squished to compensate). Went with sinf & cosf instead.

Part of T49042
2016-08-25 13:45:39 -04:00
da36b447c7 OpenGL: de-GLU the transform manipulator
Part of T49042

Also reduced the number of matrix ops.

TODO: replace glBegin/glVertex with new immediate mode
2016-08-24 23:47:45 -04:00
1fc1fd8372 OpenGL: draw area resize handle with new immediate mode
The little grabby handle in the corner of an area. Now uses 1 draw call
instead of 6.

Also one version of the (+) icon to show a hidden region. Why do we
have multiple versions of this?

Fixed a harmless signed/unsigned error.

Fixed a GL state error that prematurely disabled blending.

Added imm_draw_filled_circle function, which can be used for drawing
other widgets.

Work toward T49042 and T49043
2016-08-22 23:39:42 -04:00
069569f820 Merge branch 'master' into blender2.8
In addition to pack of conflicts listed below, also had to comment out particle part of new Alembic code... :/

Conflicts:
	intern/ghost/intern/GHOST_WindowWin32.cpp
	source/blender/blenkernel/BKE_effect.h
	source/blender/blenkernel/BKE_pointcache.h
	source/blender/blenkernel/intern/cloth.c
	source/blender/blenkernel/intern/depsgraph.c
	source/blender/blenkernel/intern/dynamicpaint.c
	source/blender/blenkernel/intern/effect.c
	source/blender/blenkernel/intern/particle_system.c
	source/blender/blenkernel/intern/pointcache.c
	source/blender/blenkernel/intern/rigidbody.c
	source/blender/blenkernel/intern/smoke.c
	source/blender/blenkernel/intern/softbody.c
	source/blender/depsgraph/intern/builder/deg_builder_relations.cc
	source/blender/gpu/intern/gpu_debug.c
	source/blender/makesdna/DNA_object_types.h
	source/blender/makesrna/intern/rna_particle.c
2016-08-21 13:18:26 +02:00
be2bc7e0f6 OpenGL: draw color picker wheel with new immediate mode
Includes new imm_draw_lined_circle function that can be used for other
widgets.

Part of T49043
2016-08-20 15:40:08 -04:00
eb717ee979 Gawain: more immediate mode functions
Scanned Blender code for commonly used glVertex, glColor functions.
Implemented immVertex, immAttrib versions of these to ease transition
away from legacy OpenGL.
2016-08-20 15:09:32 -04:00
1e6b3ef1a1 cleanup: unused OpenGL utility code
Keeping unused gla2D code because it might be useful, or inspire
something useful, for Blender 2.8 development.

Also removed an old Mac driver bug workaround. Disabled this before the
2.77 release and nobody has complained.
2016-08-20 13:57:17 -04:00
7e02d335c0 OpenGL: don't poll for errors, rely on KHR_debug
Errors are caught & reported by our GL debug callback. This gives us way more useful information than sporadic calls to glGetError.

I removed almost all use of glGetError, including our own GPU_ASSERT_NO_GL_ERRORS and GPU_CHECK_ERRORS_AROUND macros.

Still used in rna_Image_gl_load because it passes unvalidated input to OpenGL functions.

Still used in gpu_state_print_fl_ex as an exception handling hack -- will rewrite this soon.

The optimism embodied by this commit will not prevent OpenGL errors. We need to analyze what would cause GL to fail at certain points and proactively intercept these failures. Or guarantee they can't happen.
2016-08-19 00:52:52 -04:00
d8f036efd6 OpenGL: draw NDOF guide with new immediate mode
This is the rotation pivot guide for 3D mouse input.

Work toward T49043
2016-08-16 21:54:50 -04:00
6b34eed217 Gawain: add v functions to immediate mode
Legacy OpenGL has a matching Vertex3fv for every Vertex3f, and so on. Add something similar to Gawain, just for a few common functions. Might add more as the need arises.
2016-08-16 21:45:17 -04:00
b92d76000d fix #includes for GPU debug
Can now build release and debug.

Close to final version in master (which took several commits).
2016-08-16 17:14:42 -04:00
b8f27b2514 OpenGL: shaders for simple 3D drawing
These are intended for very simple drawing. No lighting etc.

Shares some fragment code with the 2D shaders.

Similar to their 2D counterparts, but are not combined because of
future plans for separate 2D & 3D matrix stacks.
2016-08-16 14:58:53 -04:00
8619e09107 OpenGL: tweak legacy 2D shader
EXT_gpu_shader4 lets us say “noperspective” in GLSL #version 120 just
like in later GLSL.

Mac shader now matches modern GLSL available on other platforms.
2016-08-15 21:44:44 -04:00
23d7ae1843 OpenGL: backtrace on errors (--debug-gpu)
Backtrace so we can pinpoint where the GL error came from. Then fflush
on severe errors in case it's severe enough to crash Blender.
2016-08-15 04:00:59 -04:00
f1ad3483af get latest OpenGL version on Windows + AMD
When we ask for GL 3.2 compatibility profile:
AMD (Radeon HD 6970) gives us exactly this version
NVIDIA (Quadro K600) gives at least this version
Still need to check Intel behavior

We want *at least* the version requested, plus more recent features if
available.

Both GPUs tested & mentioned above are capable of GL 4.5. With this
commit they both give 4.5 to Blender.
2016-08-14 01:27:00 -04:00
91f04b82a5 early out for ortho grid drawing
Helps most when real-world units are used.

Previous code started at the smallest visible unit (e.g. Inches) then
followed to Feet, Yards, Chains, Furlongs, Miles. Always to the largest
unit of the set, even though most would be way off screen.

New code knows whether it skipped any grid lines for the next unit to
fill in, can stop once all lines are on screen.
2016-08-13 22:33:49 -04:00
90c4ad7387 Mac fixes for new ortho grid drawing
Previous commit works on Windows, found some issues after trying on Mac.

- benign warnings about && within ||
- replaced nearbyint() with round() to avoid floating point environment
surprises
- remquo function appears to be broken on Mac (!) results were way way
off. Replaced with simple division.
- minor tweaks to debug output
2016-08-13 22:13:24 -04:00
db5ad6a79e draw ortho grid with new immediate mode
Work toward T49043, with a side of client vertex arrays.

Not a straightforward port from glVertex to immVertex since Gawain needs
to know how many vertices we'll be drawing *before* we start drawing.

Fixed these not-so-great aspects of grid drawing:
- coarse grids would draw atop some lines from the finer grids
- visible axes would draw atop lines from coarse grid
- axes were drawn even if they weren't in view
- terrible misuse of vertex arrays
- each line issued its own draw call

New code draws each line exactly once. The entire grid is one draw call.

Bonus: I had to / got to learn how the units system works!
2016-08-13 18:14:45 -04:00
e36af2c257 Gawain: increase size of immediate mode buffer
New value of 4MB should handle our needs without taking up too many GPU
resources.

Old value of 1KB was for observing what happens when the buffer fills up
and we need to flush and start a new one.
2016-08-13 16:31:44 -04:00
dfbc51f764 cleanup: ortho grid drawing
Getting this ready for Gawain treatment.

Removed setlinestyle(0) -- solid lines are the default,  hope this isn't
really needed.

Eliminated redundant math.

Arithmetic is still double precision, passed to OpenGL as single
precision. Even though it said GL_DOUBLE before, values were converted
to GL_FLOAT internally.

Use C99-isms for declaring variables close to where they're used.

Minor whitespace tweaks.
2016-08-12 17:20:21 -04:00
4565f3d0c8 use new immediate mode for UI_draw_box_shadow
This serves as a good example of the Gawain API. (I’ve thought of a
better way to draw drop shadows, but that can wait!)

Part of T49043.

This is what I had in mind for D1753.
2016-08-11 01:06:17 -04:00
7664d947b3 Gawain: allow partial vertex specification
If you don’t specify a vertex’s color, it will use the color of the
previous vertex. Similar for all other attributes.

This matches the legacy behavior of glColor, glNormal, etc. *except* in
Gawain the first vertex of each immBegin must be fully specified. There
is no “current” color in the new system.
2016-08-11 00:11:48 -04:00
4aadf7331e Gawain: tweak immediate mode API
Should be simpler to use now.

Made vertex format structure private. New immVertexFormat() function
clears and returns the format. Devs can start with add_attrib(format...)
and not have to clear it first.

immBindProgram automatically packs the vertex format if needed.

Updated 3D cursor drawing to use new API.
2016-08-10 18:01:04 -04:00
f537d96286 Merge branch 'blender2.8' of git.blender.org:blender into blender2.8 2016-08-10 16:09:08 -04:00
adbbcefe57 Gawain: fewer glEnable/DisableVertexAttribArray calls
Track previously enabled attrib locations so we can call OpenGL only
when needed.

Same result, fewer GL calls.
2016-08-10 16:08:32 -04:00
8fd4a8ab5d Merge branch 'master' into blender2.8
Conflicts:
	source/blender/blenkernel/intern/library.c
	source/blender/blenkernel/intern/particle.c
2016-08-10 15:06:40 +02:00
e7a32365cf Gawain: map vertex format to shader inputs
glBindAttribLocation does not take effect until the program is
re-linked. In other words I was doing it wrong!

New code gets attrib locations from program, then remembers the attrib
-> location mapping for subsequent draw calls.

The program and VertexFormat are not modified (makes threading and reuse
easier).
2016-08-10 04:45:23 -04:00
5320a0ad9b Gawain: fix compiler warnings
properly typed function parameters
pointer casting & arithmetic
ptrdiff_t formatting
2016-08-10 02:38:51 -04:00
e4e1b0c7d3 OpenGL: invalidate buffers the modern way
There are older ways to give OpenGL hints about buffer invalidation, but
glInvalidateBufferData does exactly what we want. Use this function when
OpenGL 4.3 is available (Windows and proprietary Linux drivers).

Part of Gawain immediate mode.
2016-08-09 17:17:34 -04:00
d3349e5e3f Merge branch 'master' into strand_editmode 2016-08-09 15:52:02 +02:00
f3d65ad23c OpenGL: debug context on Windows
Enable based on --debug-gpu at the command line. Linux already works
this way.
2016-08-09 03:29:49 -04:00
b7f3fb0ef9 Gawain: fix Windows build error
MSVC is more strict than  gcc or clang about pointer arithmetic. Also
fixed pointer cast warnings.
2016-08-09 02:27:54 -04:00
a77e77599d OpenGL: enhance debug output
When running blender --debug-gpu

Display which debug facilities are available. One of these, in order of preference:
- OpenGL 4.3
- KHR_debug
- ARB_debug_output
- AMD_debug_output

All messages are logged now, not just errors. Will probably turn some of these off later.

GL_DEBUG_OUTPUT_SYNCHRONOUS lets us break on errors and backtrace to the exact trouble spot.

Callers of GPU_string_marker no longer pass in a message length, just the message itself (null terminated).

Apple provides no GL debug logging features.
2016-08-09 01:29:58 -04:00
9893153799 OpenGL: fix FBO error messages
Old code had a mix of framebuffer error codes from OpenGL ES, EXT_framebuffer_object, and desktop GL. We use desktop GL (or ARB_framebuffer_object which acts just like GL 3.x) so I made it compatible with that.

Changed messages to the actual GL_FRAMEBUFFER_XXX symbols. These are less friendly and more accurate. Can easily look up what an error means, unfiltered by what a Blender dev thinks it means.

Kept ES error codes around in case we support that one day. Just flip the #if or use a compile-time option.
2016-08-08 18:02:40 -04:00
39259fc8ab draw 3D cursor with new immediate mode
Replace legacy OpenGL with Gawain. Use shaders instead of fixed
function pipeline.

This simple UI element is shown at startup so is easy to verify things
are working. It also serves as a good example for people converting
other parts of the code.

Part of T49043
2016-08-08 15:45:18 -04:00
c73e4e99a5 OpenGL: simple 2D shader with flat color
Flat color means each primitive will use color from the provoking
vertex.
2016-08-08 04:56:02 -04:00
4214b3c44a OpenGL: simplify 3D cursor drawing
Use simple alternating colored lines instead of stippled overdraw.

Reimplement circ function to not use deprecated GLU (T49042). It also
leaves matrix stack untouched.

Remove unused circf function.
2016-08-08 03:17:24 -04:00
6c65e5a00c GPU: bind builtin shader for immediate mode
immBindBuiltinProgram extends Gawain’s immBindProgram to use Blender’s
library of built-in shader programs.

It uses imm prefix instead of GPU_ so people won’t be tempted to call
GPU_unbind_program() afterward.

From my understanding, Apache code is not allowed to call GPL code, so
this function needs to be in the GPU lib.
2016-08-07 22:11:45 -04:00
8e99eec026 Gawain: immediate mode set uniforms for active program
Start simple with vec4 uniforms. Add more later.
2016-08-07 21:30:02 -04:00
11ffbfb36a Gawain: bind a shader for immediate mode
How to use:
1) set up vertex format
2) bind a shader
3) draw with immBegin … immEnd
4) unbind shader

TODO: expand this a little, so we can send uniform values to the bound
shader.
2016-08-07 01:35:42 -04:00
6fea42d677 Gawain: initialize & destroy immediate mode
TODO: make this work better with multiple OpenGL contexts
2016-08-07 01:30:45 -04:00
f27516839f fix simple 2D built-in shaders
Forgot the projection matrix.
2016-08-07 01:26:29 -04:00
0ea8430549 Gawain: legacy Mac VBO workarounds
glMapBufferRange is a wonderful function that doesn’t exist on GL < 3.0.

Use the APPLE_flush_buffer_range extension on Mac. It offers several of
glMapBufferRange’s benefits.

Use older “black arts” method to orphan VBOs when we are done with
them. In modern OpenGL this behavior is more obvious.

Add APPLE_flush_buffer_range to Mac requirements. Every GPU is
supported. T49012
2016-08-07 01:05:49 -04:00
e7f9614f07 Gawain: legacy OpenGL compatibility
Apple invented VAOs and exposes them via an extension in legacy GL.
Other platforms use at least GL 3.0 which has VAOs built in.

QUADS were removed from core profile but are useful for immediate-mode
drawing. We’ll have to implement our own QUAD drawing before switching
to core profile.
2016-08-07 01:05:49 -04:00
6b21d22c60 Gawain: fix VAO and VBO binds
Immediate mode no longer leaves its internals bound after use. Part of
transition from a simple prototype app to non-simple Blender, which has
lots of other parts using OpenGL.
2016-08-07 01:05:49 -04:00
a55c5dbcc4 Gawain: flesh out immediate mode
More ways to send values via immAttrib:
2D float vectors
3 & 4 component ubytes (for colors mostly)

New immVertex functions that act more like familiar glVertex. We’ll
find a balance between making this API convenient and keeping it small.
2f and 3f are enough for now.
2016-08-07 01:05:49 -04:00
3eae585791 Merge branch 'master' into blender2.8 2016-08-06 12:57:21 +02:00
9843921288 Merge branch 'master' into blender2.8
Conflicts:
	release/scripts/startup/bl_ui/properties_particle.py
	release/scripts/startup/bl_ui/properties_physics_cloth.py
	release/scripts/startup/bl_ui/properties_physics_dynamicpaint.py
	release/scripts/startup/bl_ui/properties_physics_softbody.py
	source/blender/blenkernel/BKE_library.h
	source/blender/blenkernel/BKE_particle.h
	source/blender/blenkernel/intern/cloth.c
	source/blender/blenkernel/intern/library.c
	source/blender/blenkernel/intern/library_query.c
	source/blender/blenkernel/intern/particle_system.c
	source/blender/blenkernel/intern/scene.c
	source/blender/blenkernel/intern/softbody.c
	source/blender/blenloader/intern/readfile.c
	source/blender/blenloader/intern/versioning_270.c
	source/blender/editors/space_file/filesel.c
	source/blender/editors/space_outliner/outliner_intern.h
	source/blender/makesdna/DNA_ID.h
	source/blender/makesdna/DNA_object_force.h
	source/blender/makesdna/DNA_particle_types.h
	source/blender/makesrna/intern/rna_particle.c
	source/blender/makesrna/intern/rna_sculpt_paint.c
	source/blender/makesrna/intern/rna_smoke.c
	source/blender/makesrna/intern/rna_space.c
2016-08-06 12:45:03 +02:00
4571fdde0e OpenGL: transition to ARB FBOs, remove runtime checks
ARB_framebuffer_object replaces several related EXT extensions. The ARB
version pulls GL 3 FBO features into GL 2.1, useful for Mac platform.
Its functions and enums have no ARB suffix so transition to modern GL
will be seamless!

Extension is checked at startup, so is guaranteed to be true at runtime.

Part of T49012
2016-08-04 21:11:45 -04:00
58697444bb OpenGL: remove runtime check for EXT_gpu_shader4
It’s checked at startup, so is guaranteed to be true at runtime.

Part of T49012
2016-08-04 20:27:24 -04:00
32757d488f OpenGL: require EXT_gpu_shader4 & ARB_framebuffer_object on Mac
Mac’s OpenGL version is furthest away from our target of GL 3.2. This
commit brings Mac closer to other platforms, so that our shaders and
other code don’t diverge too much during development.

According to Apple’s OpenGL matrix these useful extensions are
available on all GPUs that will be able to run Blender 2.8.

Only checked in debug builds; we might need something more forceful.

Part of T49012
2016-08-04 20:25:47 -04:00
396dd82428 OpenGL: add simple shaders for 2D drawing
The first two of several new simple built-in shaders (will test these
before adding more). These are intended for the new immediate mode API,
but you can use them just like any built-in GPUShader.

Due to limitations on different platforms, shaders need to work with
GLSL versions 120, 130 and 150. Final Blender 2.8 will be pure #version
150.
2016-08-04 15:59:38 -04:00
797f1896fa OpenGL: immediate mode work-alike
Introducing an immediate mode drawing API that works with modern GL 3.2
core profile. I wrote and tested this using a core context on Mac.

This is part of the Gawain library which is Apache 2 licensed. Be very
careful not to pull other Blender code into these files.

Modifications for the Blender integration:
- prefix filenames to match rest of Blender’s GPU libs
- include GPU_glew.h instead of <OpenGL/gl3.h>
- disable thread-local vars until we figure out how best to do this
2016-08-04 15:36:20 -04:00
42d816a3d9 Blender 2.8 requires Mac OS 10.7 or later
MacOS 10.7 “Lion” was the first to implement OpenGL 3.2, which will be
required to run Blender 2.8.

Minimum OS version was unspecified before.
2016-08-04 03:13:20 -04:00
3d9cc4d3f1 support automatic GPU switching on Mac
First attempt. On my laptop (Intel + nVidia) Blender still switches to
nVidia at launch time.
2016-08-04 03:08:13 -04:00
b3cb7e2652 OpenGL: on Mac use legacy 2.1 or core 3.2
This implements Mac part of T49012.

Removed options for EGL, ES2, compatibility profile. None of these
exist on Mac platform.

Create a GL 3.2 core context when requested at build time. Old code
just pretended to support core profile.
2016-08-04 02:36:46 -04:00
0d1f0116fe OpenGL: Blender 2.8 on X11 requires GL 3.0
Implements the Linux part of T49012.

Simplify the options for context creation. No options for legacy GL or EGL or ES2. Select 3.2 CORE or COMPATIBILITY profile at build time.

If that fails, use a GL 3.0 context. This keeps Mesa supported while we work on full 3.2 core elsewhere in the code.
2016-08-03 17:58:24 -04:00
eccf5a6f81 OpenGL: Blender 2.8 on Windows requires GL 3.2
This greatly simplifies the options for context creation. No options for
legacy GL or EGL or ES2. Select CORE or COMPATIBILITY profile at build
time.

OpenGL 3.2 core profile will be our final target on all platforms. Until
all our code is ready we can use 3.2 compatibility profile or "legacy"
GL 2.1 on platforms that don't support compatibility profile.
2016-08-03 14:46:29 -04:00
251349c3c2 Merge branch 'master' into blender2.8 2016-07-28 12:00:58 +10:00
5a7efaf287 Added "show_brush" option for hair edit settings, expected by common paint UI.
This setting has no effect yet for hair editing, but the UI script expects it.
2016-07-27 09:50:45 +02:00
b1532493c2 Merge branch 'master' into blender2.8
Conflicts:
	source/blender/blenkernel/BKE_particle.h
	source/blender/blenkernel/intern/library.c
	source/blender/blenkernel/intern/particle.c
2016-07-25 15:07:17 +02:00
f3bc942370 Merge branch 'master' into strand_editmode 2016-07-25 09:33:48 +02:00
07cffae7ea Fix for uninitialized v_mirr variable when using edge strokes with mirroring. 2016-07-20 09:44:39 +02:00
1b431c3cfe Merge branch 'master' into strand_editmode 2016-07-19 11:42:52 +02:00
dd1211ecb8 Merge branch 'master' into strand_editmode 2016-07-19 10:32:23 +02:00
9186b9ae48 Merge branch 'master' into blender2.8 2016-07-18 19:25:44 +10:00
1d28579daf Merge branch 'mesh_samples' into strand_editmode 2016-07-14 09:59:52 +02:00
48fc8b76b2 Merge branch 'master' into strand_editmode 2016-07-14 09:57:38 +02:00
bd4ca21b54 Merge branch 'master' into mesh_samples 2016-07-14 09:56:58 +02:00
28270f0953 Replace the deprecated TessFace usage for mesh sampling by LoopTri.
Also make sure a valid generator instance for random sampling is always
returned, regardless of triangle counts.
2016-07-14 09:55:18 +02:00
2f596756b7 Merge branch 'master' into strand_editmode 2016-07-13 16:50:23 +02:00
cfbd605567 Merge branch 'master' into blender2.8
Conflicts:
	intern/cycles/blender/addon/ui.py
	source/blender/blenkernel/BKE_particle.h
	source/blender/blenkernel/intern/dynamicpaint.c
	source/blender/blenkernel/intern/library.c
	source/blender/blenkernel/intern/object.c
	source/blender/blenkernel/intern/particle.c
	source/blender/blenkernel/intern/particle_distribute.c
	source/blender/blenkernel/intern/texture.c
	source/blender/editors/object/object_add.c
	source/blender/editors/object/object_relations.c
	source/blender/editors/physics/particle_edit.c
	source/blender/editors/physics/particle_object.c
	source/blender/editors/transform/transform_snap_object.c
2016-07-12 00:07:44 +02:00
56ad4520cd Merge branch 'master' into strand_editmode 2016-07-09 09:09:47 +02:00
4e95617769 Merge branch 'master' into strand_editmode 2016-07-05 09:53:24 +02:00
71a57a37b2 Merge branch 'master' into blender2.8 2016-06-29 17:58:39 +02:00
f45fbf4b83 Merge branch 'master' into blender2.8 2016-06-29 17:45:16 +02:00
b90b02a480 Merge branch 'master' into blender2.8 2016-06-28 21:21:11 +10:00
5ae6a3b6b6 Merge branch 'master' into blender2.8 2016-06-28 21:10:11 +10:00
548dfdbd31 Merge branch 'master' into mesh_samples 2016-06-28 11:17:44 +02:00
0f927d6eca Fix stupid merge error. 2016-06-27 16:07:38 +02:00
cbce7fef16 Merge branch 'master' into blender2.8
Conflicts:
	source/blender/blenkernel/intern/pointcache.c
	source/blender/makesrna/intern/rna_main_api.c
	source/blender/makesrna/intern/rna_particle.c
2016-06-27 15:59:01 +02:00
73140ca283 Merge branch 'master' into strand_editmode 2016-06-27 10:52:10 +02:00
c2dc77983d Merge branch 'master' into blender2.8
No changes, just resolve conflicts.
2016-06-23 08:04:19 +10:00
3b0a5dd158 Merge branch 'master' into blender2.8 2016-06-23 07:52:58 +10:00
97ee7f8609 Merge branch 'master' into blender2.8
Conflicts:
	source/blender/blenloader/intern/readfile.c
	source/blender/editors/physics/particle_edit.c
2016-06-22 13:12:44 +02:00
48c58bd913 Merge branch 'master' into blender2.8 2016-06-21 12:14:49 +10:00
2cfff95ba3 Merge branch 'master' into blender2.8 2016-06-15 17:41:22 +10:00
eedcc4a6a0 Merge branch 'master' into blender2.8 2016-06-15 17:29:11 +10:00
5864269b2c Merge branch 'master' into blender2.8 2016-06-13 19:26:56 +10:00
46e1d85e61 Reduce conflicts be keeping same indent-level as master 2016-06-10 05:51:34 +10:00
c96d4ec644 Merge branch 'master' into blender2.8 2016-06-10 05:46:29 +10:00
a151806698 Merge branch 'master' into blender2.8 2016-06-10 05:17:33 +10:00
10d57f991b Merge branch 'master' into blender2.8 2016-06-10 05:15:06 +10:00
4b99958ca1 Remove particle expander
Having this caused buffer-overrun on startup
2016-06-07 18:27:31 +10:00
1e5735ab99 World space switch for BI nodes.
At the moment light shading in Blender is produced in viewspace. Apparently, that's why
shader nodes work with normals in camera space. But it is not convenient for artists.
The more convenient approach is implemented in Cycles where normals are represented in world space.
Blend4Web Team designed the engine keeping in mind shader parameters readability,
so normals are interpreted in world space as well. And now our users have to use some tweaks, like
empty node group with the name "Replace", which is replacing one input by another on the engine side
(replacing working configuration in Blender Viewport by the configuration that has the same behavior in the engine).

This patch adds the ability to switch to world space for normals and lamp vector in BI and Viewport.
This patch is very important to us and we crave to see this patch in Blender 2.7 because
it will significantly simplify Blend4Web material creation workflow.

{F315547}

{F315548}

Reviewers: campbellbarton, brecht

Reviewed By: brecht

Subscribers: homyachetser, Evgeny_Rodygin, AlexKowel, yurikovelenov

Differential Revision: https://developer.blender.org/D2046
2016-06-07 10:21:55 +02:00
5750549f6a Cleanup: warnings 2016-06-07 18:16:03 +10:00
ed6f86a510 Merge branch 'master' into blender2.8 2016-06-07 18:06:46 +10:00
24d29f2e50 Merge branch 'master' into blender2.8
Conflicts:
	source/blender/blenkernel/intern/particle.c
	source/blender/editors/transform/transform_snap_object.c
2016-06-07 09:59:26 +02:00
11af9e9a5b Merge branch 'master' into blender2.8
Conflicts:
	intern/cycles/blender/blender_curves.cpp
	intern/cycles/blender/blender_particles.cpp
	source/blender/depsgraph/intern/builder/deg_builder_relations.h
	source/blender/depsgraph/intern/depsgraph_build.cc
2016-06-01 14:34:11 +02:00
faec430914 Merge branch 'master' into blender2.8
Conflicts:
	intern/cycles/blender/blender_curves.cpp
	source/blender/blenkernel/intern/dynamicpaint.c
	source/blender/blenkernel/intern/particle.c
	source/blender/blenloader/intern/versioning_270.c
	source/blender/editors/physics/particle_edit.c
	source/blender/editors/transform/transform_snap_object.c
	source/blender/editors/util/undo.c
	source/blender/makesrna/intern/rna_object_force.c
2016-05-24 16:48:10 +02:00
f85745b17b Flat shading for basic shader
The purpose of the patch is to replace deprecated  glShadeModel.

To decrease glShadeModel calls I've set GL_SMOOTH by default

Reviewers: merwin, brecht

Reviewed By: brecht

Subscribers: blueprintrandom, Evgeny_Rodygin, AlexKowel, yurikovelenov

Differential Revision: https://developer.blender.org/D1958
2016-05-16 11:13:21 +03:00
b4a721af69 Merge branch 'temp_remove_pointcache' into blender2.8 2016-05-02 11:00:34 +02:00
5aa19be912 Merge branch 'temp_remove_particles' into blender2.8 2016-05-02 11:00:26 +02:00
735727e2b8 Removed DNA for point caches. 2016-04-30 14:20:13 +02:00
ac30a04b27 Removed point cache blenkernel code. 2016-04-29 15:03:58 +02:00
181d095f50 Removed PointCache RNA struct definition and uses. 2016-04-29 11:07:11 +02:00
ceb452bc9d Removed point cache operators. 2016-04-29 10:44:09 +02:00
c3863650cc Removed UI for point cache users. 2016-04-28 18:38:10 +02:00
1f723603c8 Merge branch 'master' into temp_remove_particles 2016-04-28 17:33:19 +02:00
3632c4997f Merge branch 'master' into temp_remove_particles 2016-04-20 16:25:16 +02:00
32455e230a Fix unused function warning. 2016-04-20 12:34:04 +02:00
773efb506a Removed particle sync code from Cycles.
Note that this only removes the actual dependencies of Cycles on the
particle code in Blender, but not the internal "particle" definition
or the curve type handling inside Cycles. These structures may be in need
of some improvement themselves, but that is out of scope here.
2016-04-20 11:59:02 +02:00
af594b7b85 Fix meamleak from unfreed edit data when exiting in hair edit mode. 2016-04-19 14:19:54 +02:00
5f67ac83bf Fix unfreed temporary buffers in strand relaxation. 2016-04-19 14:05:35 +02:00
b2cb4c448e Define BMEditStrands struct as an extension of BMEditMesh.
The advantage is that we can now use this struct in the (rather involved)
process of generating a display DerivedMesh and apply modifiers to it.
2016-04-19 14:01:41 +02:00
216aacbcba Disable regular mesh drawing in hair edit mode. 2016-04-19 13:27:20 +02:00
ec51e83798 Proof-of-concept: Hair edit data from regular meshes.
This adds the possibility to edit a regular mesh like strand data.
It's more of a test for independence from particles than a real use case,
but could come in handy anyway.
2016-04-18 18:13:26 +02:00
9a20f68295 Check mesh samples for zero weights on eval to detect invalid/unusable samples. 2016-04-18 17:48:25 +02:00
a85c9b241a Corrected implementation of the strand relaxation method ported from particles.
This is still the same algorithm as in particle edit mode, but cleaned up
some unnecessary complications and use much more meaningful variable names.
2016-04-17 15:08:46 +02:00
07221e980b Merge branch 'master' into strand_editmode 2016-04-16 18:10:37 +02:00
ba279efbdb Removed the ND_PARTICLE notifier and outliner particle elements. 2016-04-16 17:27:49 +02:00
9465d3decf Removed the particle context of property buttons space. 2016-04-16 17:17:31 +02:00
ecb695ccc8 Removed tool settings for particle edit mode. 2016-04-16 14:26:09 +02:00
cd0ec340c4 Removed remaining uses of the particle edit mode flag. 2016-04-16 12:39:41 +02:00
15c8d095e5 Removed the Main.particle list, used for ParticleSettings ID blocks.
There were still some type-agnostic uses as well, owing to the generic
ListBase type.
2016-04-16 12:28:29 +02:00
7c57822afa Fixed some minor errors in game engine and player. 2016-04-16 12:11:34 +02:00
c92b6f1de6 Removed the translation context for particle settings. 2016-04-16 11:32:45 +02:00
d30b942f07 Removed the ID_PA code used for ParticleSettings. 2016-04-16 11:29:28 +02:00
df2e543d44 Removed some unused declarations for boids code. 2016-04-16 11:11:39 +02:00
fbed29a246 Merge branch 'master' into temp_remove_particles 2016-04-15 17:59:54 +02:00
987bb50a74 Removed remaining use of pointers to particle types as well as boids headers. 2016-04-13 18:10:23 +02:00
d474ed9b88 Partially revert 82ec9c87a7, to add back point cache operators.
Eventually point cache will also be replaced, but it can be kept working at first even without particles.
2016-04-13 16:58:44 +02:00
664f5b8c06 Removed particle DNA. 2016-04-13 13:41:11 +02:00
d8d49befa0 Removed particle system and particle instance modifiers. 2016-04-13 11:45:15 +02:00
d47173c8ca Removed blenkernel particle code. 2016-04-13 10:49:39 +02:00
cf6cb3dcaf Removed most particle system code from RNA. 2016-04-12 18:26:19 +02:00
bcd12bf64d Removed most partical-related code from UI scripts.
There are a lot of cases here where deciding for removal is a bit tricky.
Many features have options for "use_particles" and similar settings. Only
features which actually store a particle object reference or work on actual
particle data have been removed.
2016-04-12 16:28:00 +02:00
29a792a75b Removed all direct uses of BKE_particle.h and DNA_particle_types.h from source/blender/editors. 2016-04-12 13:04:31 +02:00
cc468c1974 Removed remnants of particle draw code. 2016-04-12 12:18:38 +02:00
82ec9c87a7 Removed particle operators API and point cache operators. 2016-04-12 11:47:08 +02:00
5a783144e2 Removed particle operators from editors/physics/. 2016-04-12 11:25:40 +02:00
56d8228713 Merge branch 'master' into mesh_samples 2015-10-11 15:51:07 +02:00
892529029f Port over the improved mesh sampling API from the mesh_samples branch. 2015-09-19 17:33:37 +02:00
d820eb1265 Merge branch 'master' into mesh_samples 2015-09-19 16:59:26 +02:00
3aaca08aad Merge branch 'master' into strand_editmode
Conflicts:
	source/blender/editors/sculpt_paint/paint_ops.c
2015-09-19 16:29:04 +02:00
5f6d9e301e Implementation of Volume Sampling on meshes.
Based on the ray casting technique described here: http://www.joesfer.com/?p=84

Volume samples currently are not bound to mesh deformation in any way, they are
simple object-space locations. Potentially a harmonic weight approach as in
mesh cages could be used.
2015-08-21 16:45:36 +02:00
05281abca1 Merge branch 'master' into mesh_samples
Conflicts:
	release/datafiles/locale
	release/scripts/addons
	source/blender/blenkernel/CMakeLists.txt
2015-08-21 15:07:47 +02:00
38d9301674 Another fix for mirror editing of strand data.
Currently strand edit mode tool use the object data 'x mirror' flag.
This flag is only available on mesh objects, but the strand editing
can be used for dupli override caches etc. as well. Eventually strand
editing should get it's own independent flag to avoid this problem.
2015-05-05 14:27:44 +02:00
fbc70fa51c Fix for call to mirror functions when mirroring is not enabled, giving
warnings.
2015-05-05 14:03:59 +02:00
d52bdb6d3d Moved particle related functions of the strands edit mode into a
separate file.

This may seem a bit like overkill, but it helps ensure that no particle
depedencies messes up the strand editing code. The same will be done for
other use cases of the strand editing code in the future.
2015-05-04 18:37:45 +02:00
16b6d6c676 Added missing CD layer type name for MSurfaceSample. 2015-05-04 17:52:13 +02:00
bf7e8b42fa Merge branch 'master' into strand_editmode
Conflicts:
	source/blender/bmesh/bmesh_class.h
	source/blender/bmesh/intern/bmesh_mesh_conv.h
2015-05-04 17:14:25 +02:00
20e960215a Particle shapekey code is only in the gooseberry branch, disabled here. 2015-04-20 12:59:01 +02:00
9cafd3ae56 SimDebugData is now global, for easier usage and less intrusive code. 2015-04-20 12:58:16 +02:00
0dccffb7aa Fix for CustomDataType syntax error from merging. 2015-04-20 12:37:21 +02:00
7719a6365a Use the X mirror option in new strand edit stroke brush tools.
Note that currently this has virtually no effect, because the mirror
option relies on exact positions of vertices, which does not happen with
random hair placement (the add brush has no mirror option yet).

Eventually topological mirroring should help with this case, but is not
implemented for either old or new strand edit yet.
2015-04-20 12:25:18 +02:00
3a3327dcd5 Cleanup: rename function argument for consistency. 2015-04-20 12:25:18 +02:00
8ffcd1f434 Utility methods for mirrored strand editing.
These are a modified version of their BMEditMesh counterparts.

use_topology is not yet implemented for strands. Native strand topology
is not very useful for this. Instead, the topology of the scalp mesh
should be used for finding mirrored strand roots, then the arc- or
parametric length of a vertex from the root to find mirrored verts.

Conflicts:
	source/blender/blenkernel/BKE_editstrands.h
2015-04-20 12:25:15 +02:00
ed1dc43657 Fix for strands undo creating an invalid BMesh.
When copying mesh data to bmesh the MVERT and similar customdata types
have to be omitted. Otherwise the bmesh instance ends up with NULL
pointers in customdata layers, but entries in the typemap != -1. The
effect was that when storing new steps after one or more undo, the
resulting original data would be copied, and subsequent undo steps
are ignored.
2015-04-20 12:24:34 +02:00
5b9b779cab Minor code reshuffling. 2015-04-20 12:24:34 +02:00
4798464e8b Extended Mesh <-> BMesh copy function versions for specifying custom
data masks explicitly.

A dummy mesh is used for strand edit undo storage like in mesh edit
to prevent unnecessary code duplication. However, when copying from/to
BMesh only the mesh data layers are copied by default, omitting the new
data layers for strands (currently only MSurfaceSample hair root data).
2015-04-20 12:24:33 +02:00
299859e40b Sanity check: if there is no edited/active object for an undo step,
consider it invalid and clean up.
2015-04-20 12:24:33 +02:00
5e42aff397 Basic undo support in the new strand edit mode.
This uses the generalized undo stack system which is also used for
object data edit. An extension is necessary to tell the undo functions
which object is specifically used for generating undo data and
identifying the stack, since strand editing does not edit the obdata
itself.
2015-04-20 12:24:33 +02:00
3f539c987f Removed deprecated UI button for the hair debug flag. 2015-04-20 12:24:33 +02:00
6146b90312 Select Linked operator for hair edit mode (select all vertices of a
strand).
2015-04-20 12:24:03 +02:00
8b2ec99f57 Lasso Select operator for hair edit mode. 2015-04-20 12:24:03 +02:00
410998cdc6 Border Select operator for hair edit mode. 2015-04-20 12:24:03 +02:00
b6f4e0932d Mouse Select operator for hair edit mode. 2015-04-20 12:24:03 +02:00
62fa5c4a84 Select/Deselect All operator for hair edit mode. 2015-04-20 12:24:03 +02:00
2cddc3cda8 Disabled the partial IK strand relaxation for the time being.
First goal is to reproduce current particle edit tools in the strand
edit mode, then make improvements.
2015-04-20 12:24:03 +02:00
9120df6cb3 Missing bmesh include path in scons files. 2015-04-20 12:24:02 +02:00
48a86af388 IK solver for hair strands that provides a better solution for keeping
consistent segment lengths when transforming vertices.

Warning: The implementation is not correct yet, but all the steps should
be there.

The main idea is to treat strands as a sequence of joints that are
displaced out of their original locations by a transform or other tool.
The solver then tries to find a global per-strand solution that keeps
the segment lengths unmodified, with a minimum change in angles from
the original starting shape. Such a solution is much more usable and
efficient than the current O(n^2) attempt of "spreading the error"
across the strand.

The inverse kinematics method is very flexible. It can also include
stretching, which would be very welcome for features like the length
tool. Different parts of the strand could be weighted separately using
scaling factors for the angle/stretch parameters.

Conflicts:
	source/blender/physics/intern/implicit.h
2015-04-20 12:24:00 +02:00
eacc24ccf1 Ported over the relaxation method for hair vertices from particle edit
mode.

This method is simple, but not really very usable. It works by
successively relaxing segments that are too long or too short, moving
both vertices along the edge between them. This is repeated N^2 times
(N: number of vertices on the strand).

A true IK solver could give a lot better results, as well as providing
many opportunities to apply weighting for targets (e.g. preferring to
move non-selected over selected vertices). Many different methods for
simple IK solvers exist, so there should be one that works well for
large number of simple strands. See e.g.
http://www.math.ucsd.edu/~sbuss/ResearchWeb/ikmethods/iksurvey.pdf
2015-04-20 12:23:49 +02:00
ac54ded29b Primitive transform operator support for strand vertices.
This does not yet prevent root transforms and/or length changes.
2015-04-20 12:23:49 +02:00
f7511b3d01 Improved hair combing tool, adjusting edge directions instead of
vertex positions.

This works a lot better with strokes perpendicular to the general hair
strand direction. With the previous comb tool such strokes would only
make a small dent in the hair curve and then vertices would slip out
of the tool circle. The edge combing affects the local direction of
strands, which acts as a kind of grabbing functionality by moving
further vertices in front of the tool circle. The result is that
drawing a curvy hair shape with the comb becomes much easier.

In addition, the new tool also uses edge filtering and weighting rather
than vertices. This means that small brushes also work well, instead
of having no effect when hitting the edge segments between vertices.

Further improvement could be achieved later by using a global strand
solver, which adjusts vertex positions based on an error metric along
the whole of the strand.
2015-04-20 12:23:48 +02:00
208ddcde2c Use a simple low-pass filter to generate a smoother, more stable
direction vector for the hair stroke tool.

This is necessary for directional tools such as combing, where the
stroke direction can lead to unwanted results if it changes too
abruptly.
2015-04-20 12:23:48 +02:00
f3b22c5769 Support for sim_debug drawing in hair edit mode (dev feature). 2015-04-20 12:23:48 +02:00
b70c815ac2 Renamed the edithair files in BKE to editstrands.
The rationale behind this is that the BKE code could be used for
modeling hair and fur as well as a number of other features such as
grass. The primary addition to BMesh is the limitation to strand-like
topology (simple vertex chains, optionally rooted on a mesh surface).

The editor code OTOH is quite hair specific, since the result should
be suitable for hair simulation, and the workflow should mimick actual
hair grooming intuitively. Eventually the hair edit mode could become
a generalized strand edit mode with slightly different tool sets for
various purposes, but for now it is quite specifically built for hair.

Conflicts:
	source/blender/blenkernel/CMakeLists.txt
	source/blender/blenkernel/intern/particle.c
2015-04-20 12:23:46 +02:00
d0a1fc8bb0 Sanity check for strand root/tip checks, now supports single vertices. 2015-04-20 12:23:23 +02:00
2d1d909817 MSVC compiler cannot handle standard C code.
Conflicts:
	source/blender/editors/physics/particle_edit.c
2015-04-20 12:23:20 +02:00
e9737da5f2 Fix scons build files for new hair edit code parts. 2015-04-20 12:23:16 +02:00
1e047231c6 Fix for hair-to-particle export: need to set weight=1.0 for hair roots,
since the particle system uses this for pinning them to the mesh.
2015-04-20 12:23:16 +02:00
142ef0b2e9 Fixed lib-linking for hair edit settings brush and object pointers. 2015-04-20 12:23:15 +02:00
56a09434c5 Basic Add tool for creating new strands in hair edit mode. 2015-04-20 12:23:15 +02:00
8672304e30 Fix for uninitialized return value. 2015-04-20 12:23:15 +02:00
f95dde244e Better feedback about valid sample from mesh sampling methods.
Conflicts:
	source/blender/editors/object/object_shapekey.c
2015-04-20 12:23:15 +02:00
79e649a3bf New simple storage method for single sample values. 2015-04-20 12:23:15 +02:00
e5b25e3c07 Generic raycast method for generating mesh surface samples.
Conflicts:
	source/blender/blenkernel/intern/mesh_sample.c
2015-04-20 12:23:15 +02:00
a4664ef88d New mesh sample evaluation function for shape key data. 2015-04-20 12:23:15 +02:00
be312b1399 First selection operator implementation for hair edit: circle select. 2015-04-20 12:23:14 +02:00
3edc512888 Show selection state of hair vertices with the usual theme colors. 2015-04-20 12:23:14 +02:00
b2ea8c1022 Added back different selection modes (strands, verts, tips) for hair
editing.
2015-04-20 12:23:14 +02:00
339a8b7521 Fix for OpenlGL state restoration after strand drawing, disable color
material option.
2015-04-20 12:23:14 +02:00
77da317cb1 Apply the same weight profile in the comb tool as in particle edit mode.
The comb tool will likely get a complete overhaul, but until then it
should just behave like the old tool.
2015-04-20 12:23:14 +02:00
2c0616b034 Support for common operators, keymap entries and radial controls for
hair brush settings.
2015-04-20 12:23:14 +02:00
a9fbd3b23b Fix for brush radius, the Brush.size property is actually the radius and
not the diameter.
2015-04-20 12:23:14 +02:00
687b5a1ec0 Implemented basic cursor drawing for hair edit mode brushes. 2015-04-20 12:23:13 +02:00
59efe23830 Primitive hair lighting in OpenGL solid shading, cleanup of strands
drawing code for edit mode.

The lighting uses the same method as the particle hair, interpreting
strand direction as the normal. This is nowhere near realistic hair
shading, but doing this with line shading alone in the fixed-function
pipeline is probably not possible. A GLSL shader could be used instead
for a more realistic alternative as part of the viewport project. At
least this simple shading mode gives some orientation feedback while
editing hair.
2015-04-20 12:23:13 +02:00
d16599ea04 Display basic brush properties in the toolbar for hair edit mode. 2015-04-20 12:23:13 +02:00
37d3a3331e Use the "official" brush size calculated by blenkernel and subdivide
the stroke step to avoid tunneling.
2015-04-20 12:23:13 +02:00
5254df30ba Filter affected hair vertices in edit mode based on the brush size and
z depth.
2015-04-20 12:23:13 +02:00
2590231315 Constrain hair root vertices to their mesh location after applying tools.
Conflicts:
	source/blender/bmesh/intern/bmesh_interp.c
	source/blender/bmesh/intern/bmesh_interp.h
2015-04-20 12:23:11 +02:00
83b20c7ddf Enforce hair constraints (constant segment length) after applying a tool.
Currently uses the same approach as old particle edit mode (rescale
hair segments from the root on). A more sophisticated approach using
least-square error minimization of the displacement could yield better
results.
2015-04-20 12:22:10 +02:00
0e06a60168 Make sure tool input data is in object space. 2015-04-20 12:22:10 +02:00
121677d7c8 Nicer vector math for mouse coordinates. 2015-04-20 12:22:10 +02:00
1615da133f Simplified first version of the hair stroke combing functionality.
Stroke tools will be categorized by the hair elements they operate on:
vertices, segments or strands (roots). In addition to that a filter
function defines the influence of the brush. This should be defined by
the other brush settings and be largely independent of the main tool
mode.
2015-04-20 12:22:10 +02:00
7ae6492c85 Lots of small fixes for paint system quirks to make hair brushes work
in the UI.

Conflicts:
	release/scripts/startup/bl_ui/space_view3d.py
	source/blender/editors/transform/manipulator_widget.c
2015-04-20 12:21:58 +02:00
7779166313 Define hair edit settings and brush types in the RNA, similar to paint
and sculpt settings.

Conflicts:
	source/blender/makesdna/DNA_brush_types.h
2015-04-20 12:19:28 +02:00
833a11f891 New image file icons for hair brush tools and an according tool enum in
the Brush RNA.
2015-04-20 12:17:16 +02:00
79959152e6 Calculate some basic info about mouse strokes and context and pass it
on to a general hair tool function.
2015-04-20 12:17:16 +02:00
4fd6a7a696 Revert previous hair edit operator scaffolding and port over the old
operator for strokes instead.

The paint system is much too complicated and does not add any real
advantage at this point.
2015-04-20 12:17:16 +02:00
98b15d9a7c Copied high-level operator code from the paint/sculpt system as a basis
for brush-stroke operators in hair edit mode.

Hopefully this can help avoid some redundant code and ensure consistent
keymapping etc.
2015-04-20 12:17:16 +02:00
a889a1458c Missing bmesh include folder for hair editor in scons. 2015-04-20 12:17:16 +02:00
7b6332f634 Apply the hair matrices when converting from particle keys to bmesh,
so the edit data is consistently in object space.
2015-04-20 12:17:16 +02:00
0a27e97fb7 Fix for GL buffer size for edges, needs to 2x for two vertex indices. 2015-04-20 12:17:16 +02:00
eb5257002b New drawing code for hair edit mode.
Conflicts:
	source/blender/editors/space_view3d/drawobject.c
	source/blender/editors/space_view3d/view3d_intern.h
2015-04-20 12:17:14 +02:00
23b284348b Removed deprecated code. 2015-04-20 12:15:17 +02:00
2d79994e39 Free strand edit memory after use. 2015-04-20 12:15:17 +02:00
fd34e3efbc Fix for verts-of-strand iterator: This requires a second pointer in
addition to the edge, otherwise the last point is omitted.
2015-04-20 12:15:17 +02:00
dc43df89cd CustomData layer for storing hair root locations as MSurfaceSamples.
This requires converting the old messy particle num/num_dmcache/fuv/foffset
data into the new mesh samples, which can potentially introduce floating
point errors and inaccuracies due to lack of face index mapping in the
new system. However, in any well-constructed particle system the hair
roots should be nearest to their num face, so mapping would be accurate
enough. If necessary face index data could be added to samples as a
legacy code hack, but probably it's best to eventually replace the
hair system as a whole anyway.
2015-04-20 12:15:17 +02:00
4e47239de2 Store the hair key weight in edit mode.
Currently particles only have a single weight value, controlling
pinning in the simulation (for root and virtual root verts) and goal
force scaling. This will be replaced by a full vertex group weight
system eventually.
2015-04-20 12:15:17 +02:00
991ee8a570 First customdata layer for particle mass.
This is more for testing purposes, since currently there is only a
single mass property for the psys as a whole. This should change in the
future though, to allow variable mass per strand or vertex.

Conflicts:
	source/blender/bmesh/intern/bmesh_interp.c
2015-04-20 12:15:15 +02:00
e43ef55e7f Basic particle data reconstruction when exiting edit mode. 2015-04-20 12:14:34 +02:00
1afd5be044 Fix for verts-of-strand iterator: After last edge step has to set the
edge to NULL to avoid infinite looping over the same edge (1-elem disk).
2015-04-20 12:14:34 +02:00
d550a29558 Fix for particle-to-bmesh: only was looping over totvert instead of
pa->totkey.
2015-04-20 12:14:34 +02:00
5f44f4a2ff Intermediate commit: switching strand edit data to BMesh.
Hair/Strand editing will only use a subset of the bmesh topology and
expect a specific topology that needs to be verified and enforced.
However, this extra requirement is much less work than reimplementing a
whole edit data system with the same feature set as bmesh and avoids
much redundant code.

Conflicts:
	source/blender/blenkernel/intern/customdata.c
	source/blender/makesdna/DNA_customdata_types.h
2015-04-20 12:14:30 +02:00
b0a9e48a19 New customdata type for mesh surface samples.
Conflicts:
	source/blender/makesdna/DNA_customdata_types.h
2015-04-20 12:14:23 +02:00
afb947c00c Switched the hair edit data to a bmesh-like structure for consistency.
This means using mempools to store curve and vertex data, which allows
arbitrary addition and removal of data more easily. Also this includes
an iterator system similar to bmesh iterators (although the simpler
topology makes it a lot less complex).

Conflicts:
	source/blender/blenkernel/intern/customdata.c
	source/blender/makesdna/DNA_customdata_types.h
2015-04-20 12:13:35 +02:00
f1e4d35489 Reconstruct most basic particle data when applying the hair edit, so
particle hairs remain visible.

Note that currently the hair root location (num/num_dmcache, fuv, foffset)
is not stored from edit data, so all hairs end up in a default location.
2015-04-20 12:12:01 +02:00
1c7053f7a0 Store hair edit data in particle systems and manage it in the operator
for entering/exiting the edit mode.

Conflicts:
	source/blender/blenkernel/intern/particle.c
2015-04-20 12:11:59 +02:00
7bb90a06e1 Moved code for the hair edit data structures to blenkernel.
This makes it work more like editmesh, and avoid the awkward and
basically bad-level approach in particles, where the edit data is an
anonymous pointer in particle systems together with a callback for
freeing.

Conflicts:
	source/blender/blenkernel/CMakeLists.txt
2015-04-20 12:11:44 +02:00
a9001adbb4 New edit mode for hair.
Conflicts:
	source/blender/blenloader/intern/readfile.c
2015-04-20 12:11:05 +02:00
dd69a3dbcf Finished the particle-to-edit conversion function. 2015-04-20 12:10:33 +02:00
c65f1b2e15 More work on particle conversion methods for hair edit mode. 2015-04-20 12:10:33 +02:00
09a7dbc29a New editor library for hair edit mode. 2015-04-20 12:10:33 +02:00
6078e79cea Minor syntax fix. 2015-04-20 12:10:33 +02:00
6783b15453 Shifted the dispatch from the algorithm side to the storage side of the
sampling system to keep the code simple.

Now there is a MSurfaceSampleStorage struct that encodes the storage
details, which the algorithms don't have to care about.
2015-04-20 12:10:33 +02:00
82132fc5b0 Added generalized method for creating an array of mesh samples with
arbitrary stride.
2015-04-20 12:10:32 +02:00
4b4f24607e Changed mesh sample definition to use 3 vertex weights instead of a
face index. This is easier to sample uniformly and avoids the need for
tesselation for evaluating.
2015-04-20 12:10:32 +02:00
fe48c353f1 Normalize the normal vector after sample eval to account for
interpolation.
2015-04-20 12:10:32 +02:00
308af3bfb3 Added a bool return to the eval function to give feedback on invalid
samples.
2015-04-20 12:10:32 +02:00
3f7d66ece4 Added a basic RNA definition for the mesh sampling system. 2015-04-20 12:10:32 +02:00
a952800ffc Eval function to get a location and normal vector from mesh samples. 2015-04-20 12:10:32 +02:00
71e34dad2b Usable random distribution algorithm.
Does not include area weighting yet.
2015-04-20 12:10:32 +02:00
24b77359ae Skeleton code for sampling meshes.
Conflicts:
	source/blender/blenkernel/CMakeLists.txt
2015-04-20 12:10:29 +02:00
62aabdd550 Merge remote-tracking branch 'github_lukastoenne/mesh_samples' into mesh_samples 2014-12-05 12:17:53 +01:00
2204bb092b Merge branch 'master' into mesh_samples 2014-12-05 11:23:38 +01:00
8374e08894 Mesh sampling system for unified point-on-mesh handling.
This code is not yet used by any feature in master, but has proved very useful in the Gooseberry branch and several WIP patches. Inclusion into master was requested to avoid diverging code in branches and get part of the Gooseberry code merged early on.

The core idea is to have a common way of identifying points on mesh surfaces. Efficient evaluation of such points after deformation and mappable modifiers (e.g. subdivision) tracks positions, normals and other surface attributes. This is used extensively in the particle/hair systems and could be useful for certain tools, duplicators, etc.. Currently the particle systems in particular are very fragile and succeptible to mesh changes because of the unreliable way mesh surface mapping is stored. While the new system at this point uses essentially the same method, it at least provides a centralized DNA type that can be improved easily without too much effort and compatiblity issues.

In addition to evaluating surface samples the system also provides a central place to implement surface sampling algorithms, such as random sampling, ray casting, paint-like tools, etc.

Differential Revision: https://developer.blender.org/D922
2014-12-01 15:10:16 +01:00
822949a3e2 Fix for uninitialized return value. 2014-12-01 14:42:18 +01:00
a86869af8f Better feedback about valid sample from mesh sampling methods.
Conflicts:
	source/blender/editors/object/object_shapekey.c
2014-12-01 14:41:02 +01:00
ca31ce144e New simple storage method for single sample values. 2014-12-01 14:38:03 +01:00
f61f7e2d57 Generic raycast method for generating mesh surface samples. 2014-12-01 14:36:10 +01:00
3036cedd90 New mesh sample evaluation function for shape key data. 2014-12-01 14:34:59 +01:00
cc5b3c2ff7 Merge branch 'mesh_samples' of github.com:lukastoenne/blender into mesh_samples 2014-12-01 14:29:41 +01:00
a30f9ffa87 Merge branch 'master' into mesh_samples
Conflicts:
	release/datafiles/locale
	release/scripts/addons
2014-12-01 14:29:09 +01:00
3361788b1c Merge branch 'master' into mesh_samples
Conflicts:
	release/datafiles/locale
	release/scripts/addons
2014-11-30 10:08:09 +01:00
21ab9ac9e3 Minor syntax fix. 2014-09-24 17:35:41 +02:00
18c6bb2436 Shifted the dispatch from the algorithm side to the storage side of the
sampling system to keep the code simple.

Now there is a MSurfaceSampleStorage struct that encodes the storage
details, which the algorithms don't have to care about.
2014-09-24 17:04:41 +02:00
a93841e3d4 Added generalized method for creating an array of mesh samples with
arbitrary stride.
2014-09-24 15:58:53 +02:00
728b6ed8e6 Merge branch 'master' into mesh_samples 2014-09-24 15:54:21 +02:00
fa0163b8c7 Changed mesh sample definition to use 3 vertex weights instead of a
face index. This is easier to sample uniformly and avoids the need for
tesselation for evaluating.
2014-03-04 15:39:48 +01:00
7112a531b2 Normalize the normal vector after sample eval to account for
interpolation.
2014-03-04 13:42:51 +01:00
60cde6ca4a Added a bool return to the eval function to give feedback on invalid
samples.
2014-03-04 13:42:06 +01:00
717db95210 Added a basic RNA definition for the mesh sampling system. 2014-03-03 17:57:56 +01:00
a944cf8450 Eval function to get a location and normal vector from mesh samples. 2014-03-03 14:10:58 +01:00
a1dd14c764 Usable random distribution algorithm.
Does not include area weighting yet.
2014-03-03 12:36:02 +01:00
47d024c2b0 Merge branch 'master' into mesh_samples 2014-03-03 11:56:02 +01:00
30e02b9a19 Skeleton code for sampling meshes. 2014-03-03 10:59:36 +01:00
2103 changed files with 203841 additions and 70021 deletions

View File

@@ -1,6 +1,6 @@
{ {
"project_id" : "Blender", "project_id" : "Blender",
"conduit_uri" : "https://developer.blender.org/", "conduit_uri" : "https://developer.blender.org/",
"git.default-relative-commit" : "origin/master", "git.default-relative-commit" : "origin/blender2.8",
"arc.land.update.default" : "rebase" "arc.land.update.default" : "rebase"
} }

4
.gitmodules vendored
View File

@@ -1,20 +1,24 @@
[submodule "release/scripts/addons"] [submodule "release/scripts/addons"]
path = release/scripts/addons path = release/scripts/addons
url = ../blender-addons.git url = ../blender-addons.git
branch = blender2.8
ignore = all ignore = all
branch = master branch = master
[submodule "release/scripts/addons_contrib"] [submodule "release/scripts/addons_contrib"]
path = release/scripts/addons_contrib path = release/scripts/addons_contrib
url = ../blender-addons-contrib.git url = ../blender-addons-contrib.git
branch = master
ignore = all ignore = all
branch = master branch = master
[submodule "release/datafiles/locale"] [submodule "release/datafiles/locale"]
path = release/datafiles/locale path = release/datafiles/locale
url = ../blender-translations.git url = ../blender-translations.git
branch = master
ignore = all ignore = all
branch = master branch = master
[submodule "source/tools"] [submodule "source/tools"]
path = source/tools path = source/tools
url = ../blender-dev-tools.git url = ../blender-dev-tools.git
branch = master
ignore = all ignore = all
branch = master branch = master

View File

@@ -244,6 +244,8 @@ endif()
option(WITH_PLAYER "Build Player" OFF) option(WITH_PLAYER "Build Player" OFF)
option(WITH_OPENCOLORIO "Enable OpenColorIO color management" ${_init_OPENCOLORIO}) option(WITH_OPENCOLORIO "Enable OpenColorIO color management" ${_init_OPENCOLORIO})
option(WITH_CLAY_ENGINE "Enable Clay engine" ON)
# Compositor # Compositor
option(WITH_COMPOSITOR "Enable the tile based nodal compositor" ON) option(WITH_COMPOSITOR "Enable the tile based nodal compositor" ON)
@@ -390,10 +392,14 @@ if(UNIX AND NOT APPLE)
endif() endif()
option(WITH_PYTHON_INSTALL "Copy system python into the blender install folder" ON) option(WITH_PYTHON_INSTALL "Copy system python into the blender install folder" ON)
if(WITH_PYTHON_INSTALL) if(WITH_PYTHON_INSTALL OR (WITH_AUDASPACE AND NOT WITH_SYSTEM_AUDASPACE))
option(WITH_PYTHON_INSTALL_NUMPY "Copy system numpy into the blender install folder" ON)
set(PYTHON_NUMPY_PATH "" CACHE PATH "Path to python site-packages or dist-packages containing 'numpy' module") set(PYTHON_NUMPY_PATH "" CACHE PATH "Path to python site-packages or dist-packages containing 'numpy' module")
mark_as_advanced(PYTHON_NUMPY_PATH) mark_as_advanced(PYTHON_NUMPY_PATH)
set(PYTHON_NUMPY_INCLUDE_DIRS ${PYTHON_NUMPY_PATH}/numpy/core/include CACHE PATH "Path to the include directory of the numpy module")
mark_as_advanced(PYTHON_NUMPY_INCLUDE_DIRS)
endif()
if(WITH_PYTHON_INSTALL)
option(WITH_PYTHON_INSTALL_NUMPY "Copy system numpy into the blender install folder" ON)
if(UNIX AND NOT APPLE) if(UNIX AND NOT APPLE)
option(WITH_PYTHON_INSTALL_REQUESTS "Copy system requests into the blender install folder" ON) option(WITH_PYTHON_INSTALL_REQUESTS "Copy system requests into the blender install folder" ON)
@@ -464,28 +470,16 @@ endif()
# OpenGL # OpenGL
option(WITH_GLEW_MX "Support multiple GLEW contexts (experimental)" OFF )
option(WITH_GLEW_ES "Switches to experimental copy of GLEW that has support for OpenGL ES. (temporary option for development purposes)" OFF) option(WITH_GLEW_ES "Switches to experimental copy of GLEW that has support for OpenGL ES. (temporary option for development purposes)" OFF)
option(WITH_GL_EGL "Use the EGL OpenGL system library instead of the platform specific OpenGL system library (CGL, glX, or WGL)" OFF) option(WITH_GL_EGL "Use the EGL OpenGL system library instead of the platform specific OpenGL system library (CGL, glX, or WGL)" OFF)
option(WITH_GL_PROFILE_COMPAT "Support using the OpenGL 'compatibility' profile. (deprecated)" ON )
option(WITH_GL_PROFILE_CORE "Support using the OpenGL 3.2+ 'core' profile." OFF)
option(WITH_GL_PROFILE_ES20 "Support using OpenGL ES 2.0. (thru either EGL or the AGL/WGL/XGL 'es20' profile)" OFF) option(WITH_GL_PROFILE_ES20 "Support using OpenGL ES 2.0. (thru either EGL or the AGL/WGL/XGL 'es20' profile)" OFF)
mark_as_advanced( mark_as_advanced(
WITH_GLEW_MX
WITH_GLEW_ES WITH_GLEW_ES
WITH_GL_EGL WITH_GL_EGL
WITH_GL_PROFILE_COMPAT
WITH_GL_PROFILE_CORE
WITH_GL_PROFILE_ES20 WITH_GL_PROFILE_ES20
) )
if(WITH_GL_PROFILE_COMPAT)
set(WITH_GLU ON)
else()
set(WITH_GLU OFF)
endif()
if(WIN32) if(WIN32)
option(WITH_GL_ANGLE "Link with the ANGLE library, an OpenGL ES 2.0 implementation based on Direct3D, instead of the system OpenGL library." OFF) option(WITH_GL_ANGLE "Link with the ANGLE library, an OpenGL ES 2.0 implementation based on Direct3D, instead of the system OpenGL library." OFF)
mark_as_advanced(WITH_GL_ANGLE) mark_as_advanced(WITH_GL_ANGLE)
@@ -506,11 +500,10 @@ endif()
# We default options to whatever default standard in the current compiler. # We default options to whatever default standard in the current compiler.
if(CMAKE_COMPILER_IS_GNUCC AND (NOT "${CMAKE_C_COMPILER_VERSION}" VERSION_LESS "6.0") AND (NOT WITH_CXX11)) if(CMAKE_COMPILER_IS_GNUCC AND (NOT "${CMAKE_C_COMPILER_VERSION}" VERSION_LESS "6.0") AND (NOT WITH_CXX11))
set(_c11_init ON) set(_c11_init ON)
set(_cxx11_init ON)
else() else()
set(_c11_init OFF) set(_c11_init OFF)
set(_cxx11_init OFF)
endif() endif()
set(_cxx11_init ON)
option(WITH_C11 "Build with C11 standard enabled, for development use only!" ${_c11_init}) option(WITH_C11 "Build with C11 standard enabled, for development use only!" ${_c11_init})
mark_as_advanced(WITH_C11) mark_as_advanced(WITH_C11)
@@ -524,8 +517,8 @@ if(CMAKE_COMPILER_IS_GNUCC)
endif() endif()
# Dependency graph # Dependency graph
option(WITH_LEGACY_DEPSGRAPH "Build Blender with legacy dependency graph" ON) option(WITH_DEPSGRAPH_COPY_ON_WRITE "Build Blender with copy-on-write support for dependency graph" OFF)
mark_as_advanced(WITH_LEGACY_DEPSGRAPH) mark_as_advanced(WITH_DEPSGRAPH_COPY_ON_WRITE)
if(WIN32) if(WIN32)
# Use hardcoded paths or find_package to find externals # Use hardcoded paths or find_package to find externals
@@ -634,16 +627,11 @@ if(NOT WITH_BOOST)
endmacro() endmacro()
set_and_warn(WITH_CYCLES OFF) set_and_warn(WITH_CYCLES OFF)
set_and_warn(WITH_AUDASPACE OFF)
set_and_warn(WITH_INTERNATIONAL OFF) set_and_warn(WITH_INTERNATIONAL OFF)
set_and_warn(WITH_OPENVDB OFF) set_and_warn(WITH_OPENVDB OFF)
set_and_warn(WITH_OPENCOLORIO OFF) set_and_warn(WITH_OPENCOLORIO OFF)
set_and_warn(WITH_MOD_BOOLEAN OFF) set_and_warn(WITH_MOD_BOOLEAN OFF)
elseif(WITH_CYCLES OR WITH_OPENIMAGEIO OR WITH_INTERNATIONAL OR
set_and_warn(WITH_OPENAL OFF) # depends on AUDASPACE
set_and_warn(WITH_GAMEENGINE OFF) # depends on AUDASPACE
set_and_warn(WITH_PLAYER OFF) # depends on GAMEENGINE
elseif(WITH_CYCLES OR WITH_OPENIMAGEIO OR WITH_AUDASPACE OR WITH_INTERNATIONAL OR
WITH_OPENVDB OR WITH_OPENCOLORIO OR WITH_MOD_BOOLEAN) WITH_OPENVDB OR WITH_OPENCOLORIO OR WITH_MOD_BOOLEAN)
# Keep enabled # Keep enabled
else() else()
@@ -711,30 +699,9 @@ TEST_SHARED_PTR_SUPPORT()
TEST_UNORDERED_MAP_SUPPORT() TEST_UNORDERED_MAP_SUPPORT()
if(WITH_AUDASPACE) if(WITH_AUDASPACE)
if(WITH_SYSTEM_AUDASPACE) if(NOT WITH_SYSTEM_AUDASPACE)
set(AUDASPACE_DEFINITIONS set(AUDASPACE_C_INCLUDE_DIRS "${CMAKE_SOURCE_DIR}/extern/audaspace/bindings/C" "${CMAKE_BINARY_DIR}/extern/audaspace")
-DWITH_AUDASPACE set(AUDASPACE_PY_INCLUDE_DIRS "${CMAKE_SOURCE_DIR}/extern/audaspace/bindings")
-DWITH_SYSTEM_AUDASPACE
"-DAUD_DEVICE_H=<AUD_Device.h>"
"-DAUD_SPECIAL_H=<AUD_Special.h>"
"-DAUD_SOUND_H=<AUD_Sound.h>"
"-DAUD_HANDLE_H=<AUD_Handle.h>"
"-DAUD_SEQUENCE_H=<AUD_Sequence.h>"
"-DAUD_TYPES_H=<AUD_Types.h>"
"-DAUD_PYTHON_H=<python/PyAPI.h>"
)
else()
set(AUDASPACE_C_INCLUDE_DIRS "${CMAKE_SOURCE_DIR}/intern/audaspace/intern")
set(AUDASPACE_PY_INCLUDE_DIRS "${CMAKE_SOURCE_DIR}/intern/audaspace/intern")
set(AUDASPACE_DEFINITIONS
-DWITH_AUDASPACE
"-DAUD_DEVICE_H=<AUD_C-API.h>"
"-DAUD_SPECIAL_H=<AUD_C-API.h>"
"-DAUD_SOUND_H=<AUD_C-API.h>"
"-DAUD_HANDLE_H=<AUD_C-API.h>"
"-DAUD_SEQUENCE_H=<AUD_C-API.h>"
"-DAUD_TYPES_H=<AUD_Space.h>"
)
endif() endif()
endif() endif()
@@ -963,19 +930,11 @@ endif()
find_package(OpenGL) find_package(OpenGL)
blender_include_dirs_sys("${OPENGL_INCLUDE_DIR}") blender_include_dirs_sys("${OPENGL_INCLUDE_DIR}")
if(WITH_GLU)
list(APPEND BLENDER_GL_LIBRARIES "${OPENGL_glu_LIBRARY}")
list(APPEND GL_DEFINITIONS -DWITH_GLU)
endif()
if(WITH_SYSTEM_GLES) if(WITH_SYSTEM_GLES)
find_package_wrapper(OpenGLES) find_package_wrapper(OpenGLES)
endif() endif()
if(WITH_GL_PROFILE_COMPAT OR WITH_GL_PROFILE_CORE) if(WITH_GL_PROFILE_ES20)
list(APPEND BLENDER_GL_LIBRARIES "${OPENGL_gl_LIBRARY}")
elseif(WITH_GL_PROFILE_ES20)
if(WITH_SYSTEM_GLES) if(WITH_SYSTEM_GLES)
if(NOT OPENGLES_LIBRARY) if(NOT OPENGLES_LIBRARY)
message(FATAL_ERROR message(FATAL_ERROR
@@ -1035,6 +994,9 @@ elseif(WITH_GL_PROFILE_ES20)
endif() endif()
else()
list(APPEND BLENDER_GL_LIBRARIES "${OPENGL_gl_LIBRARY}")
endif() endif()
if(WITH_GL_EGL) if(WITH_GL_EGL)
@@ -1082,16 +1044,10 @@ if(WITH_GL_EGL)
endif() endif()
if(WITH_GL_PROFILE_COMPAT)
list(APPEND GL_DEFINITIONS -DWITH_GL_PROFILE_COMPAT)
endif()
if(WITH_GL_PROFILE_CORE)
list(APPEND GL_DEFINITIONS -DWITH_GL_PROFILE_CORE)
endif()
if(WITH_GL_PROFILE_ES20) if(WITH_GL_PROFILE_ES20)
list(APPEND GL_DEFINITIONS -DWITH_GL_PROFILE_ES20) list(APPEND GL_DEFINITIONS -DWITH_GL_PROFILE_ES20)
else()
list(APPEND GL_DEFINITIONS -DWITH_GL_PROFILE_CORE)
endif() endif()
if(WITH_GL_EGL) if(WITH_GL_EGL)
@@ -1128,10 +1084,6 @@ endif()
#----------------------------------------------------------------------------- #-----------------------------------------------------------------------------
# Configure GLEW # Configure GLEW
if(WITH_GLEW_MX)
list(APPEND GL_DEFINITIONS -DWITH_GLEW_MX)
endif()
if(WITH_SYSTEM_GLEW) if(WITH_SYSTEM_GLEW)
find_package(GLEW) find_package(GLEW)
@@ -1141,11 +1093,7 @@ if(WITH_SYSTEM_GLEW)
message(FATAL_ERROR "GLEW is required to build Blender. Install it or disable WITH_SYSTEM_GLEW.") message(FATAL_ERROR "GLEW is required to build Blender. Install it or disable WITH_SYSTEM_GLEW.")
endif() endif()
if(WITH_GLEW_MX) set(BLENDER_GLEW_LIBRARIES ${GLEW_LIBRARY})
set(BLENDER_GLEW_LIBRARIES ${GLEW_MX_LIBRARY})
else()
set(BLENDER_GLEW_LIBRARIES ${GLEW_LIBRARY})
endif()
else() else()
if(WITH_GLEW_ES) if(WITH_GLEW_ES)
set(GLEW_INCLUDE_PATH "${CMAKE_SOURCE_DIR}/extern/glew-es/include") set(GLEW_INCLUDE_PATH "${CMAKE_SOURCE_DIR}/extern/glew-es/include")
@@ -1153,12 +1101,11 @@ else()
list(APPEND GL_DEFINITIONS -DGLEW_STATIC -DWITH_GLEW_ES) list(APPEND GL_DEFINITIONS -DGLEW_STATIC -DWITH_GLEW_ES)
# These definitions remove APIs from glew.h, making GLEW smaller, and catching unguarded API usage # These definitions remove APIs from glew.h, making GLEW smaller, and catching unguarded API usage
if(NOT WITH_GL_PROFILE_ES20) if(WITH_GL_PROFILE_ES20)
list(APPEND GL_DEFINITIONS -DGLEW_ES_ONLY)
else()
# No ES functions are needed # No ES functions are needed
list(APPEND GL_DEFINITIONS -DGLEW_NO_ES) list(APPEND GL_DEFINITIONS -DGLEW_NO_ES)
elseif(NOT (WITH_GL_PROFILE_CORE OR WITH_GL_PROFILE_COMPAT))
# ES is enabled, but the other functions are all disabled
list(APPEND GL_DEFINITIONS -DGLEW_ES_ONLY)
endif() endif()
if(WITH_GL_PROFILE_ES20) if(WITH_GL_PROFILE_ES20)
@@ -1195,9 +1142,7 @@ else()
endif() endif()
if(NOT WITH_GLU) list(APPEND GL_DEFINITIONS -DGLEW_NO_GLU)
list(APPEND GL_DEFINITIONS -DGLEW_NO_GLU)
endif()
#----------------------------------------------------------------------------- #-----------------------------------------------------------------------------
# Configure Bullet # Configure Bullet
@@ -1502,10 +1447,15 @@ if(WITH_PYTHON)
) )
endif() endif()
if(WIN32 OR APPLE) if(WIN32)
# pass, we have this in an archive to extract # pass, we have this in an archive to extract
elseif(WITH_PYTHON_INSTALL AND WITH_PYTHON_INSTALL_NUMPY) elseif((WITH_PYTHON_INSTALL AND WITH_PYTHON_INSTALL_NUMPY) OR (WITH_AUDASPACE AND NOT WITH_SYSTEM_AUDASPACE))
find_python_package(numpy) if(("${PYTHON_NUMPY_PATH}" STREQUAL "") OR (${PYTHON_NUMPY_PATH} MATCHES NOTFOUND))
find_python_package(numpy)
unset(PYTHON_NUMPY_INCLUDE_DIRS CACHE)
set(PYTHON_NUMPY_INCLUDE_DIRS ${PYTHON_NUMPY_PATH}/numpy/core/include CACHE PATH "Path to the include directory of the numpy module")
mark_as_advanced(PYTHON_NUMPY_INCLUDE_DIRS)
endif()
endif() endif()
if(WIN32 OR APPLE) if(WIN32 OR APPLE)
@@ -1742,10 +1692,7 @@ if(FIRST_RUN)
info_cfg_text("OpenGL:") info_cfg_text("OpenGL:")
info_cfg_option(WITH_GLEW_ES) info_cfg_option(WITH_GLEW_ES)
info_cfg_option(WITH_GLU)
info_cfg_option(WITH_GL_EGL) info_cfg_option(WITH_GL_EGL)
info_cfg_option(WITH_GL_PROFILE_COMPAT)
info_cfg_option(WITH_GL_PROFILE_CORE)
info_cfg_option(WITH_GL_PROFILE_ES20) info_cfg_option(WITH_GL_PROFILE_ES20)
if(WIN32) if(WIN32)
info_cfg_option(WITH_GL_ANGLE) info_cfg_option(WITH_GL_ANGLE)

View File

@@ -423,7 +423,7 @@ update: .FORCE
svn update ../lib/* ; \ svn update ../lib/* ; \
fi fi
git pull --rebase git pull --rebase
git submodule foreach git pull --rebase origin master git submodule update --remote
# ----------------------------------------------------------------------------- # -----------------------------------------------------------------------------

View File

@@ -16,19 +16,19 @@
# #
# ***** END GPL LICENSE BLOCK ***** # ***** END GPL LICENSE BLOCK *****
set(SNDFILE_EXTRA_ARGS) set(LIBSNDFILE_EXTRA_ARGS)
set(SNDFILE_ENV PKG_CONFIG_PATH=${mingw_LIBDIR}/ogg/lib/pkgconfig:${mingw_LIBDIR}/vorbis/lib/pkgconfig:${mingw_LIBDIR}/flac/lib/pkgconfig:${mingw_LIBDIR}) set(LIBSNDFILE_ENV PKG_CONFIG_PATH=${mingw_LIBDIR}/ogg/lib/pkgconfig:${mingw_LIBDIR}/vorbis/lib/pkgconfig:${mingw_LIBDIR}/flac/lib/pkgconfig:${mingw_LIBDIR})
if(WIN32) if(WIN32)
set(SNDFILE_ENV set ${SNDFILE_ENV} &&) set(LIBSNDFILE_ENV set ${LIBSNDFILE_ENV} &&)
endif() endif()
ExternalProject_Add(external_sndfile ExternalProject_Add(external_sndfile
URL ${SNDFILE_URI} URL ${LIBSNDFILE_URI}
DOWNLOAD_DIR ${DOWNLOAD_DIR} DOWNLOAD_DIR ${DOWNLOAD_DIR}
URL_HASH MD5=${SNDFILE_HASH} URL_HASH MD5=${LIBSNDFILE_HASH}
PREFIX ${BUILD_DIR}/sndfile PREFIX ${BUILD_DIR}/sndfile
CONFIGURE_COMMAND ${CONFIGURE_ENV} && cd ${BUILD_DIR}/sndfile/src/external_sndfile/ && ${SNDFILE_ENV} ${CONFIGURE_COMMAND} --enable-static --disable-shared --prefix=${mingw_LIBDIR}/sndfile CONFIGURE_COMMAND ${CONFIGURE_ENV} && cd ${BUILD_DIR}/sndfile/src/external_sndfile/ && ${LIBSNDFILE_ENV} ${CONFIGURE_COMMAND} --enable-static --disable-shared --prefix=${mingw_LIBDIR}/sndfile
BUILD_COMMAND ${CONFIGURE_ENV} && cd ${BUILD_DIR}/sndfile/src/external_sndfile/ && make -j${MAKE_THREADS} BUILD_COMMAND ${CONFIGURE_ENV} && cd ${BUILD_DIR}/sndfile/src/external_sndfile/ && make -j${MAKE_THREADS}
INSTALL_COMMAND ${CONFIGURE_ENV} && cd ${BUILD_DIR}/sndfile/src/external_sndfile/ && make install INSTALL_COMMAND ${CONFIGURE_ENV} && cd ${BUILD_DIR}/sndfile/src/external_sndfile/ && make install
INSTALL_DIR ${LIBDIR}/sndfile INSTALL_DIR ${LIBDIR}/sndfile

View File

@@ -216,9 +216,9 @@ set(LAPACK_VERSION 3.6.0)
set(LAPACK_URI http://www.netlib.org/lapack/lapack-${LAPACK_VERSION}.tgz) set(LAPACK_URI http://www.netlib.org/lapack/lapack-${LAPACK_VERSION}.tgz)
set(LAPACK_HASH f2f6c67134e851fe189bb3ca1fbb5101) set(LAPACK_HASH f2f6c67134e851fe189bb3ca1fbb5101)
set(SNDFILE_VERSION 1.0.26) set(LIBSNDFILE_VERSION 1.0.26)
set(SNDFILE_URI http://www.mega-nerd.com/libsndfile/files/libsndfile-${SNDFILE_VERSION}.tar.gz) set(LIBSNDFILE_URI http://www.mega-nerd.com/libsndfile/files/libsndfile-${LIBSNDFILE_VERSION}.tar.gz)
set(SNDFILE_HASH ec810a0c60c08772a8a5552704b63393) set(LIBSNDFILE_HASH ec810a0c60c08772a8a5552704b63393)
#set(HIDAPI_VERSION 0.8.0-rc1) #set(HIDAPI_VERSION 0.8.0-rc1)
#set(HIDAPI_URI https://github.com/signal11/hidapi/archive/hidapi-${HIDAPI_VERSION}.tar.gz) #set(HIDAPI_URI https://github.com/signal11/hidapi/archive/hidapi-${HIDAPI_VERSION}.tar.gz)

View File

@@ -25,7 +25,7 @@
ARGS=$( \ ARGS=$( \
getopt \ getopt \
-o s:i:t:h \ -o s:i:t:h \
--long source:,install:,tmp:,info:,threads:,help,show-deps,no-sudo,no-build,no-confirm,use-cxx11,\ --long source:,install:,tmp:,info:,threads:,help,show-deps,no-sudo,no-build,no-confirm,\
with-all,with-opencollada,with-jack,\ with-all,with-opencollada,with-jack,\
ver-ocio:,ver-oiio:,ver-llvm:,ver-osl:,ver-osd:,ver-openvdb:,\ ver-ocio:,ver-oiio:,ver-llvm:,ver-osl:,ver-osd:,ver-openvdb:,\
force-all,force-python,force-numpy,force-boost,\ force-all,force-python,force-numpy,force-boost,\
@@ -104,11 +104,6 @@ ARGUMENTS_INFO="\"COMMAND LINE ARGUMENTS:
--no-confirm --no-confirm
Disable any interaction with user (suitable for automated run). Disable any interaction with user (suitable for automated run).
--use-cxx11
Build all libraries in cpp11 'mode' (will be mandatory soon in blender2.8 branch).
NOTE: If your compiler is gcc-6.0 or above, you probably *want* to enable this option (since it's default
standard starting from this version).
--with-all --with-all
By default, a number of optional and not-so-often needed libraries are not installed. By default, a number of optional and not-so-often needed libraries are not installed.
This option will try to install them, at the cost of potential conflicts (depending on This option will try to install them, at the cost of potential conflicts (depending on
@@ -290,7 +285,7 @@ SUDO="sudo"
NO_BUILD=false NO_BUILD=false
NO_CONFIRM=false NO_CONFIRM=false
USE_CXX11=false USE_CXX11=true # Mandatory in blender2.8
PYTHON_VERSION="3.5.3" PYTHON_VERSION="3.5.3"
PYTHON_VERSION_MIN="3.5" PYTHON_VERSION_MIN="3.5"
@@ -501,9 +496,6 @@ while true; do
--no-confirm) --no-confirm)
NO_CONFIRM=true; shift; continue NO_CONFIRM=true; shift; continue
;; ;;
--use-cxx11)
USE_CXX11=true; shift; continue
;;
--with-all) --with-all)
WITH_ALL=true; shift; continue WITH_ALL=true; shift; continue
;; ;;
@@ -804,7 +796,7 @@ FFMPEG_SOURCE=( "http://ffmpeg.org/releases/ffmpeg-$FFMPEG_VERSION.tar.bz2" )
CXXFLAGS_BACK=$CXXFLAGS CXXFLAGS_BACK=$CXXFLAGS
if [ "$USE_CXX11" = true ]; then if [ "$USE_CXX11" = true ]; then
WARNING "You are trying to use c++11, this *should* go smoothely with any very recent distribution WARNING "C++11 is now mandatory for blender2.8, this *should* go smoothly with any very recent distribution.
However, if you are experiencing linking errors (also when building Blender itself), please try the following: However, if you are experiencing linking errors (also when building Blender itself), please try the following:
* Re-run this script with '--build-all --force-all' options. * Re-run this script with '--build-all --force-all' options.
* Ensure your gcc version is at the very least 4.8, if possible you should really rather use gcc-5.1 or above. * Ensure your gcc version is at the very least 4.8, if possible you should really rather use gcc-5.1 or above.
@@ -2681,10 +2673,10 @@ install_DEB() {
install_packages_DEB $_packages install_packages_DEB $_packages
PRINT"" PRINT""
SNDFILE_DEV="libsndfile1-dev" LIBSNDFILE_DEV="libsndfile1-dev"
check_package_DEB $SNDFILE_DEV check_package_DEB $LIBSNDFILE_DEV
if [ $? -eq 0 ]; then if [ $? -eq 0 ]; then
install_packages_DEB $SNDFILE_DEV install_packages_DEB $LIBSNDFILE_DEV
fi fi
PRINT "" PRINT ""
@@ -3279,10 +3271,10 @@ install_RPM() {
fi fi
PRINT"" PRINT""
SNDFILE_DEV="libsndfile-devel" LIBSNDFILE_DEV="libsndfile-devel"
check_package_RPM $SNDFILE_DEV check_package_RPM $LIBSNDFILE_DEV
if [ $? -eq 0 ]; then if [ $? -eq 0 ]; then
install_packages_RPM $SNDFILE_DEV install_packages_RPM $LIBSNDFILE_DEV
fi fi
if [ "$WITH_ALL" = true ]; then if [ "$WITH_ALL" = true ]; then
@@ -3686,10 +3678,10 @@ install_ARCH() {
install_packages_ARCH $_packages install_packages_ARCH $_packages
PRINT"" PRINT""
SNDFILE_DEV="libsndfile" LIBSNDFILE_DEV="libsndfile"
check_package_ARCH $SNDFILE_DEV check_package_ARCH $LIBSNDFILE_DEV
if [ $? -eq 0 ]; then if [ $? -eq 0 ]; then
install_packages_ARCH $SNDFILE_DEV install_packages_ARCH $LIBSNDFILE_DEV
fi fi
PRINT "" PRINT ""

View File

@@ -70,11 +70,11 @@ set(FFMPEG_LIBRARIES
) )
# SndFile libraries # SndFile libraries
set(SNDFILE_LIBRARY "/usr/lib/libsndfile.a;/usr/lib/libFLAC.a" CACHE STRING "" FORCE) set(LIBSNDFILE_LIBRARY "/usr/lib/libsndfile.a;/usr/lib/libFLAC.a" CACHE STRING "" FORCE)
# OpenAL libraries # OpenAL libraries
set(OPENAL_ROOT_DIR "/opt/lib/openal" CACHE STRING "" FORCE) set(OPENAL_ROOT_DIR "/opt/lib/openal" CACHE STRING "" FORCE)
set(OPENAL_INCLUDE_DIR "${OPENAL_ROOT_DIR}/include" CACHE STRING "" FORCE) set(OPENAL_INCLUDE_DIR "${OPENAL_ROOT_DIR}/include/AL" CACHE STRING "" FORCE)
set(OPENAL_LIBRARY set(OPENAL_LIBRARY
${OPENAL_ROOT_DIR}/lib/libopenal.a ${OPENAL_ROOT_DIR}/lib/libopenal.a
${OPENAL_ROOT_DIR}/lib/libcommon.a ${OPENAL_ROOT_DIR}/lib/libcommon.a

View File

@@ -9,7 +9,6 @@
# #
# also defined, # also defined,
# GLEW_LIBRARY, where to find the Glew library. # GLEW_LIBRARY, where to find the Glew library.
# GLEW_MX_LIBRARY, where to find the GlewMX library.
#============================================================================= #=============================================================================
# Copyright 2014 Blender Foundation. # Copyright 2014 Blender Foundation.
@@ -50,16 +49,6 @@ FIND_LIBRARY(GLEW_LIBRARY
lib64 lib lib64 lib
) )
FIND_LIBRARY(GLEW_MX_LIBRARY
NAMES
GLEWmx
HINTS
${_glew_SEARCH_DIRS}
PATH_SUFFIXES
lib64 lib
)
# handle the QUIETLY and REQUIRED arguments and set GLEW_FOUND to TRUE if # handle the QUIETLY and REQUIRED arguments and set GLEW_FOUND to TRUE if
# all listed variables are TRUE # all listed variables are TRUE
INCLUDE(FindPackageHandleStandardArgs) INCLUDE(FindPackageHandleStandardArgs)
@@ -73,7 +62,6 @@ ENDIF(GLEW_FOUND)
MARK_AS_ADVANCED( MARK_AS_ADVANCED(
GLEW_INCLUDE_DIR GLEW_INCLUDE_DIR
GLEW_LIBRARY GLEW_LIBRARY
GLEW_MX_LIBRARY
) )
UNSET(_glew_SEARCH_DIRS) UNSET(_glew_SEARCH_DIRS)

View File

@@ -1,15 +1,15 @@
# - Find SndFile library # - Find SndFile library
# Find the native SndFile includes and library # Find the native SndFile includes and library
# This module defines # This module defines
# SNDFILE_INCLUDE_DIRS, where to find sndfile.h, Set when # LIBSNDFILE_INCLUDE_DIRS, where to find sndfile.h, Set when
# SNDFILE_INCLUDE_DIR is found. # LIBSNDFILE_INCLUDE_DIR is found.
# SNDFILE_LIBRARIES, libraries to link against to use SndFile. # LIBSNDFILE_LIBRARIES, libraries to link against to use SndFile.
# SNDFILE_ROOT_DIR, The base directory to search for SndFile. # LIBSNDFILE_ROOT_DIR, The base directory to search for SndFile.
# This can also be an environment variable. # This can also be an environment variable.
# SNDFILE_FOUND, If false, do not try to use SndFile. # LIBSNDFILE_FOUND, If false, do not try to use SndFile.
# #
# also defined, but not for general use are # also defined, but not for general use are
# SNDFILE_LIBRARY, where to find the SndFile library. # LIBSNDFILE_LIBRARY, where to find the SndFile library.
#============================================================================= #=============================================================================
# Copyright 2011 Blender Foundation. # Copyright 2011 Blender Foundation.
@@ -22,27 +22,27 @@
# See the License for more information. # See the License for more information.
#============================================================================= #=============================================================================
# If SNDFILE_ROOT_DIR was defined in the environment, use it. # If LIBSNDFILE_ROOT_DIR was defined in the environment, use it.
IF(NOT SNDFILE_ROOT_DIR AND NOT $ENV{SNDFILE_ROOT_DIR} STREQUAL "") IF(NOT LIBSNDFILE_ROOT_DIR AND NOT $ENV{LIBSNDFILE_ROOT_DIR} STREQUAL "")
SET(SNDFILE_ROOT_DIR $ENV{SNDFILE_ROOT_DIR}) SET(LIBSNDFILE_ROOT_DIR $ENV{LIBSNDFILE_ROOT_DIR})
ENDIF() ENDIF()
SET(_sndfile_SEARCH_DIRS SET(_sndfile_SEARCH_DIRS
${SNDFILE_ROOT_DIR} ${LIBSNDFILE_ROOT_DIR}
/usr/local /usr/local
/sw # Fink /sw # Fink
/opt/local # DarwinPorts /opt/local # DarwinPorts
/opt/csw # Blastwave /opt/csw # Blastwave
) )
FIND_PATH(SNDFILE_INCLUDE_DIR sndfile.h FIND_PATH(LIBSNDFILE_INCLUDE_DIR sndfile.h
HINTS HINTS
${_sndfile_SEARCH_DIRS} ${_sndfile_SEARCH_DIRS}
PATH_SUFFIXES PATH_SUFFIXES
include include
) )
FIND_LIBRARY(SNDFILE_LIBRARY FIND_LIBRARY(LIBSNDFILE_LIBRARY
NAMES NAMES
sndfile sndfile
HINTS HINTS
@@ -51,18 +51,18 @@ FIND_LIBRARY(SNDFILE_LIBRARY
lib64 lib lib64 lib
) )
# handle the QUIETLY and REQUIRED arguments and set SNDFILE_FOUND to TRUE if # handle the QUIETLY and REQUIRED arguments and set LIBSNDFILE_FOUND to TRUE if
# all listed variables are TRUE # all listed variables are TRUE
INCLUDE(FindPackageHandleStandardArgs) INCLUDE(FindPackageHandleStandardArgs)
FIND_PACKAGE_HANDLE_STANDARD_ARGS(SndFile DEFAULT_MSG FIND_PACKAGE_HANDLE_STANDARD_ARGS(SndFile DEFAULT_MSG
SNDFILE_LIBRARY SNDFILE_INCLUDE_DIR) LIBSNDFILE_LIBRARY LIBSNDFILE_INCLUDE_DIR)
IF(SNDFILE_FOUND) IF(LIBSNDFILE_FOUND)
SET(SNDFILE_LIBRARIES ${SNDFILE_LIBRARY}) SET(LIBSNDFILE_LIBRARIES ${LIBSNDFILE_LIBRARY})
SET(SNDFILE_INCLUDE_DIRS ${SNDFILE_INCLUDE_DIR}) SET(LIBSNDFILE_INCLUDE_DIRS ${LIBSNDFILE_INCLUDE_DIR})
ENDIF(SNDFILE_FOUND) ENDIF(LIBSNDFILE_FOUND)
MARK_AS_ADVANCED( MARK_AS_ADVANCED(
SNDFILE_INCLUDE_DIR LIBSNDFILE_INCLUDE_DIR
SNDFILE_LIBRARY LIBSNDFILE_LIBRARY
) )

View File

@@ -318,7 +318,7 @@ function(SETUP_LIBDIRS)
link_directories(${JACK_LIBPATH}) link_directories(${JACK_LIBPATH})
endif() endif()
if(WITH_CODEC_SNDFILE) if(WITH_CODEC_SNDFILE)
link_directories(${SNDFILE_LIBPATH}) link_directories(${LIBSNDFILE_LIBPATH})
endif() endif()
if(WITH_FFTW3) if(WITH_FFTW3)
link_directories(${FFTW3_LIBPATH}) link_directories(${FFTW3_LIBPATH})
@@ -398,7 +398,7 @@ function(setup_liblinks
target_link_libraries(${target} ${JACK_LIBRARIES}) target_link_libraries(${target} ${JACK_LIBRARIES})
endif() endif()
if(WITH_CODEC_SNDFILE) if(WITH_CODEC_SNDFILE)
target_link_libraries(${target} ${SNDFILE_LIBRARIES}) target_link_libraries(${target} ${LIBSNDFILE_LIBRARIES})
endif() endif()
if(WITH_SDL AND NOT WITH_SDL_DYNLOAD) if(WITH_SDL AND NOT WITH_SDL_DYNLOAD)
target_link_libraries(${target} ${SDL_LIBRARY}) target_link_libraries(${target} ${SDL_LIBRARY})
@@ -549,6 +549,12 @@ function(SETUP_BLENDER_SORTED_LIBS)
endif() endif()
endif() endif()
if(WITH_AUDASPACE AND NOT WITH_SYSTEM_AUDASPACE)
list(APPEND BLENDER_LINK_LIBS
audaspace
audaspace-py)
endif()
# Sort libraries # Sort libraries
set(BLENDER_SORTED_LIBS set(BLENDER_SORTED_LIBS
bf_windowmanager bf_windowmanager
@@ -579,12 +585,15 @@ function(SETUP_BLENDER_SORTED_LIBS)
bf_editor_curve bf_editor_curve
bf_editor_gpencil bf_editor_gpencil
bf_editor_interface bf_editor_interface
bf_editor_manipulator_library
bf_editor_mesh bf_editor_mesh
bf_editor_metaball bf_editor_metaball
bf_editor_object bf_editor_object
bf_editor_armature bf_editor_armature
bf_editor_physics bf_editor_physics
bf_editor_hair
bf_editor_render bf_editor_render
bf_editor_scene
bf_editor_screen bf_editor_screen
bf_editor_sculpt_paint bf_editor_sculpt_paint
bf_editor_sound bf_editor_sound
@@ -597,6 +606,7 @@ function(SETUP_BLENDER_SORTED_LIBS)
bf_python bf_python
bf_python_ext bf_python_ext
bf_python_mathutils bf_python_mathutils
bf_python_gawain
bf_python_bmesh bf_python_bmesh
bf_freestyle bf_freestyle
bf_ikplugin bf_ikplugin
@@ -604,11 +614,14 @@ function(SETUP_BLENDER_SORTED_LIBS)
bf_alembic bf_alembic
bf_bmesh bf_bmesh
bf_gpu bf_gpu
bf_draw
bf_blenloader bf_blenloader
bf_blenkernel bf_blenkernel
bf_physics bf_physics
bf_nodes bf_nodes
bf_rna bf_rna
bf_editor_manipulator_library # rna -> manipulator bad-level calls
bf_python
bf_imbuf bf_imbuf
bf_blenlib bf_blenlib
bf_depsgraph bf_depsgraph
@@ -649,6 +662,8 @@ function(SETUP_BLENDER_SORTED_LIBS)
bf_blenfont bf_blenfont
bf_blentranslation bf_blentranslation
bf_intern_audaspace bf_intern_audaspace
audaspace
audaspace-py
bf_intern_mikktspace bf_intern_mikktspace
bf_intern_dualcon bf_intern_dualcon
bf_intern_cycles bf_intern_cycles
@@ -660,6 +675,7 @@ function(SETUP_BLENDER_SORTED_LIBS)
cycles_util cycles_util
cycles_subd cycles_subd
bf_intern_opencolorio bf_intern_opencolorio
bf_intern_gawain
bf_intern_eigen bf_intern_eigen
extern_rangetree extern_rangetree
extern_wcwidth extern_wcwidth
@@ -1503,6 +1519,7 @@ function(find_python_package
NAMES NAMES
${package} ${package}
HINTS HINTS
"${PYTHON_LIBPATH}/"
"${PYTHON_LIBPATH}/python${PYTHON_VERSION}/" "${PYTHON_LIBPATH}/python${PYTHON_VERSION}/"
"${PYTHON_LIBPATH}/python${_PY_VER_MAJOR}/" "${PYTHON_LIBPATH}/python${_PY_VER_MAJOR}/"
PATH_SUFFIXES PATH_SUFFIXES

View File

@@ -23,6 +23,8 @@
# Libraries configuration for Apple. # Libraries configuration for Apple.
set(MACOSX_DEPLOYMENT_TARGET "10.9")
macro(find_package_wrapper) macro(find_package_wrapper)
# do nothing, just satisfy the macro # do nothing, just satisfy the macro
endmacro() endmacro()
@@ -44,7 +46,7 @@ if(WITH_OPENAL)
find_package(OpenAL) find_package(OpenAL)
if(OPENAL_FOUND) if(OPENAL_FOUND)
set(WITH_OPENAL ON) set(WITH_OPENAL ON)
set(OPENAL_INCLUDE_DIR "${LIBDIR}/openal/include") set(OPENAL_INCLUDE_DIR "${LIBDIR}/openal/include/AL")
else() else()
set(WITH_OPENAL OFF) set(WITH_OPENAL OFF)
endif() endif()
@@ -80,10 +82,10 @@ if(WITH_JACK)
endif() endif()
if(WITH_CODEC_SNDFILE) if(WITH_CODEC_SNDFILE)
set(SNDFILE ${LIBDIR}/sndfile) set(LIBSNDFILE ${LIBDIR}/sndfile)
set(SNDFILE_INCLUDE_DIRS ${SNDFILE}/include) set(LIBSNDFILE_INCLUDE_DIRS ${LIBSNDFILE}/include)
set(SNDFILE_LIBRARIES sndfile FLAC ogg vorbis vorbisenc) set(LIBSNDFILE_LIBRARIES sndfile FLAC ogg vorbis vorbisenc)
set(SNDFILE_LIBPATH ${SNDFILE}/lib ${LIBDIR}/ffmpeg/lib) # TODO, deprecate set(LIBSNDFILE_LIBPATH ${LIBSNDFILE}/lib ${LIBDIR}/ffmpeg/lib) # TODO, deprecate
endif() endif()
if(WITH_PYTHON) if(WITH_PYTHON)

View File

@@ -135,7 +135,7 @@ endif()
# Codecs # Codecs
if(WITH_CODEC_SNDFILE) if(WITH_CODEC_SNDFILE)
find_package_wrapper(SndFile) find_package_wrapper(SndFile)
if(NOT SNDFILE_FOUND) if(NOT LIBSNDFILE_FOUND)
set(WITH_CODEC_SNDFILE OFF) set(WITH_CODEC_SNDFILE OFF)
endif() endif()
endif() endif()

View File

@@ -36,7 +36,7 @@ set(WINTAB_INC ${LIBDIR}/wintab/include)
if(WITH_OPENAL) if(WITH_OPENAL)
set(OPENAL ${LIBDIR}/openal) set(OPENAL ${LIBDIR}/openal)
set(OPENALDIR ${LIBDIR}/openal) set(OPENALDIR ${LIBDIR}/openal)
set(OPENAL_INCLUDE_DIR ${OPENAL}/include) set(OPENAL_INCLUDE_DIR ${OPENAL}/include/AL)
if(MSVC) if(MSVC)
set(OPENAL_LIBRARY openal32) set(OPENAL_LIBRARY openal32)
else() else()
@@ -46,10 +46,10 @@ if(WITH_OPENAL)
endif() endif()
if(WITH_CODEC_SNDFILE) if(WITH_CODEC_SNDFILE)
set(SNDFILE ${LIBDIR}/sndfile) set(LIBSNDFILE ${LIBDIR}/sndfile)
set(SNDFILE_INCLUDE_DIRS ${SNDFILE}/include) set(LIBSNDFILE_INCLUDE_DIRS ${LIBSNDFILE}/include)
set(SNDFILE_LIBRARIES libsndfile-1) set(LIBSNDFILE_LIBRARIES libsndfile-1)
set(SNDFILE_LIBPATH ${SNDFILE}/lib) # TODO, deprecate set(LIBSNDFILE_LIBPATH ${LIBSNDFILE}/lib) # TODO, deprecate
endif() endif()
if(WITH_RAYOPTIMIZATION AND SUPPORT_SSE_BUILD) if(WITH_RAYOPTIMIZATION AND SUPPORT_SSE_BUILD)

View File

@@ -223,6 +223,10 @@
* \ingroup editors * \ingroup editors
*/ */
/** \defgroup edscene scene
* \ingroup editors
*/
/** \defgroup edsculpt sculpt and paint /** \defgroup edsculpt sculpt and paint
* \ingroup editors * \ingroup editors
*/ */

View File

@@ -0,0 +1,29 @@
"""
Manipulator Overview
--------------------
Manipulators are created using two classes.
- :class:`bpy.types.ManipulatorGroup` - stores a list of manipulators.
The manipulator group is associated with a space and region type.
- :class:`bpy.types.Manipulator` - a single item which can be used.
Each manipulator group has a collection of manipulators which it manages.
The following example shows a manipulator group with a single,
manipulator used to control a lamp objects energy.
.. literalinclude:: __/__/__/release/scripts/templates_py/manipulator_simple.py
It's also possible to use a manipulator to run an operator.
.. literalinclude:: __/__/__/release/scripts/templates_py/manipulator_operator_target.py
This more comprehensive example shows how an operator can create a temporary manipulator group to adjust its settings.
.. literalinclude:: __/__/__/release/scripts/templates_py/manipulator_operator.py
"""

View File

@@ -52,6 +52,7 @@ class OffScreenDraw(bpy.types.Operator):
@staticmethod @staticmethod
def _update_offscreen(context, offscreen): def _update_offscreen(context, offscreen):
scene = context.scene scene = context.scene
render_layer = context.render_layer
render = scene.render render = scene.render
camera = scene.camera camera = scene.camera
@@ -65,6 +66,7 @@ class OffScreenDraw(bpy.types.Operator):
offscreen.draw_view3d( offscreen.draw_view3d(
scene, scene,
render_layer,
context.space_data, context.space_data,
context.region, context.region,
projection_matrix, projection_matrix,

View File

@@ -332,6 +332,9 @@ except ImportError:
# to avoid having to match Blender's source tree. # to avoid having to match Blender's source tree.
EXTRA_SOURCE_FILES = ( EXTRA_SOURCE_FILES = (
"../../../release/scripts/templates_py/bmesh_simple.py", "../../../release/scripts/templates_py/bmesh_simple.py",
"../../../release/scripts/templates_py/manipulator_operator.py",
"../../../release/scripts/templates_py/manipulator_operator_target.py",
"../../../release/scripts/templates_py/manipulator_simple.py",
"../../../release/scripts/templates_py/operator_simple.py", "../../../release/scripts/templates_py/operator_simple.py",
"../../../release/scripts/templates_py/ui_panel_simple.py", "../../../release/scripts/templates_py/ui_panel_simple.py",
"../../../release/scripts/templates_py/ui_previews_custom_icon.py", "../../../release/scripts/templates_py/ui_previews_custom_icon.py",
@@ -1024,6 +1027,7 @@ context_type_map = {
"brush": ("Brush", False), "brush": ("Brush", False),
"camera": ("Camera", False), "camera": ("Camera", False),
"cloth": ("ClothModifier", False), "cloth": ("ClothModifier", False),
"collection": ("LayerCollection", False),
"collision": ("CollisionModifier", False), "collision": ("CollisionModifier", False),
"curve": ("Curve", False), "curve": ("Curve", False),
"dynamic_paint": ("DynamicPaintModifier", False), "dynamic_paint": ("DynamicPaintModifier", False),
@@ -1044,6 +1048,7 @@ context_type_map = {
"image_paint_object": ("Object", False), "image_paint_object": ("Object", False),
"lamp": ("Lamp", False), "lamp": ("Lamp", False),
"lattice": ("Lattice", False), "lattice": ("Lattice", False),
"lightprobe": ("LightProbe", False),
"line_style": ("FreestyleLineStyle", False), "line_style": ("FreestyleLineStyle", False),
"material": ("Material", False), "material": ("Material", False),
"material_slot": ("MaterialSlot", False), "material_slot": ("MaterialSlot", False),
@@ -1055,6 +1060,7 @@ context_type_map = {
"particle_system": ("ParticleSystem", False), "particle_system": ("ParticleSystem", False),
"particle_system_editable": ("ParticleSystem", False), "particle_system_editable": ("ParticleSystem", False),
"pose_bone": ("PoseBone", False), "pose_bone": ("PoseBone", False),
"render_layer": ("SceneLayer", False),
"scene": ("Scene", False), "scene": ("Scene", False),
"sculpt_object": ("Object", False), "sculpt_object": ("Object", False),
"selectable_bases": ("ObjectBase", True), "selectable_bases": ("ObjectBase", True),

View File

@@ -113,3 +113,8 @@ endif()
if(WITH_SDL AND WITH_SDL_DYNLOAD) if(WITH_SDL AND WITH_SDL_DYNLOAD)
add_subdirectory(sdlew) add_subdirectory(sdlew)
endif() endif()
if(WITH_AUDASPACE AND NOT WITH_SYSTEM_AUDASPACE)
set(AUDASPACE_CMAKE_CFG ${CMAKE_CURRENT_SOURCE_DIR}/audaspace/blender_config.cmake)
add_subdirectory(audaspace)
endif()

16
extern/audaspace/AUTHORS vendored Normal file
View File

@@ -0,0 +1,16 @@
Main author: Jörg Müller <nexyon@gmail.com>
Minor improvements have been done while audaspace was an internal part of Blender by
- Campbell Barton (bug fixes and cleanup)
- Brecht Van Lommel (bug fixes and cleanup)
- Sergey Sharybin (bug fixes and cleanup)
- Nathan Letwory (bug fixes and cleanup)
- Peter Schlaile (ffmpeg)
- Jens Verwiebe (jack on Apple)
The first three of them were employed by the Blender Foundation during that time.
Some features (random sounds, dynamic music, playback manager, convolution and HRTFs support) were added as part of the VALS (Virtual Alliances for Learning Society) project by
- Juan Francisco Crespo Galán <dethon_5@outlook.com>

115
extern/audaspace/CHANGES vendored Normal file
View File

@@ -0,0 +1,115 @@
Audaspace 1.3
=============
- New features:
- linear interpolation for volume changes in the software mixer
- dynamic Loading for JACK
- Bug fixes:
- renamed Jack to JACK
- C API was not working
- filter python API parameter check
- finding ffmpeg with pkgconfig
64884a7 Windows fixes.
53ba3e6 Implemented JACK dynamic loading.
5ee0ee1 Continues last commit.
c24b384 Trying to fix travis-ci python versioning once and for all (at least for python3).
1fbf3bf Rename Jack => JACK where possible.
6e4b31f Implemented linear interpolation for volume changes in the software mixer.
817043c Fixing C API not working.
c384daf Maybe travis-ci works now.
aa7ddd7 Fix (hopefully) for previous commit.
57c5dd7 Configure MACOSX_DEPLOYMENT_TARGET for travis-ci.
7ae6ff9 Fix travis-ci python path.
552fea4 Added posibillity to use math constants on MinGW
c18ed59 Bugfix: incorrect parameter check in python API.
6f048c3 CMake: fix finding ffmpeg with pkgconfig.
Audaspace 1.2
=============
- New features:
- sound list
- random sounds
- dynamic music playing
- playback manager
- convolution/reverbation
- multi-threading
- binaural audio
- API changes:
- changing default sample rate from 44.1 to 48 kHz
- Bug fixes:
- several standard library fixes.
- Bindings API:
- mixdown C API refactored
- CMake/Building:
- assuring numpy is installed
- building the Python module on Mac OS X with CMake
a6b6e70 Changing default sample rate from 44.1 to 48 kHz.
20f0164 Bugfix: CMake custom command for python module on OS X.
98679a2 Bugfix: using standard library (s)rand.
5ab4fe7 Bugfix: first step in fixing the vector of array problem.
e83f01d FFTW: trying to use complex to circumvent vector of array problem.
093ebc0 Bugfix: abs -> std::fabs.
328d7cc Bugfix: standard library include and call fixes.
f78e330 Bugfix: using correct includes.
64d7825 Behavior change: C API Mixdown
749896b Merge pull request #3 from DethonUSAL/master
6e9491c CMake: finding NumPy.
Audaspace 1.1
=============
- Bug fixes:
- pkgconfig uses cmake configured library directory
- FFMPEG file writing crashed, also corrected pts for encoding
- silenced Doxygen warnings about undefined defines
- C++ API:
- ResampleReader uses specs instead of sample rate
- Bindings API:
- writing sounds to files
- reading sound data, specs and length
- resampling sounds
- CMake/Building:
- first steps towards building for Mac
- windows builds copy dlls automatically
- Python module:
- using distutils instead of setuptools
- added numpy as dependency
- Documentation:
- added windows building and plugin documentation
- disabled html timestamps in doxygen
- updated sphinx template
- build binding documentation without installing the python module
Detailed list of changes:
326a300 Documentation: windows, dll copying now done automatically.
54cac4f Windows: install dlls.
65c2d78 Bindings: Sound length and specs properties.
c38da70 Bindings API: adding resampling.
374822f Documentation: Added windows and plugin documentation.
a9dc5b9 Python module: add numpy as dependency.
c933a02 C API: implement new API based on the python API.
ac54c52 Python API: silence numpy warnings.
c9491bb Python API: checking for a positive sample rate.
4eb1fa8 Python API: reorder functions.
ec7c00b Sphinx update and fixes.
e16d979 FFMPEG: correct pts during encoding.
7ab3935 Documentation: git path fix.
28d77bb Python: use distutils directly instead of setuptools.
1f43284 Silence doxygen warning about undefined defines.
0d52458 CMake: improvements and fixes for building on Mac.
37daedf FFMPEG: bugfixes for file writing.
780ca2a ResampleReader API change
4d9863d Python API: Optimization for cached sounds' data access.
ea04fee Python API: read sound data and create sound buffers as well as getting the specs of a sound.
335b293 Python sound writing API.
36a7252 Pkgconfig: use cmake configured library directory.
5503908 Doxygen: disable html timestamps.
Initial Release of Audaspace 1.0
================================
Audaspace has been the internal audio library of blender since blender 2.5. It is now released as a standalone library to be used in other projects as well.

983
extern/audaspace/CMakeLists.txt vendored Normal file
View File

@@ -0,0 +1,983 @@
################################################################################
# Copyright 2009-2016 Jörg Müller
#
# 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.
################################################################################
cmake_minimum_required(VERSION 3.1)
include(CMakeDependentOption)
if(POLICY CMP0054)
cmake_policy(SET CMP0054 NEW)
endif()
project(audaspace)
set(AUDASPACE_VERSION 1.3)
set(AUDASPACE_LONG_VERSION ${AUDASPACE_VERSION}.0)
if(DEFINED AUDASPACE_CMAKE_CFG)
include(${AUDASPACE_CMAKE_CFG})
endif()
if(NOT DEFINED AUDASPACE_STANDALONE)
set(AUDASPACE_STANDALONE TRUE)
endif()
# sources
set(SRC
src/devices/DefaultSynchronizer.cpp
src/devices/DeviceManager.cpp
src/devices/NULLDevice.cpp
src/devices/ReadDevice.cpp
src/devices/SoftwareDevice.cpp
src/Exception.cpp
src/file/File.cpp
src/file/FileManager.cpp
src/file/FileWriter.cpp
src/fx/Accumulator.cpp
src/fx/ADSR.cpp
src/fx/ADSRReader.cpp
src/fx/BaseIIRFilterReader.cpp
src/fx/ButterworthCalculator.cpp
src/fx/Butterworth.cpp
src/fx/CallbackIIRFilterReader.cpp
src/fx/Delay.cpp
src/fx/DelayReader.cpp
src/fx/DynamicIIRFilter.cpp
src/fx/DynamicIIRFilterReader.cpp
src/fx/DynamicMusic.cpp
src/fx/Effect.cpp
src/fx/EffectReader.cpp
src/fx/Envelope.cpp
src/fx/Fader.cpp
src/fx/FaderReader.cpp
src/fx/HighpassCalculator.cpp
src/fx/Highpass.cpp
src/fx/IIRFilter.cpp
src/fx/IIRFilterReader.cpp
src/fx/Limiter.cpp
src/fx/LimiterReader.cpp
src/fx/Loop.cpp
src/fx/LoopReader.cpp
src/fx/LowpassCalculator.cpp
src/fx/Lowpass.cpp
src/fx/MutableReader.cpp
src/fx/MutableSound.cpp
src/fx/Pitch.cpp
src/fx/PitchReader.cpp
src/fx/PlaybackManager.cpp
src/fx/PlaybackCategory.cpp
src/fx/Reverse.cpp
src/fx/ReverseReader.cpp
src/fx/SoundList.cpp
src/fx/Source.cpp
src/fx/Sum.cpp
src/fx/Threshold.cpp
src/fx/Volume.cpp
src/fx/VolumeReader.cpp
src/fx/VolumeSound.cpp
src/fx/VolumeStorage.cpp
src/generator/Sawtooth.cpp
src/generator/SawtoothReader.cpp
src/generator/Silence.cpp
src/generator/SilenceReader.cpp
src/generator/Sine.cpp
src/generator/SineReader.cpp
src/generator/Square.cpp
src/generator/SquareReader.cpp
src/generator/Triangle.cpp
src/generator/TriangleReader.cpp
src/respec/ChannelMapper.cpp
src/respec/ChannelMapperReader.cpp
src/respec/Converter.cpp
src/respec/ConverterFunctions.cpp
src/respec/ConverterReader.cpp
src/respec/JOSResample.cpp
src/respec/JOSResampleReaderCoeff.cpp
src/respec/JOSResampleReader.cpp
src/respec/LinearResample.cpp
src/respec/LinearResampleReader.cpp
src/respec/Mixer.cpp
src/respec/ResampleReader.cpp
src/respec/SpecsChanger.cpp
src/sequence/AnimateableProperty.cpp
src/sequence/Double.cpp
src/sequence/DoubleReader.cpp
src/sequence/PingPong.cpp
src/sequence/Sequence.cpp
src/sequence/SequenceData.cpp
src/sequence/SequenceEntry.cpp
src/sequence/SequenceHandle.cpp
src/sequence/SequenceReader.cpp
src/sequence/Superpose.cpp
src/sequence/SuperposeReader.cpp
src/util/Barrier.cpp
src/util/Buffer.cpp
src/util/BufferReader.cpp
src/util/StreamBuffer.cpp
src/util/ThreadPool.cpp
)
set(PRIVATE_HDR
src/sequence/SequenceHandle.h
)
set(PUBLIC_HDR
include/devices/DefaultSynchronizer.h
include/devices/DeviceManager.h
include/devices/I3DDevice.h
include/devices/I3DHandle.h
include/devices/IDeviceFactory.h
include/devices/IDevice.h
include/devices/IHandle.h
include/devices/ISynchronizer.h
include/devices/NULLDevice.h
include/devices/ReadDevice.h
include/devices/SoftwareDevice.h
include/Exception.h
include/file/File.h
include/file/FileManager.h
include/file/FileWriter.h
include/file/IFileInput.h
include/file/IFileOutput.h
include/file/IWriter.h
include/fx/Accumulator.h
include/fx/ADSR.h
include/fx/ADSRReader.h
include/fx/BaseIIRFilterReader.h
include/fx/ButterworthCalculator.h
include/fx/Butterworth.h
include/fx/CallbackIIRFilterReader.h
include/fx/Delay.h
include/fx/DelayReader.h
include/fx/DynamicIIRFilter.h
include/fx/DynamicIIRFilterReader.h
include/fx/DynamicMusic.h
include/fx/Effect.h
include/fx/EffectReader.h
include/fx/Envelope.h
include/fx/Fader.h
include/fx/FaderReader.h
include/fx/HighpassCalculator.h
include/fx/Highpass.h
include/fx/IDynamicIIRFilterCalculator.h
include/fx/IIRFilter.h
include/fx/IIRFilterReader.h
include/fx/Limiter.h
include/fx/LimiterReader.h
include/fx/Loop.h
include/fx/LoopReader.h
include/fx/LowpassCalculator.h
include/fx/Lowpass.h
include/fx/MutableReader.h
include/fx/MutableSound.h
include/fx/Pitch.h
include/fx/PitchReader.h
include/fx/PlaybackManager.h
include/fx/PlaybackCategory.h
include/fx/Reverse.h
include/fx/ReverseReader.h
include/fx/SoundList.h
include/fx/Source.h
include/fx/Sum.h
include/fx/Threshold.h
include/fx/Volume.h
include/fx/VolumeReader.h
include/fx/VolumeSound.h
include/fx/VolumeStorage.h
include/generator/Sawtooth.h
include/generator/SawtoothReader.h
include/generator/Silence.h
include/generator/SilenceReader.h
include/generator/Sine.h
include/generator/SineReader.h
include/generator/Square.h
include/generator/SquareReader.h
include/generator/Triangle.h
include/generator/TriangleReader.h
include/IReader.h
include/ISound.h
include/plugin/PluginManager.h
include/respec/ChannelMapper.h
include/respec/ChannelMapperReader.h
include/respec/ConverterFunctions.h
include/respec/Converter.h
include/respec/ConverterReader.h
include/respec/JOSResample.h
include/respec/JOSResampleReader.h
include/respec/LinearResample.h
include/respec/LinearResampleReader.h
include/respec/Mixer.h
include/respec/ResampleReader.h
include/respec/Specification.h
include/respec/SpecsChanger.h
include/sequence/AnimateableProperty.h
include/sequence/Double.h
include/sequence/DoubleReader.h
include/sequence/PingPong.h
include/sequence/SequenceData.h
include/sequence/SequenceEntry.h
include/sequence/Sequence.h
include/sequence/SequenceReader.h
include/sequence/Superpose.h
include/sequence/SuperposeReader.h
include/util/Barrier.h
include/util/Buffer.h
include/util/BufferReader.h
include/util/ILockable.h
include/util/Math3D.h
include/util/StreamBuffer.h
include/util/ThreadPool.h
)
set(HDR ${PRIVATE_HDR} ${PUBLIC_HDR})
set(INCLUDE ${CMAKE_CURRENT_BINARY_DIR} include)
if(WIN32)
set(LIBRARIES)
if(AUDASPACE_STANDALONE)
set(DLLS)
set(LIBRARY_PATH "../lib" CACHE PATH "Path which contains the libraries.")
file(GLOB LIBRARY_DIRS ${LIBRARY_PATH}/*)
list(APPEND CMAKE_PREFIX_PATH ${LIBRARY_DIRS})
endif()
else()
set(LIBRARIES ${CMAKE_DL_LIBS} -lpthread)
endif()
set(STATIC_PLUGINS "")
# dependencies
if(AUDASPACE_STANDALONE)
set(PACKAGE_OPTION QUIET)
list(APPEND CMAKE_MODULE_PATH "${PROJECT_SOURCE_DIR}/cmake/")
option(BUILD_DEMOS "Build and install demos" TRUE)
option(SHARED_LIBRARY "Build Shared Library" TRUE)
option(WITH_C "Build C Module" TRUE)
option(WITH_DOCS "Build C++ HTML Documentation with Doxygen" TRUE)
option(WITH_FFMPEG "Build With FFMPEG" TRUE)
option(WITH_FFTW "Build With FFTW" TRUE)
option(WITH_JACK "Build With Plugin" TRUE)
option(WITH_LIBSNDFILE "Build With LibSndFile" TRUE)
option(WITH_OPENAL "Build With OpenAL" TRUE)
option(WITH_PYTHON "Build With Python Library" TRUE)
option(WITH_SDL "Build With SDL" TRUE)
option(WITH_STRICT_DEPENDENCIES "Error and abort instead of warning if a library is not found." FALSE)
if(WITH_STRICT_DEPENDENCIES)
set(PACKAGE_OPTION REQUIRED)
endif()
endif()
if(WIN32)
set(DEFAULT_PLUGIN_PATH "." CACHE STRING "Default plugin installation and loading path.")
set(DOCUMENTATION_INSTALL_PATH "doc" CACHE PATH "Path where the documentation is installed.")
else()
set(DEFAULT_PLUGIN_PATH "${CMAKE_INSTALL_PREFIX}/share/audaspace/plugins" CACHE STRING "Default plugin installation and loading path.")
set(DOCUMENTATION_INSTALL_PATH "share/doc/audaspace" CACHE PATH "Path where the documentation is installed.")
endif()
if(AUDASPACE_STANDALONE)
cmake_dependent_option(SEPARATE_C "Build C Binding as separate library" TRUE "WITH_C" FALSE)
cmake_dependent_option(PLUGIN_FFMPEG "Build FFMPEG Plugin" TRUE "WITH_FFMPEG;SHARED_LIBRARY" FALSE)
cmake_dependent_option(PLUGIN_JACK "Build JACK Plugin" TRUE "WITH_JACK;SHARED_LIBRARY" FALSE)
cmake_dependent_option(PLUGIN_LIBSNDFILE "Build LibSndFile Plugin" TRUE "WITH_LIBSNDFILE;SHARED_LIBRARY" FALSE)
cmake_dependent_option(PLUGIN_OPENAL "Build OpenAL Plugin" TRUE "WITH_OPENAL;SHARED_LIBRARY" FALSE)
cmake_dependent_option(PLUGIN_SDL "Build SDL Plugin" TRUE "WITH_SDL;SHARED_LIBRARY" FALSE)
cmake_dependent_option(WITH_PYTHON_MODULE "Build Python Module" TRUE "WITH_PYTHON" FALSE)
cmake_dependent_option(USE_SDL2 "Use SDL2 instead of 1 if available" TRUE "WITH_SDL" FALSE)
cmake_dependent_option(DYNLOAD_JACK "Dynamically load JACK" FALSE "WITH_JACK" FALSE)
cmake_dependent_option(WITH_BINDING_DOCS "Build C/Python HTML Documentation with Sphinx" TRUE "WITH_PYTHON_MODULE" FALSE)
endif()
# compiler options
set(CMAKE_CXX_STANDARD 11)
if(CMAKE_COMPILER_IS_GNUCXX OR "${CMAKE_CXX_COMPILER_ID}" MATCHES "Clang")
list(APPEND CMAKE_C_COMPILER_FLAGS "-fvisibility=hidden")
list(APPEND CMAKE_CXX_COMPILER_FLAGS "-fvisibility=hidden")
endif()
if(MSVC)
if(AUDASPACE_STANDALONE)
list(APPEND CMAKE_C_FLAGS_DEBUG "/Zi /Od")
list(APPEND CMAKE_CXX_FLAGS_DEBUG "/Zi /Od")
list(APPEND CMAKE_SHARED_LINKER_FLAGS_DEBUG "/DEBUG")
list(APPEND CMAKE_STATIC_LINKER_FLAGS_DEBUG "/DEBUG")
list(APPEND CMAKE_EXE_LINKER_FLAGS_DEBUG "/DEBUG")
endif()
add_definitions(
/D_USE_MATH_DEFINES
/EHsc
/DNOMINMAX
/D_STDINT_H
)
if(SHARED_LIBRARY)
include(GenerateExportHeader)
endif()
endif()
if(APPLE AND NOT CMAKE_OSX_DEPLOYMENT_TARGET)
set(CMAKE_OSX_DEPLOYMENT_TARGET "10.9" CACHE STRING "" FORCE)
endif()
# platform specific options
if(MSYS OR MINGW)
add_definitions(-D_USE_MATH_DEFINES)
endif()
# C
if(WITH_C)
set(C_SRC
bindings/C/AUD_ThreadPool.cpp
bindings/C/AUD_Source.cpp
bindings/C/AUD_Device.cpp
bindings/C/AUD_DynamicMusic.cpp
bindings/C/AUD_Handle.cpp
bindings/C/AUD_PlaybackManager.cpp
bindings/C/AUD_Sequence.cpp
bindings/C/AUD_Sound.cpp
bindings/C/AUD_Special.cpp
)
set(C_HDR
bindings/C/AUD_ThreadPool.h
bindings/C/AUD_Source.h
bindings/C/AUD_Device.h
bindings/C/AUD_DynamicMusic.h
bindings/C/AUD_Handle.h
bindings/C/AUD_PlaybackManager.h
bindings/C/AUD_Sequence.h
bindings/C/AUD_Sound.h
bindings/C/AUD_Special.h
bindings/C/AUD_Types.h
)
if(WITH_FFTW)
list(APPEND C_SRC
bindings/C/AUD_HRTF.cpp
bindings/C/AUD_ImpulseResponse.cpp
)
list(APPEND C_HDR
bindings/C/AUD_HRTF.h
bindings/C/AUD_ImpulseResponse.h
)
endif()
if(NOT SEPARATE_C)
list(APPEND SRC ${C_SRC})
list(APPEND HDR ${C_HDR})
else()
set(AUDASPACE_C_LIBRARY -laudaspace-c)
endif()
endif()
# FFMPEG
if(WITH_FFMPEG)
if(AUDASPACE_STANDALONE)
find_package(FFMPEG ${PACKAGE_OPTION})
endif()
if(FFMPEG_FOUND)
set(FFMPEG_SRC
plugins/ffmpeg/FFMPEG.cpp
plugins/ffmpeg/FFMPEGReader.cpp
plugins/ffmpeg/FFMPEGWriter.cpp
)
set(FFMPEG_HDR
plugins/ffmpeg/FFMPEG.h
plugins/ffmpeg/FFMPEGReader.h
plugins/ffmpeg/FFMPEGWriter.h
)
if(NOT PLUGIN_FFMPEG)
list(APPEND INCLUDE ${FFMPEG_INCLUDE_DIRS})
list(APPEND LIBRARIES ${FFMPEG_LIBRARIES})
list(APPEND SRC ${FFMPEG_SRC})
list(APPEND HDR ${FFMPEG_HDR})
list(APPEND STATIC_PLUGINS FFMPEG)
endif()
if(WIN32 AND AUDASPACE_STANDALONE)
file(GLOB FFMPEG_DLLS ${LIBRARY_PATH}/ffmpeg/bin/*.dll)
list(APPEND DLLS ${FFMPEG_DLLS})
endif()
else()
set(WITH_FFMPEG FALSE CACHE BOOL "Build With FFMPEG" FORCE)
message(WARNING "FFMPEG not found, plugin will not be built.")
endif()
endif()
# FFTW
if(WITH_FFTW)
if(AUDASPACE_STANDALONE)
find_package(FFTW ${PACKAGE_OPTION})
endif()
if(FFTW_FOUND)
set(FFTW_SRC
src/fx/BinauralSound.cpp
src/fx/BinauralReader.cpp
src/fx/Convolver.cpp
src/fx/ConvolverReader.cpp
src/fx/ConvolverSound.cpp
src/fx/FFTConvolver.cpp
src/fx/HRTF.cpp
src/fx/ImpulseResponse.cpp
src/util/FFTPlan.cpp
)
set(FFTW_HDR
include/fx/BinauralSound.h
include/fx/BinauralReader.h
include/fx/Convolver.h
include/fx/ConvolverReader.h
include/fx/ConvolverSound.h
include/fx/FFTConvolver.h
include/fx/HRTF.h
include/fx/HRTFLoader.h
include/fx/ImpulseResponse.h
include/util/FFTPlan.h
)
add_definitions(-DWITH_CONVOLUTION)
list(APPEND INCLUDE ${FFTW_INCLUDE_DIR})
list(APPEND LIBRARIES ${FFTW_LIBRARY})
list(APPEND SRC ${FFTW_SRC})
list(APPEND HDR ${FFTW_HDR})
if(WIN32 AND AUDASPACE_STANDALONE)
file(GLOB FFTW_DLLS ${LIBRARY_PATH}/fftw/bin/*.dll)
list(APPEND DLLS ${FFTW_DLLS})
endif()
else()
set(WITH_FFTW FALSE CACHE BOOL "Build With FFTW" FORCE)
message(WARNING "FFTW not found, convolution functionality will not be built.")
endif()
endif()
# JACK
if(WITH_JACK)
if(AUDASPACE_STANDALONE)
find_package(Jack ${PACKAGE_OPTION})
endif()
if(JACK_FOUND)
set(JACK_SRC
plugins/jack/JackDevice.cpp
plugins/jack/JackSynchronizer.cpp
plugins/jack/JackLibrary.cpp
)
set(JACK_HDR
plugins/jack/JackDevice.h
plugins/jack/JackSynchronizer.h
plugins/jack/JackLibrary.h
plugins/jack/JackSymbols.h
)
if(DYNLOAD_JACK)
add_definitions(-DDYNLOAD_JACK)
endif()
if(NOT PLUGIN_JACK)
list(APPEND INCLUDE ${JACK_INCLUDE_DIRS})
if(NOT DYNLOAD_JACK)
list(APPEND LIBRARIES ${JACK_LIBRARIES})
endif()
list(APPEND SRC ${JACK_SRC})
list(APPEND HDR ${JACK_HDR})
list(APPEND STATIC_PLUGINS JackDevice)
endif()
if(WIN32 AND AUDASPACE_STANDALONE)
file(GLOB JACK_DLLS ${LIBRARY_PATH}/jack/bin/*.dll)
list(APPEND DLLS ${JACK_DLLS})
endif()
else()
set(WITH_JACK FALSE CACHE BOOL "Build With JACK" FORCE)
message(WARNING "JACK not found, plugin will not be built.")
endif()
endif()
# LibSndFile
if(WITH_LIBSNDFILE)
if(AUDASPACE_STANDALONE)
find_package(LibSndFile ${PACKAGE_OPTION})
endif()
if(LIBSNDFILE_FOUND)
set(LIBSNDFILE_SRC
plugins/libsndfile/SndFile.cpp
plugins/libsndfile/SndFileReader.cpp
plugins/libsndfile/SndFileWriter.cpp
)
set(LIBSNDFILE_HDR
plugins/libsndfile/SndFile.h
plugins/libsndfile/SndFileReader.h
plugins/libsndfile/SndFileWriter.h
)
if(NOT PLUGIN_LIBSNDFILE)
list(APPEND INCLUDE ${LIBSNDFILE_INCLUDE_DIRS})
list(APPEND LIBRARIES ${LIBSNDFILE_LIBRARIES})
list(APPEND SRC ${LIBSNDFILE_SRC})
list(APPEND HDR ${LIBSNDFILE_HDR})
list(APPEND STATIC_PLUGINS SndFile)
endif()
if(WIN32 AND AUDASPACE_STANDALONE)
file(GLOB LIBSNDFILE_DLLS ${LIBRARY_PATH}/libsndfile/bin/*.dll)
list(APPEND DLLS ${LIBSNDFILE_DLLS})
endif()
else()
set(WITH_LIBSNDFILE FALSE CACHE BOOL "Build With LibSndFile" FORCE)
message(WARNING "LibSndFile not found, plugin will not be built.")
endif()
endif()
# OpenAL
if(WITH_OPENAL)
if(AUDASPACE_STANDALONE)
find_package(OpenAL ${PACKAGE_OPTION})
endif()
if(OPENAL_FOUND)
set(OPENAL_SRC
plugins/openal/OpenALDevice.cpp
plugins/openal/OpenALReader.cpp
)
set(OPENAL_HDR
plugins/openal/OpenALDevice.h
plugins/openal/OpenALReader.h
)
if(NOT PLUGIN_OPENAL)
list(APPEND INCLUDE ${OPENAL_INCLUDE_DIR})
list(APPEND LIBRARIES ${OPENAL_LIBRARY})
list(APPEND SRC ${OPENAL_SRC})
list(APPEND HDR ${OPENAL_HDR})
list(APPEND STATIC_PLUGINS OpenALDevice)
endif()
if(WIN32 AND AUDASPACE_STANDALONE)
file(GLOB OPENAL_DLLS ${LIBRARY_PATH}/OpenAL/bin/*.dll)
list(APPEND DLLS ${OPENAL_DLLS})
endif()
else()
set(WITH_OPENAL FALSE CACHE BOOL "Build With OpenAL" FORCE)
message(WARNING "OpenAL not found, plugin will not be built.")
endif()
endif()
# Python
if(WITH_PYTHON)
if(AUDASPACE_STANDALONE)
find_package(PythonLibs 3.2 ${PACKAGE_OPTION})
find_package(NumPy ${PACKAGE_OPTION})
endif()
if(PYTHONLIBS_FOUND AND NUMPY_FOUND)
list(APPEND INCLUDE ${PYTHON_INCLUDE_DIRS} ${NUMPY_INCLUDE_DIRS})
if(WITH_PYTHON_MODULE)
find_package(PythonInterp 3.2 ${PACKAGE_OPTION})
if(NOT PYTHONINTERP_FOUND)
set(WITH_PYTHON_MODULE FALSE)
message(WARNING "Python interpreter not found, module will not be built.")
endif()
endif()
set(AUDASPACE_PY_LIBRARY -laudaspace-py)
if(WIN32 AND AUDASPACE_STANDALONE)
file(GLOB PYTHON_DLLS ${LIBRARY_PATH}/Python/bin/*.dll)
list(APPEND DLLS ${PYTHON_DLLS})
endif()
else()
set(WITH_PYTHON FALSE CACHE BOOL "Build With Python Library" FORCE)
message(WARNING "Python libraries not found, language binding will not be built.")
endif()
endif()
# SDL
if(WITH_SDL)
if(AUDASPACE_STANDALONE)
if(USE_SDL2)
find_package(SDL2)
if(SDL2_FOUND)
set(SDL_INCLUDE_DIR ${SDL2_INCLUDE_DIR})
set(SDL_LIBRARY ${SDL2_LIBRARY})
set(SDL_FOUND TRUE)
else()
find_package(SDL ${PACKAGE_OPTION})
endif()
else()
find_package(SDL ${PACKAGE_OPTION})
endif()
endif()
if(SDL_FOUND)
set(SDL_SRC
plugins/sdl/SDLDevice.cpp
)
set(SDL_HDR
plugins/sdl/SDLDevice.h
)
if(NOT PLUGIN_SDL)
list(APPEND INCLUDE ${SDL_INCLUDE_DIR})
list(APPEND LIBRARIES ${SDL_LIBRARY})
list(APPEND SRC ${SDL_SRC})
list(APPEND HDR ${SDL_HDR})
list(APPEND STATIC_PLUGINS SDLDevice)
endif()
if(WIN32 AND AUDASPACE_STANDALONE)
file(GLOB SDL_DLLS ${LIBRARY_PATH}/sdl/bin/*.dll)
list(APPEND DLLS ${SDL_DLLS})
endif()
else()
set(WITH_SDL FALSE CACHE BOOL "Build With SDL" FORCE)
message(WARNING "SDL not found, plugin will not be built.")
endif()
endif()
# library configuration
if(SHARED_LIBRARY)
set(AUD_LIBRARY_TYPE AUD_SHARED_LIBRARY)
set(LIBRARY_TYPE SHARED)
add_definitions(-DAUD_BUILD_SHARED_LIBRARY)
else()
set(AUD_LIBRARY_TYPE AUD_STATIC_LIBRARY)
set(LIBRARY_TYPE STATIC)
endif()
# file configuration
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/config/Audaspace.h.in ${CMAKE_CURRENT_BINARY_DIR}/Audaspace.h ESCAPE_QUOTES @ONLY)
list(APPEND HDR ${CMAKE_CURRENT_BINARY_DIR}/Audaspace.h)
set(STATIC_PLUGIN_CLASSES "")
set(STATIC_PLUGIN_REGISTERS "")
foreach(PLUGIN ${STATIC_PLUGINS})
list(APPEND STATIC_PLUGIN_CLASSES "STATIC_PLUGIN_CLASS(" ${PLUGIN} ")\n")
list(APPEND STATIC_PLUGIN_REGISTERS "\tSTATIC_PLUGIN_REGISTER(" ${PLUGIN} ")\n")
endforeach()
string(CONCAT STATIC_PLUGIN_CLASSES ${STATIC_PLUGIN_CLASSES})
string(CONCAT STATIC_PLUGIN_REGISTERS ${STATIC_PLUGIN_REGISTERS})
if(WIN32)
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/src/plugin/PluginManagerWindows.cpp.in ${CMAKE_CURRENT_BINARY_DIR}/PluginManager.cpp ESCAPE_QUOTES @ONLY)
if(WITH_FFTW)
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/src/fx/HRTFLoaderWindows.cpp ${CMAKE_CURRENT_BINARY_DIR}/HRTFLoader.cpp COPYONLY)
endif()
else()
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/src/plugin/PluginManagerUnix.cpp.in ${CMAKE_CURRENT_BINARY_DIR}/PluginManager.cpp ESCAPE_QUOTES @ONLY)
if(WITH_FFTW)
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/src/fx/HRTFLoaderUnix.cpp ${CMAKE_CURRENT_BINARY_DIR}/HRTFLoader.cpp COPYONLY)
endif()
endif()
list(APPEND SRC ${CMAKE_CURRENT_BINARY_DIR}/PluginManager.cpp)
if(WITH_FFTW)
list(APPEND SRC ${CMAKE_CURRENT_BINARY_DIR}/HRTFLoader.cpp)
endif()
# directories
include_directories(${INCLUDE})
link_directories()
# install configuration
if(WIN32)
set(BIN_DESTINATION ".")
else()
set(BIN_DESTINATION "bin")
endif()
set(LIB_DESTINATION "lib${LIB_SUFFIX}")
# library
add_library(audaspace ${LIBRARY_TYPE} ${SRC} ${HDR})
target_link_libraries(audaspace ${LIBRARIES})
set_target_properties(audaspace PROPERTIES SOVERSION ${AUDASPACE_VERSION})
if(AUDASPACE_STANDALONE)
install(TARGETS audaspace
RUNTIME DESTINATION ${BIN_DESTINATION}
LIBRARY DESTINATION ${LIB_DESTINATION}
ARCHIVE DESTINATION ${LIB_DESTINATION}
)
install(DIRECTORY ${CMAKE_SOURCE_DIR}/include/ DESTINATION include/audaspace)
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/Audaspace.h DESTINATION include/audaspace)
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/packages/pkgconfig/audaspace.pc.in ${CMAKE_CURRENT_BINARY_DIR}/audaspace.pc @ONLY)
if(NOT WIN32 AND NOT APPLE)
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/audaspace.pc DESTINATION "lib${LIB_SUFFIX}/pkgconfig")
endif()
endif()
# plugins
if(WITH_FFMPEG AND PLUGIN_FFMPEG)
add_definitions(-DFFMPEG_PLUGIN)
include_directories(${INCLUDE} ${FFMPEG_INCLUDE_DIRS})
add_library(audffmpeg SHARED ${FFMPEG_SRC} ${FFMPEG_HDR} ${HDR})
target_link_libraries(audffmpeg audaspace ${FFMPEG_LIBRARIES})
set_target_properties(audffmpeg PROPERTIES SOVERSION ${AUDASPACE_VERSION})
install(TARGETS audffmpeg DESTINATION ${DEFAULT_PLUGIN_PATH})
endif()
if(WITH_JACK AND PLUGIN_JACK)
add_definitions(-DJACK_PLUGIN)
include_directories(${INCLUDE} ${JACK_INCLUDE_DIRS})
add_library(audjack SHARED ${JACK_SRC} ${JACK_HDR} ${HDR})
if(DYNLOAD_JACK)
target_link_libraries(audjack audaspace)
else()
target_link_libraries(audjack audaspace ${JACK_LIBRARIES})
endif()
set_target_properties(audjack PROPERTIES SOVERSION ${AUDASPACE_VERSION})
install(TARGETS audjack DESTINATION ${DEFAULT_PLUGIN_PATH})
endif()
if(WITH_LIBSNDFILE AND PLUGIN_LIBSNDFILE)
add_definitions(-DLIBSNDFILE_PLUGIN)
include_directories(${INCLUDE} ${LIBSNDFILE_INCLUDE_DIRS})
add_library(audlibsndfile SHARED ${LIBSNDFILE_SRC} ${LIBSNDFILE_HDR} ${HDR})
set_target_properties(audlibsndfile PROPERTIES SOVERSION ${AUDASPACE_VERSION})
target_link_libraries(audlibsndfile audaspace ${LIBSNDFILE_LIBRARIES})
install(TARGETS audlibsndfile DESTINATION ${DEFAULT_PLUGIN_PATH})
endif()
if(WITH_OPENAL AND PLUGIN_OPENAL)
add_definitions(-DOPENAL_PLUGIN)
include_directories(${INCLUDE} ${OPENAL_INCLUDE_DIR})
add_library(audopenal SHARED ${OPENAL_SRC} ${OPENAL_HDR} ${HDR})
set_target_properties(audopenal PROPERTIES SOVERSION ${AUDASPACE_VERSION})
target_link_libraries(audopenal audaspace ${OPENAL_LIBRARY})
install(TARGETS audopenal DESTINATION ${DEFAULT_PLUGIN_PATH})
endif()
if(WITH_SDL AND PLUGIN_SDL)
add_definitions(-DSDL_PLUGIN)
include_directories(${INCLUDE} ${SDL_INCLUDE_DIR})
add_library(audsdl SHARED ${SDL_SRC} ${SDL_HDR} ${HDR})
set_target_properties(audsdl PROPERTIES SOVERSION ${AUDASPACE_VERSION})
target_link_libraries(audsdl audaspace ${SDL_LIBRARY})
install(TARGETS audsdl DESTINATION ${DEFAULT_PLUGIN_PATH})
endif()
# dlls
if(WIN32)
if(DLLS)
install(FILES ${DLLS} DESTINATION ${BIN_DESTINATION})
endif()
endif()
# demos
if(BUILD_DEMOS)
include_directories(${INCLUDE})
set(DEMOS audaplay audaconvert audaremap signalgen randsounds dynamicmusic playbackmanager)
add_executable(audaplay demos/audaplay.cpp)
target_link_libraries(audaplay audaspace)
add_executable(audaconvert demos/audaconvert.cpp)
target_link_libraries(audaconvert audaspace)
add_executable(audaremap demos/audaremap.cpp)
target_link_libraries(audaremap audaspace)
add_executable(signalgen demos/signalgen.cpp)
target_link_libraries(signalgen audaspace)
add_executable(randsounds demos/randsounds.cpp)
target_link_libraries(randsounds audaspace)
add_executable(dynamicmusic demos/dynamicmusic.cpp)
target_link_libraries(dynamicmusic audaspace)
add_executable(playbackmanager demos/playbackmanager.cpp)
target_link_libraries(playbackmanager audaspace)
if(WITH_FFTW)
list(APPEND DEMOS convolution binaural)
add_executable(convolution demos/convolution.cpp)
target_link_libraries(convolution audaspace)
add_executable(binaural demos/binaural.cpp)
target_link_libraries(binaural audaspace)
endif()
if(WITH_OPENAL)
list(APPEND DEMOS openaldevices)
add_executable(openaldevices demos/openaldevices.cpp)
if(PLUGIN_OPENAL)
target_link_libraries(openaldevices audaspace audopenal)
else()
target_link_libraries(openaldevices audaspace)
endif()
endif()
install(TARGETS ${DEMOS}
RUNTIME DESTINATION ${BIN_DESTINATION}
LIBRARY DESTINATION ${LIB_DESTINATION}
ARCHIVE DESTINATION ${LIB_DESTINATION}
)
endif()
# bindings
if(WITH_C)
if(SEPARATE_C)
add_library(audaspace-c ${LIBRARY_TYPE} ${C_SRC} ${C_HDR})
target_link_libraries(audaspace-c audaspace)
set_target_properties(audaspace-c PROPERTIES SOVERSION ${AUDASPACE_VERSION})
install(TARGETS audaspace-c
RUNTIME DESTINATION ${BIN_DESTINATION}
LIBRARY DESTINATION ${LIB_DESTINATION}
ARCHIVE DESTINATION ${LIB_DESTINATION}
)
endif()
if(AUDASPACE_STANDALONE)
install(FILES ${C_HDR} DESTINATION include/audaspace)
endif()
endif()
if(WITH_PYTHON)
set(PYTHON_SRC
bindings/python/PyAPI.cpp
bindings/python/PyDevice.cpp
bindings/python/PyDynamicMusic.cpp
bindings/python/PyHandle.cpp
bindings/python/PyPlaybackManager.cpp
bindings/python/PySequence.cpp
bindings/python/PySequenceEntry.cpp
bindings/python/PySound.cpp
bindings/python/PySource.cpp
bindings/python/PyThreadPool.cpp
)
set(PYTHON_HDR
bindings/python/PyAPI.h
bindings/python/PyDevice.h
bindings/python/PyDynamicMusic.h
bindings/python/PyHandle.h
bindings/python/PyPlaybackManager.h
bindings/python/PySequence.h
bindings/python/PySequenceEntry.h
bindings/python/PySound.h
bindings/python/PySource.h
bindings/python/PyThreadPool.h
)
if(WITH_FFTW)
list(APPEND PYTHON_SRC
bindings/python/PyHRTF.cpp
bindings/python/PyImpulseResponse.cpp
)
list(APPEND PYTHON_HDR
bindings/python/PyHRTF.h
bindings/python/PyImpulseResponse.h
)
endif()
add_library(audaspace-py ${LIBRARY_TYPE} ${PYTHON_SRC} ${PYTHON_HDR})
target_link_libraries(audaspace-py audaspace ${PYTHON_LIBRARIES})
set_target_properties(audaspace-py PROPERTIES SOVERSION ${AUDASPACE_VERSION})
if(AUDASPACE_STANDALONE)
install(TARGETS audaspace-py
RUNTIME DESTINATION ${BIN_DESTINATION}
LIBRARY DESTINATION ${LIB_DESTINATION}
ARCHIVE DESTINATION ${LIB_DESTINATION}
)
install(FILES ${PYTHON_HDR} DESTINATION include/audaspace/python)
endif()
if(WITH_PYTHON_MODULE)
set(PYTHON_SOURCE_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/bindings/python)
configure_file(${PYTHON_SOURCE_DIRECTORY}/setup.py.in ${CMAKE_CURRENT_BINARY_DIR}/setup.py ESCAPE_QUOTES @ONLY)
if(APPLE)
add_custom_command(OUTPUT build COMMAND MACOSX_DEPLOYMENT_TARGET=${CMAKE_OSX_DEPLOYMENT_TARGET} ${PYTHON_EXECUTABLE} setup.py build DEPENDS ${PYTHON_SRC} ${PYTHON_HDR})
elseif(WIN32)
set(ENV{VS100COMNTOOLS} $ENV{VS120COMNTOOLS})
add_custom_command(OUTPUT build COMMAND ${PYTHON_EXECUTABLE} setup.py build DEPENDS ${PYTHON_SRC} ${PYTHON_HDR})
else()
add_custom_command(OUTPUT build COMMAND ${PYTHON_EXECUTABLE} setup.py build DEPENDS ${PYTHON_SRC} ${PYTHON_HDR})
endif()
add_custom_target(pythonmodule ALL DEPENDS build SOURCES ${PYTHON_SOURCE_DIRECTORY}/setup.py.in ${PYTHON_SRC} ${PYTHON_HDR})
add_dependencies(pythonmodule audaspace)
install(CODE "EXECUTE_PROCESS(COMMAND ${PYTHON_EXECUTABLE} setup.py install --root=\$ENV{DESTDIR} --prefix=${CMAKE_INSTALL_PREFIX})")
endif()
endif()
# docs
if(WITH_DOCS)
find_package(Doxygen ${PACKAGE_OPTION})
if(DOXYGEN_FOUND AND DOXYGEN_DOT_FOUND)
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/doc/Doxyfile.in ${CMAKE_CURRENT_BINARY_DIR}/Doxyfile @ONLY)
add_custom_target(audaspace_doc ALL ${DOXYGEN_EXECUTABLE} Doxyfile COMMENT "Building C++ HTML documentation with Doxygen.")
else()
set(WITH_DOCS FALSE CACHE BOOL "Build C++ HTML Documentation with Doxygen" FORCE)
message(WARNING "Doxygen (and/or dot) not found, documentation will not be built.")
endif()
endif()
if(WITH_BINDING_DOCS)
find_package(Sphinx ${PACKAGE_OPTION})
if(SPHINX_FOUND)
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/bindings/doc/conf.py.in ${CMAKE_CURRENT_BINARY_DIR}/conf.py @ONLY)
add_custom_target(bindings_doc ALL COMMAND ${PYTHON_EXECUTABLE} setup.py --build-docs ${SPHINX_EXECUTABLE} -q -b html -c "${CMAKE_CURRENT_BINARY_DIR}" -d "${CMAKE_CURRENT_BINARY_DIR}/_doctrees" "${CMAKE_CURRENT_SOURCE_DIR}/bindings/doc" "${CMAKE_CURRENT_BINARY_DIR}/doc/bindings" DEPENDS pythonmodule COMMENT "Building C/Python HTML documentation with Sphinx.")
else()
set(WITH_BINDING_DOCS FALSE CACHE BOOL "Build C/Python HTML Documentation with Sphinx" FORCE)
message(WARNING "Sphinx not found, binding documentation will not be built.")
endif()
endif()
if(WITH_DOCS OR WITH_BINDING_DOCS)
install(DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/doc/ DESTINATION ${DOCUMENTATION_INSTALL_PATH})
endif()

107
extern/audaspace/INSTALL vendored Normal file
View File

@@ -0,0 +1,107 @@
Audaspace Installation Guide
============================
This document guides through the building and installation of audaspace.
The build system used to build audaspace is CMake and it allows very building the library for very different application scenarios from a very general shared library build with plugins that is suitable for system wide installations to building everything into a single static library to be linked into a standalone program.
Build Dependencies
------------------
Audaspace is written in C++ 11 so a fairly recent compiler (g++ 4.8.2, clang 3.3, MSVC 2013) is needed to build it. The build system used is CMake and you need at least version 3.0. The following build dependencies are all optional, but without any it's neither possible to open sound files nor play back through the speakers. For windows a library folder called build-dependencies can be downloaded from https://github.com/audaspace/audaspace/releases.
- OpenAL (input/output device)
- SDL (output device)
- Jack (output device)
- libsndfile (file access)
- ffmpeg (file access)
- Python (language binding)
Getting the Code
----------------
The audaspace source code or binary releases can be downloaded from https://github.com/audaspace/audaspace/releases.
For the most recent version you can use git to get the source code.
git clone https://github.com/audaspace/audaspace.git
Plugins
-------
Before diving into the exact build steps for each platform, we will have a look at plugins. There are so far two types of plugins: input and output plugins. Input plugins are for reading audio files in many different formats and output plugins are for output devices on different platforms. During the configuration audaspace's standard plugins can be enabled with their repsective `WITH_*` and `PLUGIN_*` configuration option. Plugins are built as shared libraries. By default audaspace looks in the `DEFAULT_PLUGIN_PATH` for shared libraries it can load. Building with a dependency (`WITH_*`) but without enabling the respective `PLUGIN_*` option will compile the plugin directly into the library, so the plugin always gets loaded when the plugins are initialised.
Building for Linux
------------------
### Configuration ###
It is highly recommended to build audaspace outside of the actual source code in a specific build directory.
mkdir build
cd build
Configuration is then either done interactively by using ccmake
ccmake ../audaspace
__or__ it can be done by defining variables directly during the run of cmake.
cmake ../build \
-DCMAKE_INSTALL_PREFIX:PATH=/usr \
-DCMAKE_BUILD_TYPE:STRING=Release \
-DBUILD_DEMOS:BOOL=TRUE \
-DSHARED_LIBRARY:BOOL=TRUE \
-DWITH_C:BOOL=TRUE \
-DWITH_FFMPEG:BOOL=TRUE \
-DWITH_JACK:BOOL=TRUE \
-DWITH_LIBSNDFILE:BOOL=TRUE \
-DWITH_OPENAL:BOOL=TRUE \
-DWITH_PYTHON:BOOL=TRUE \
-DWITH_SDL:BOOL=TRUE \
-DDEFAULT_PLUGIN_PATH:PATH=/usr/share/audaspace/plugins
This specific configuration is recommended for a system wide installation of audaspace where all build dependencies are required.
### Building ###
After configuration the building is as easy as running
make
### Installation ###
Installation is then also simple using
make install
### Using the library ###
When audaspace is installed to the system, the required configuration for _pkgconfig_ is also installed and pkgconfig can then be used to compile projects with audaspace.
It is also possible to build audaspace as a static library and use it directly in a project. For this the library has to be configured accordingly with ccmake and after building the resulting library file can be added to the project's build system.
Building for Windows
--------------------
### Configuration ###
Using cmake-gui select Visual Studio 2013 or 2015 for the architecture you want to build for and choose audaspace's source directory and a build directory. It is highly recommended to build audaspace outside of the source directory. During the first configuration cmake tries to find the dependencies. Dependencies that are not installed on the system are automatically disabled. To prevent this, enable `WITH_STRICT_DEPENDENCIES`. To use the build dependencies folder from the website, set the `LIBRARY_PATH` to point to the extracted directory. Also don't forget to set the `CMAKE_INSTALL_PREFIX` to a path where your user account can install to. Finally enable the dependencies that you want to use (`WITH_*`), configure and generate.
### Building ###
Open the project in Visual Studio and set the configuration to Release. Then you can simply hit the build button.
### Installation ###
To install audaspace to your target folder, build the INSTALL target.
Note that if you don't use the libraries folder provided on the website, the INSTALL target might fail and you need to copy the files manually, including the dlls of the dependencies.
### Using the library ###
To use audaspace in your project, configure the include path and the libraries that you need, which you can find in the include and lib directories in your installation path.
### Notes for plugins on windows ###
- FFMPEG: Due to a problem with FFMPEG's 32 bit libraries, it is necessary to disable SAFESEH for the audffmpeg build target inside Visual Studio (Properties, Linker, Advanced). This has to be done after each generate step of CMake.
- Jack: If no jack server is running on windows and your application or one of the demos tries to use the jack plugin, this adds a long delay to the device initialisation. In case you don't need jack, make sure to disable the plugin or for the prebuilt version of audaspace simply delete audjack.dll (and any files with jack in the name to clean up).

202
extern/audaspace/LICENSE vendored Normal file
View File

@@ -0,0 +1,202 @@
Apache License
Version 2.0, January 2004
http://www.apache.org/licenses/
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
1. Definitions.
"License" shall mean the terms and conditions for use, reproduction,
and distribution as defined by Sections 1 through 9 of this document.
"Licensor" shall mean the copyright owner or entity authorized by
the copyright owner that is granting the License.
"Legal Entity" shall mean the union of the acting entity and all
other entities that control, are controlled by, or are under common
control with that entity. For the purposes of this definition,
"control" means (i) the power, direct or indirect, to cause the
direction or management of such entity, whether by contract or
otherwise, or (ii) ownership of fifty percent (50%) or more of the
outstanding shares, or (iii) beneficial ownership of such entity.
"You" (or "Your") shall mean an individual or Legal Entity
exercising permissions granted by this License.
"Source" form shall mean the preferred form for making modifications,
including but not limited to software source code, documentation
source, and configuration files.
"Object" form shall mean any form resulting from mechanical
transformation or translation of a Source form, including but
not limited to compiled object code, generated documentation,
and conversions to other media types.
"Work" shall mean the work of authorship, whether in Source or
Object form, made available under the License, as indicated by a
copyright notice that is included in or attached to the work
(an example is provided in the Appendix below).
"Derivative Works" shall mean any work, whether in Source or Object
form, that is based on (or derived from) the Work and for which the
editorial revisions, annotations, elaborations, or other modifications
represent, as a whole, an original work of authorship. For the purposes
of this License, Derivative Works shall not include works that remain
separable from, or merely link (or bind by name) to the interfaces of,
the Work and Derivative Works thereof.
"Contribution" shall mean any work of authorship, including
the original version of the Work and any modifications or additions
to that Work or Derivative Works thereof, that is intentionally
submitted to Licensor for inclusion in the Work by the copyright owner
or by an individual or Legal Entity authorized to submit on behalf of
the copyright owner. For the purposes of this definition, "submitted"
means any form of electronic, verbal, or written communication sent
to the Licensor or its representatives, including but not limited to
communication on electronic mailing lists, source code control systems,
and issue tracking systems that are managed by, or on behalf of, the
Licensor for the purpose of discussing and improving the Work, but
excluding communication that is conspicuously marked or otherwise
designated in writing by the copyright owner as "Not a Contribution."
"Contributor" shall mean Licensor and any individual or Legal Entity
on behalf of whom a Contribution has been received by Licensor and
subsequently incorporated within the Work.
2. Grant of Copyright License. Subject to the terms and conditions of
this License, each Contributor hereby grants to You a perpetual,
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
copyright license to reproduce, prepare Derivative Works of,
publicly display, publicly perform, sublicense, and distribute the
Work and such Derivative Works in Source or Object form.
3. Grant of Patent License. Subject to the terms and conditions of
this License, each Contributor hereby grants to You a perpetual,
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
(except as stated in this section) patent license to make, have made,
use, offer to sell, sell, import, and otherwise transfer the Work,
where such license applies only to those patent claims licensable
by such Contributor that are necessarily infringed by their
Contribution(s) alone or by combination of their Contribution(s)
with the Work to which such Contribution(s) was submitted. If You
institute patent litigation against any entity (including a
cross-claim or counterclaim in a lawsuit) alleging that the Work
or a Contribution incorporated within the Work constitutes direct
or contributory patent infringement, then any patent licenses
granted to You under this License for that Work shall terminate
as of the date such litigation is filed.
4. Redistribution. You may reproduce and distribute copies of the
Work or Derivative Works thereof in any medium, with or without
modifications, and in Source or Object form, provided that You
meet the following conditions:
(a) You must give any other recipients of the Work or
Derivative Works a copy of this License; and
(b) You must cause any modified files to carry prominent notices
stating that You changed the files; and
(c) You must retain, in the Source form of any Derivative Works
that You distribute, all copyright, patent, trademark, and
attribution notices from the Source form of the Work,
excluding those notices that do not pertain to any part of
the Derivative Works; and
(d) If the Work includes a "NOTICE" text file as part of its
distribution, then any Derivative Works that You distribute must
include a readable copy of the attribution notices contained
within such NOTICE file, excluding those notices that do not
pertain to any part of the Derivative Works, in at least one
of the following places: within a NOTICE text file distributed
as part of the Derivative Works; within the Source form or
documentation, if provided along with the Derivative Works; or,
within a display generated by the Derivative Works, if and
wherever such third-party notices normally appear. The contents
of the NOTICE file are for informational purposes only and
do not modify the License. You may add Your own attribution
notices within Derivative Works that You distribute, alongside
or as an addendum to the NOTICE text from the Work, provided
that such additional attribution notices cannot be construed
as modifying the License.
You may add Your own copyright statement to Your modifications and
may provide additional or different license terms and conditions
for use, reproduction, or distribution of Your modifications, or
for any such Derivative Works as a whole, provided Your use,
reproduction, and distribution of the Work otherwise complies with
the conditions stated in this License.
5. Submission of Contributions. Unless You explicitly state otherwise,
any Contribution intentionally submitted for inclusion in the Work
by You to the Licensor shall be under the terms and conditions of
this License, without any additional terms or conditions.
Notwithstanding the above, nothing herein shall supersede or modify
the terms of any separate license agreement you may have executed
with Licensor regarding such Contributions.
6. Trademarks. This License does not grant permission to use the trade
names, trademarks, service marks, or product names of the Licensor,
except as required for reasonable and customary use in describing the
origin of the Work and reproducing the content of the NOTICE file.
7. Disclaimer of Warranty. Unless required by applicable law or
agreed to in writing, Licensor provides the Work (and each
Contributor provides its Contributions) on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
implied, including, without limitation, any warranties or conditions
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
PARTICULAR PURPOSE. You are solely responsible for determining the
appropriateness of using or redistributing the Work and assume any
risks associated with Your exercise of permissions under this License.
8. Limitation of Liability. In no event and under no legal theory,
whether in tort (including negligence), contract, or otherwise,
unless required by applicable law (such as deliberate and grossly
negligent acts) or agreed to in writing, shall any Contributor be
liable to You for damages, including any direct, indirect, special,
incidental, or consequential damages of any character arising as a
result of this License or out of the use or inability to use the
Work (including but not limited to damages for loss of goodwill,
work stoppage, computer failure or malfunction, or any and all
other commercial damages or losses), even if such Contributor
has been advised of the possibility of such damages.
9. Accepting Warranty or Additional Liability. While redistributing
the Work or Derivative Works thereof, You may choose to offer,
and charge a fee for, acceptance of support, warranty, indemnity,
or other liability obligations and/or rights consistent with this
License. However, in accepting such obligations, You may act only
on Your own behalf and on Your sole responsibility, not on behalf
of any other Contributor, and only if You agree to indemnify,
defend, and hold each Contributor harmless for any liability
incurred by, or claims asserted against, such Contributor by reason
of your accepting any such warranty or additional liability.
END OF TERMS AND CONDITIONS
APPENDIX: How to apply the Apache License to your work.
To apply the Apache License to your work, attach the following
boilerplate notice, with the fields enclosed by brackets "[]"
replaced with your own identifying information. (Don't include
the brackets!) The text should be enclosed in the appropriate
comment syntax for the file format. We also recommend that a
file or class name and description of purpose be included on the
same "printed page" as the copyright notice for easier
identification within third-party archives.
Copyright [yyyy] [name of copyright owner]
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.

47
extern/audaspace/README.md vendored Normal file
View File

@@ -0,0 +1,47 @@
audaspace
=========
Audaspace (pronounced "outer space") is a high level audio library written in C++ with language bindings for Python for example. It started out as the audio engine of the 3D modelling application Blender and is now released as a standalone library.
Documentation and Community
---------------------------
The documentation including guides for building and installing, demos, tutorials as well as the API reference for C++, C and python can be found on https://audaspace.github.io.
Bug reports and feature requests should go to the [issue tracker](https://github.com/audaspace/audaspace/issues).
For any other discussions about audaspace there is a [mailing list](https://groups.google.com/forum/#!forum/audaspace) and there is also the IRC channel #audaspace on irc.freenode.net.
Features
--------
The following (probably incomplete) features are supported by audaspace:
* input/output devices
* input from microphones, line in, etc.
* output devices including 3D audio support
* file reading/writing
* filters like low-/highpass and effects like delay, reverse or fading
* generators for simple waveforms like silence, sine and triangle
* respecification - this term is used for changing stream parameters which are
* channel count - channel remapping
* sample format - the library internally uses 32 bit floats
* sample rate - resampling
* simple (superposition, joining and ping-pong aka forward-reverse) and more complex (non-linear audio editing) sequencing of sounds
License
-------
> Copyright © 2009-2015 Jörg Müller. All rights reserved.
>
> 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.

View File

@@ -0,0 +1,336 @@
/*******************************************************************************
* Copyright 2009-2016 Jörg Müller
*
* 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 "devices/DeviceManager.h"
#include "devices/I3DDevice.h"
#include "devices/IDeviceFactory.h"
#include "devices/ReadDevice.h"
#include "Exception.h"
#include <cassert>
using namespace aud;
#define AUD_CAPI_IMPLEMENTATION
#include "AUD_Device.h"
static inline aud::Specs convCToSpec(AUD_Specs specs)
{
aud::Specs s;
s.channels = static_cast<Channels>(specs.channels);
s.rate = static_cast<SampleRate>(specs.rate);
return s;
}
static inline aud::DeviceSpecs convCToDSpec(AUD_DeviceSpecs specs)
{
aud::DeviceSpecs s;
s.specs = convCToSpec(specs.specs);
s.format = static_cast<SampleFormat>(specs.format);
return s;
}
AUD_API AUD_Device* AUD_Device_open(const char* type, AUD_DeviceSpecs specs, int buffersize, const char* name)
{
DeviceSpecs dspecs = convCToDSpec(specs);
if(dspecs.channels == CHANNELS_INVALID)
dspecs.channels = CHANNELS_STEREO;
if(dspecs.format == FORMAT_INVALID)
dspecs.format = FORMAT_FLOAT32;
if(dspecs.rate == RATE_INVALID)
dspecs.rate = RATE_48000;
if(buffersize < 128)
buffersize = AUD_DEFAULT_BUFFER_SIZE;
if(name == nullptr)
name = "";
try
{
if(!type)
{
auto device = DeviceManager::getDevice();
if(!device)
{
DeviceManager::openDefaultDevice();
device = DeviceManager::getDevice();
}
return new AUD_Device(device);
}
if(type == std::string("read"))
{
return new AUD_Device(new ReadDevice(dspecs));
}
std::shared_ptr<IDeviceFactory> factory;
if(!*type)
factory = DeviceManager::getDefaultDeviceFactory();
else
factory = DeviceManager::getDeviceFactory(type);
if(factory)
{
factory->setName(name);
factory->setSpecs(dspecs);
factory->setBufferSize(buffersize);
return new AUD_Device(factory->openDevice());
}
}
catch(Exception&)
{
}
return nullptr;
}
AUD_API void AUD_Device_lock(AUD_Device* device)
{
auto dev = device ? *device : DeviceManager::getDevice();
dev->lock();
}
AUD_API AUD_Handle* AUD_Device_play(AUD_Device* device, AUD_Sound* sound, int keep)
{
assert(sound);
auto dev = device ? *device : DeviceManager::getDevice();
try
{
AUD_Handle handle = dev->play(*sound, keep);
if(handle.get())
{
return new AUD_Handle(handle);
}
}
catch(Exception&)
{
}
return nullptr;
}
AUD_API void AUD_Device_stopAll(AUD_Device* device)
{
auto dev = device ? *device : DeviceManager::getDevice();
dev->stopAll();
}
AUD_API void AUD_Device_unlock(AUD_Device* device)
{
auto dev = device ? *device : DeviceManager::getDevice();
dev->unlock();
}
AUD_API AUD_Channels AUD_Device_getChannels(AUD_Device* device)
{
auto dev = device ? *device : DeviceManager::getDevice();
return static_cast<AUD_Channels>(dev->getSpecs().channels);
}
AUD_API AUD_DistanceModel AUD_Device_getDistanceModel(AUD_Device* device)
{
auto dev = device ? std::dynamic_pointer_cast<I3DDevice>(*device) : DeviceManager::get3DDevice();
return static_cast<AUD_DistanceModel>(dev->getDistanceModel());
}
AUD_API void AUD_Device_setDistanceModel(AUD_Device* device, AUD_DistanceModel value)
{
auto dev = device ? std::dynamic_pointer_cast<I3DDevice>(*device) : DeviceManager::get3DDevice();
dev->setDistanceModel(static_cast<DistanceModel>(value));
}
AUD_API float AUD_Device_getDopplerFactor(AUD_Device* device)
{
auto dev = device ? std::dynamic_pointer_cast<I3DDevice>(*device) : DeviceManager::get3DDevice();
return dev->getDopplerFactor();
}
AUD_API void AUD_Device_setDopplerFactor(AUD_Device* device, float value)
{
auto dev = device ? std::dynamic_pointer_cast<I3DDevice>(*device) : DeviceManager::get3DDevice();
dev->setDopplerFactor(value);
}
AUD_API AUD_SampleFormat AUD_Device_getFormat(AUD_Device* device)
{
auto dev = device ? *device : DeviceManager::getDevice();
return static_cast<AUD_SampleFormat>(dev->getSpecs().format);
}
AUD_API void AUD_Device_getListenerLocation(AUD_Device* device, float value[3])
{
auto dev = device ? std::dynamic_pointer_cast<I3DDevice>(*device) : DeviceManager::get3DDevice();
Vector3 v = dev->getListenerLocation();
value[0] = v.x();
value[1] = v.y();
value[2] = v.z();
}
AUD_API void AUD_Device_setListenerLocation(AUD_Device* device, const float value[3])
{
auto dev = device ? std::dynamic_pointer_cast<I3DDevice>(*device) : DeviceManager::get3DDevice();
Vector3 v(value[0], value[1], value[2]);
dev->setListenerLocation(v);
}
AUD_API void AUD_Device_getListenerOrientation(AUD_Device* device, float value[4])
{
auto dev = device ? std::dynamic_pointer_cast<I3DDevice>(*device) : DeviceManager::get3DDevice();
Quaternion v = dev->getListenerOrientation();
value[0] = v.x();
value[1] = v.y();
value[2] = v.z();
value[3] = v.w();
}
AUD_API void AUD_Device_setListenerOrientation(AUD_Device* device, const float value[4])
{
auto dev = device ? std::dynamic_pointer_cast<I3DDevice>(*device) : DeviceManager::get3DDevice();
Quaternion v(value[3], value[0], value[1], value[2]);
dev->setListenerOrientation(v);
}
AUD_API void AUD_Device_getListenerVelocity(AUD_Device* device, float value[3])
{
auto dev = device ? std::dynamic_pointer_cast<I3DDevice>(*device) : DeviceManager::get3DDevice();
Vector3 v = dev->getListenerVelocity();
value[0] = v.x();
value[1] = v.y();
value[2] = v.z();
}
AUD_API void AUD_Device_setListenerVelocity(AUD_Device* device, const float value[3])
{
auto dev = device ? std::dynamic_pointer_cast<I3DDevice>(*device) : DeviceManager::get3DDevice();
Vector3 v(value[0], value[1], value[2]);
dev->setListenerVelocity(v);
}
AUD_API double AUD_Device_getRate(AUD_Device* device)
{
auto dev = device ? *device : DeviceManager::getDevice();
return dev->getSpecs().rate;
}
AUD_API float AUD_Device_getSpeedOfSound(AUD_Device* device)
{
auto dev = device ? std::dynamic_pointer_cast<I3DDevice>(*device) : DeviceManager::get3DDevice();
return dev->getSpeedOfSound();
}
AUD_API void AUD_Device_setSpeedOfSound(AUD_Device* device, float value)
{
auto dev = device ? std::dynamic_pointer_cast<I3DDevice>(*device) : DeviceManager::get3DDevice();
dev->setSpeedOfSound(value);
}
AUD_API float AUD_Device_getVolume(AUD_Device* device)
{
auto dev = device ? *device : DeviceManager::getDevice();
return dev->getVolume();
}
AUD_API void AUD_Device_setVolume(AUD_Device* device, float value)
{
auto dev = device ? *device : DeviceManager::getDevice();
dev->setVolume(value);
}
AUD_API int AUD_Device_read(AUD_Device* device, unsigned char* buffer, int length)
{
assert(device);
assert(buffer);
auto readDevice = std::dynamic_pointer_cast<ReadDevice>(*device);
if(!readDevice)
return false;
try
{
return readDevice->read(buffer, length);
}
catch(Exception&)
{
return false;
}
}
AUD_API void AUD_Device_free(AUD_Device* device)
{
assert(device);
try
{
delete device;
}
catch(Exception&)
{
}
}
AUD_API AUD_Device* AUD_Device_getCurrent()
{
auto device = DeviceManager::getDevice();
if(!device)
return nullptr;
return new AUD_Device(device);
}
AUD_API void AUD_seekSynchronizer(AUD_Handle* handle, float time)
{
auto synchronizer = DeviceManager::getDevice()->getSynchronizer();
if(synchronizer)
synchronizer->seek(*reinterpret_cast<std::shared_ptr<IHandle>*>(handle), time);
}
AUD_API float AUD_getSynchronizerPosition(AUD_Handle* handle)
{
auto synchronizer = DeviceManager::getDevice()->getSynchronizer();
if(synchronizer)
return synchronizer->getPosition(*reinterpret_cast<std::shared_ptr<IHandle>*>(handle));
return (*reinterpret_cast<std::shared_ptr<IHandle>*>(handle))->getPosition();
}
AUD_API void AUD_playSynchronizer()
{
auto synchronizer = DeviceManager::getDevice()->getSynchronizer();
if(synchronizer)
synchronizer->play();
}
AUD_API void AUD_stopSynchronizer()
{
auto synchronizer = DeviceManager::getDevice()->getSynchronizer();
if(synchronizer)
synchronizer->stop();
}
AUD_API void AUD_setSynchronizerCallback(AUD_syncFunction function, void* data)
{
auto synchronizer = DeviceManager::getDevice()->getSynchronizer();
if(synchronizer)
synchronizer->setSyncCallback(function, data);
}
AUD_API int AUD_isSynchronizerPlaying()
{
auto synchronizer = DeviceManager::getDevice()->getSynchronizer();
if(synchronizer)
return synchronizer->isPlaying();
return false;
}

258
extern/audaspace/bindings/C/AUD_Device.h vendored Normal file
View File

@@ -0,0 +1,258 @@
/*******************************************************************************
* Copyright 2009-2016 Jörg Müller
*
* 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.
******************************************************************************/
#pragma once
#include "AUD_Types.h"
#ifdef __cplusplus
extern "C" {
#endif
/// Possible distance models for the 3D device.
typedef enum
{
AUD_DISTANCE_MODEL_INVALID = 0,
AUD_DISTANCE_MODEL_INVERSE,
AUD_DISTANCE_MODEL_INVERSE_CLAMPED,
AUD_DISTANCE_MODEL_LINEAR,
AUD_DISTANCE_MODEL_LINEAR_CLAMPED,
AUD_DISTANCE_MODEL_EXPONENT,
AUD_DISTANCE_MODEL_EXPONENT_CLAMPED
} AUD_DistanceModel;
typedef void (*AUD_syncFunction)(void*, int, float);
/**
* Opens a new sound device.
* \param type The name of the device.
* Can be NULL to open the default device with default settings or return the handle to the already opened one.
* Can be "" to open the a default factory device with given settings.
* Can be "read" to open a readable device.
* \param specs Specification of the device parameters.
* \param buffersize Size of the mixing buffer.
* \param name Custom name of the device.
* \return A handle to the opened device or NULL on failure.
*/
extern AUD_API AUD_Device* AUD_Device_open(const char* type, AUD_DeviceSpecs specs, int buffersize, const char* name);
/**
* Locks the playback device.
*/
extern AUD_API void AUD_Device_lock(AUD_Device* device);
/**
* Plays back a sound file.
* \param sound The handle of the sound file.
* \param keep When keep is true the sound source will not be deleted but set to
* paused when its end has been reached.
* \return A handle to the played back sound.
*/
extern AUD_API AUD_Handle* AUD_Device_play(AUD_Device* device, AUD_Sound* sound, int keep);
/**
* Stops all sounds playing.
*/
extern AUD_API void AUD_Device_stopAll(AUD_Device* device);
/**
* Unlocks the device.
*/
extern AUD_API void AUD_Device_unlock(AUD_Device* device);
/**
* Retrieves the channels of a device.
* param device The device to get the channels from.
* return The channels of the device.
*/
extern AUD_API AUD_Channels AUD_Device_getChannels(AUD_Device* device);
/**
* Retrieves the distance model of a device.
* param device The device to get the distance model from.
* return The distance model of the device.
*/
extern AUD_API AUD_DistanceModel AUD_Device_getDistanceModel(AUD_Device* device);
/**
* Sets the distance model of a device.
* param device The device to set the distance model from.
* param value The new distance model to set.
*/
extern AUD_API void AUD_Device_setDistanceModel(AUD_Device* device, AUD_DistanceModel value);
/**
* Retrieves the doppler factor of a device.
* param device The device to get the doppler factor from.
* return The doppler factor of the device.
*/
extern AUD_API float AUD_Device_getDopplerFactor(AUD_Device* device);
/**
* Sets the doppler factor of a device.
* param device The device to set the doppler factor from.
* param value The new doppler factor to set.
*/
extern AUD_API void AUD_Device_setDopplerFactor(AUD_Device* device, float value);
/**
* Retrieves the format of a device.
* param device The device to get the format from.
* return The format of the device.
*/
extern AUD_API AUD_SampleFormat AUD_Device_getFormat(AUD_Device* device);
/**
* Retrieves the listener location of a device.
* param device The device to get the listener location from.
* return The listener location of the device.
*/
extern AUD_API void AUD_Device_getListenerLocation(AUD_Device* device, float value[3]);
/**
* Sets the listener location of a device.
* param device The device to set the listener location from.
* param value The new listener location to set.
*/
extern AUD_API void AUD_Device_setListenerLocation(AUD_Device* device, const float value[3]);
/**
* Retrieves the listener orientation of a device.
* param device The device to get the listener orientation from.
* return The listener orientation of the device.
*/
extern AUD_API void AUD_Device_getListenerOrientation(AUD_Device* device, float value[4]);
/**
* Sets the listener orientation of a device.
* param device The device to set the listener orientation from.
* param value The new listener orientation to set.
*/
extern AUD_API void AUD_Device_setListenerOrientation(AUD_Device* device, const float value[4]);
/**
* Retrieves the listener velocity of a device.
* param device The device to get the listener velocity from.
* return The listener velocity of the device.
*/
extern AUD_API void AUD_Device_getListenerVelocity(AUD_Device* device, float value[3]);
/**
* Sets the listener velocity of a device.
* param device The device to set the listener velocity from.
* param value The new listener velocity to set.
*/
extern AUD_API void AUD_Device_setListenerVelocity(AUD_Device* device, const float value[3]);
/**
* Retrieves the rate of a device.
* param device The device to get the rate from.
* return The rate of the device.
*/
extern AUD_API double AUD_Device_getRate(AUD_Device* device);
/**
* Retrieves the speed of sound of a device.
* param device The device to get the speed of sound from.
* return The speed of sound of the device.
*/
extern AUD_API float AUD_Device_getSpeedOfSound(AUD_Device* device);
/**
* Sets the speed of sound of a device.
* param device The device to set the speed of sound from.
* param value The new speed of sound to set.
*/
extern AUD_API void AUD_Device_setSpeedOfSound(AUD_Device* device, float value);
/**
* Retrieves the volume of a device.
* param device The device to get the volume from.
* return The volume of the device.
*/
extern AUD_API float AUD_Device_getVolume(AUD_Device* device);
/**
* Sets the volume of a device.
* param device The device to set the volume from.
* param value The new volume to set.
*/
extern AUD_API void AUD_Device_setVolume(AUD_Device* device, float value);
/**
* Reads the next samples into the supplied buffer.
* \param device The readable device.
* \param buffer The target buffer.
* \param length The length in samples to be filled.
* \return True if the reading succeeded, false if there are no sounds
* played back currently, in that case the buffer is filled with
* silence.
*/
extern AUD_API int AUD_Device_read(AUD_Device* device, unsigned char* buffer, int length);
/**
* Closes a device. Handle becomes invalid afterwards.
* \param device The device to close.
*/
extern AUD_API void AUD_Device_free(AUD_Device* device);
/**
* Retrieves the current device of the DeviceManager.
* \return A pointer to the current device, which needs to be freed with
* AUD_Device_free.
*/
extern AUD_API AUD_Device* AUD_Device_getCurrent();
/**
* Seeks sequenced sound scene playback.
* \param handle Playback handle.
* \param time Time in seconds to seek to.
*/
extern AUD_API void AUD_seekSynchronizer(AUD_Handle* handle, float time);
/**
* Returns the current sound scene playback time.
* \param handle Playback handle.
* \return The playback time in seconds.
*/
extern AUD_API float AUD_getSynchronizerPosition(AUD_Handle* handle);
/**
* Starts the playback of jack transport if possible.
*/
extern AUD_API void AUD_playSynchronizer();
/**
* Stops the playback of jack transport if possible.
*/
extern AUD_API void AUD_stopSynchronizer();
/**
* Sets the sync callback for jack transport.
* \param function The callback function.
* \param data The data parameter for the callback.
*/
extern AUD_API void AUD_setSynchronizerCallback(AUD_syncFunction function, void* data);
/**
* Returns whether jack transport is currently playing.
* \return Whether jack transport is currently playing.
*/
extern AUD_API int AUD_isSynchronizerPlaying();
#ifdef __cplusplus
}
#endif

View File

@@ -0,0 +1,144 @@
/*******************************************************************************
* Copyright 2015-2016 Juan Francisco Crespo Galán
*
* 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 "Exception.h"
#include <cassert>
using namespace aud;
#define AUD_CAPI_IMPLEMENTATION
#include "AUD_DynamicMusic.h"
AUD_API AUD_DynamicMusic* AUD_DynamicMusic_create(AUD_Device* device)
{
assert(device);
try
{
return new AUD_DynamicMusic(new DynamicMusic(*device));
}
catch(Exception&)
{
return nullptr;
}
}
AUD_API void AUD_DynamicMusic_free(AUD_DynamicMusic* player)
{
assert(player);
delete player;
}
AUD_API int AUD_DynamicMusic_addScene(AUD_DynamicMusic* player, AUD_Sound* scene)
{
assert(player);
assert(scene);
return (*player)->addScene(*scene);
}
AUD_API int AUD_DynamicMusic_setSecene(AUD_DynamicMusic* player, int scene)
{
assert(player);
return (*player)->changeScene(scene);
}
AUD_API int AUD_DynamicMusic_getScene(AUD_DynamicMusic* player)
{
assert(player);
return (*player)->getScene();
}
AUD_API int AUD_DynamicMusic_addTransition(AUD_DynamicMusic* player, int ini, int end, AUD_Sound* transition)
{
assert(player);
assert(transition);
return (*player)->addTransition(ini, end, *transition);
}
AUD_API void AUD_DynamicMusic_setFadeTime(AUD_DynamicMusic* player, float seconds)
{
assert(player);
(*player)->setFadeTime(seconds);
}
AUD_API float AUD_DynamicMusic_getFadeTime(AUD_DynamicMusic* player)
{
assert(player);
return (*player)->getFadeTime();
}
AUD_API int AUD_DynamicMusic_resume(AUD_DynamicMusic* player)
{
assert(player);
return (*player)->resume();
}
AUD_API int AUD_DynamicMusic_pause(AUD_DynamicMusic* player)
{
assert(player);
return (*player)->pause();
}
AUD_API int AUD_DynamicMusic_seek(AUD_DynamicMusic* player, float position)
{
assert(player);
return (*player)->seek(position);
}
AUD_API float AUD_DynamicMusic_getPosition(AUD_DynamicMusic* player)
{
assert(player);
return (*player)->getPosition();
}
AUD_API float AUD_DynamicMusic_getVolume(AUD_DynamicMusic* player)
{
assert(player);
return (*player)->getVolume();
}
AUD_API int AUD_DynamicMusic_setVolume(AUD_DynamicMusic* player, float volume)
{
assert(player);
return (*player)->setVolume(volume);
}
AUD_API AUD_Status AUD_DynamicMusic_getStatus(AUD_DynamicMusic* player)
{
assert(player);
return static_cast<AUD_Status>((*player)->getStatus());
}
AUD_API int AUD_DynamicMusic_stop(AUD_DynamicMusic* player)
{
assert(player);
return (*player)->stop();
}

View File

@@ -0,0 +1,145 @@
/*******************************************************************************
* Copyright 2015-2016 Juan Francisco Crespo Galán
*
* 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.
******************************************************************************/
#pragma once
#include "AUD_Types.h"
#include "AUD_Handle.h"
#ifdef __cplusplus
extern "C" {
#endif
/**
* Creates a new dynamic music player.
* \param device The device that will be used to play sounds.
* \return The new DynamicMusic object.
*/
extern AUD_API AUD_DynamicMusic* AUD_DynamicMusic_create(AUD_Device* device);
/**
* Deletes a dynamic music player.
* \param player The DynamicMusic object to be deleted.
*/
extern AUD_API void AUD_DynamicMusic_free(AUD_DynamicMusic* player);
/**
* Adds a sound scene to a dynamic music player.
* \param player The DynamicMusic object.
* \param scene The sound to be added as a scene.
* \return The index of the new scene.
*/
extern AUD_API int AUD_DynamicMusic_addScene(AUD_DynamicMusic* player, AUD_Sound* scene);
/**
* Changes the current sound scene of a dynamic music player.
* \param player The DynamicMusic object.
* \param scene The index of the scene to be played.
* \return 0 if the target scene doesn't exist.
*/
extern AUD_API int AUD_DynamicMusic_setSecene(AUD_DynamicMusic* player, int scene);
/**
* Retrives the index of the current scene.
* \param player The DynamicMusic object.
* \return The index of the current scene.
*/
extern AUD_API int AUD_DynamicMusic_getScene(AUD_DynamicMusic* player);
/**
* Adds a new transition between two scenes.
* \param player The DynamicMusic object.
* \param ini The origin scene for the transition.
* \param end The end scene for the transition.
* \param transition A sound that will be used as transition between two scenes.
* \return 0 if the ini or end scenes don't exist.
*/
extern AUD_API int AUD_DynamicMusic_addTransition(AUD_DynamicMusic* player, int ini, int end, AUD_Sound* transition);
/**
* Changes the fade time for the default transitions of a dynamic music player.
* \param player The DynamicMusic object.
* \param seconds The amount of secods that the crossfade transition will take.
*/
extern AUD_API void AUD_DynamicMusic_setFadeTime(AUD_DynamicMusic* player, float seconds);
/**
* Retrieves the fade time of a dynamic music player.
* \param player The DynamicMusic object.
* \return The fade time of the player.
*/
extern AUD_API float AUD_DynamicMusic_getFadeTime(AUD_DynamicMusic* player);
/**
* Resumes the current scene playback of a dynamic music player if it is paused.
* \param player The DynamicMusic object.
* \return 0 if the playback wasn't resumed.
*/
extern AUD_API int AUD_DynamicMusic_resume(AUD_DynamicMusic* player);
/**
* Pauses the current scene of a dynamic music player.
* \param player The DynamicMusic object.
* \return 0 if the playback wasn't paused.
*/
extern AUD_API int AUD_DynamicMusic_pause(AUD_DynamicMusic* player);
/**
* Seeks the current playing scene of a dynamic music player.
* \param player The DynamicMusic object.
* \param position The new position from which to play back, in seconds.
* \return 0 if the seeking wasn't possible.
*/
extern AUD_API int AUD_DynamicMusic_seek(AUD_DynamicMusic* player, float position);
/**
* Retrieves the position of the current scene of a dynamic music player.
* \param player The DynamicMusic object.
* \return The position of the current playing scene.
*/
extern AUD_API float AUD_DynamicMusic_getPosition(AUD_DynamicMusic* player);
/**
* Retrieves the volume of the current scene of a dynamic music player.
* \param player The DynamicMusic object.
* \return The volume of the current playing scene.
*/
extern AUD_API float AUD_DynamicMusic_getVolume(AUD_DynamicMusic* player);
/**
* Changes the volume of the current scene in a dynamic music player.
* \param player The DynamicMusic object.
* \param 0 if the volume couldn't be changed.
*/
extern AUD_API int AUD_DynamicMusic_setVolume(AUD_DynamicMusic* player, float volume);
/**
* Retrieves the status of the current scene in a dynamic music player.
* \param player The DynamicMusic object.
* \return The Status of the current playing scene.
*/
extern AUD_API AUD_Status AUD_DynamicMusic_getStatus(AUD_DynamicMusic* player);
/**
* Stops the current scene of a dynamic music player.
* \param player The DynamicMusic object.
* \return 0 if the playback wasn't stopped.
*/
extern AUD_API int AUD_DynamicMusic_stop(AUD_DynamicMusic* player);
#ifdef __cplusplus
}
#endif

View File

@@ -0,0 +1,50 @@
/*******************************************************************************
* Copyright 2009-2015 Juan Francisco Crespo Galán
*
* 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 "Exception.h"
#include <cassert>
using namespace aud;
#define AUD_CAPI_IMPLEMENTATION
#include "AUD_HRTF.h"
extern AUD_API AUD_HRTF* AUD_HRTF_create()
{
try
{
return new AUD_HRTF(new HRTF());
}
catch(Exception&)
{
return nullptr;
}
}
extern AUD_API void AUD_HRTF_free(AUD_HRTF* hrtfs)
{
assert(hrtfs);
delete hrtfs;
}
extern AUD_API void AUD_HRTF_addImpulseResponseFromSound(AUD_HRTF* hrtfs, AUD_Sound* sound, float azimuth, float elevation)
{
assert(hrtfs);
assert(sound);
(*hrtfs)->addImpulseResponse(std::make_shared<StreamBuffer>(*sound), azimuth, elevation);
}

48
extern/audaspace/bindings/C/AUD_HRTF.h vendored Normal file
View File

@@ -0,0 +1,48 @@
/*******************************************************************************
* Copyright 2009-2015 Juan Francisco Crespo Galán
*
* 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.
******************************************************************************/
#pragma once
#include "AUD_Types.h"
#ifdef __cplusplus
extern "C" {
#endif
/**
* Creates a new HRTF object.
* \return The new HRTF object.
*/
extern AUD_API AUD_HRTF* AUD_HRTF_create();
/**
* Deletes a HRTF object.
* \param hrtfs The HRTF object to be deleted.
*/
extern AUD_API void AUD_HRTF_free(AUD_HRTF* hrtfs);
/**
* Adds a new impulse response to an HRTF object.
* \param hrtfs The HRTF object.
* \param sound A Sound object representing an HRTF.
* \param azimuth The azimuth angle of the HRTF.
* \param elevation The elevation angle of the HRTF.
*/
extern AUD_API void AUD_HRTF_addImpulseResponseFromSound(AUD_HRTF* hrtfs, AUD_Sound* sound, float azimuth, float elevation);
#ifdef __cplusplus
}
#endif

View File

@@ -0,0 +1,384 @@
/*******************************************************************************
* Copyright 2009-2016 Jörg Müller
*
* 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 "devices/I3DHandle.h"
#include "Exception.h"
#include <cassert>
using namespace aud;
#define AUD_CAPI_IMPLEMENTATION
#include "AUD_Handle.h"
AUD_API int AUD_Handle_pause(AUD_Handle* handle)
{
assert(handle);
return (*handle)->pause();
}
AUD_API int AUD_Handle_resume(AUD_Handle* handle)
{
assert(handle);
return (*handle)->resume();
}
AUD_API int AUD_Handle_stop(AUD_Handle* handle)
{
assert(handle);
int result = (*handle)->stop();
delete handle;
return result;
}
AUD_API float AUD_Handle_getAttenuation(AUD_Handle* handle)
{
assert(handle);
std::shared_ptr<I3DHandle> h = std::dynamic_pointer_cast<I3DHandle>(*handle);
if(h.get())
return h->getAttenuation();
return 0.0f;
}
AUD_API int AUD_Handle_setAttenuation(AUD_Handle* handle, float value)
{
assert(handle);
std::shared_ptr<I3DHandle> h = std::dynamic_pointer_cast<I3DHandle>(*handle);
if(h.get())
return h->setAttenuation(value);
return false;
}
AUD_API float AUD_Handle_getConeAngleInner(AUD_Handle* handle)
{
assert(handle);
std::shared_ptr<I3DHandle> h = std::dynamic_pointer_cast<I3DHandle>(*handle);
if(h.get())
return h->getConeAngleInner();
return 0.0f;
}
AUD_API int AUD_Handle_setConeAngleInner(AUD_Handle* handle, float value)
{
assert(handle);
std::shared_ptr<I3DHandle> h = std::dynamic_pointer_cast<I3DHandle>(*handle);
if(h.get())
return h->setConeAngleInner(value);
return false;
}
AUD_API float AUD_Handle_getConeAngleOuter(AUD_Handle* handle)
{
assert(handle);
std::shared_ptr<I3DHandle> h = std::dynamic_pointer_cast<I3DHandle>(*handle);
if(h.get())
return h->getConeAngleOuter();
return 0.0f;
}
AUD_API int AUD_Handle_setConeAngleOuter(AUD_Handle* handle, float value)
{
assert(handle);
std::shared_ptr<I3DHandle> h = std::dynamic_pointer_cast<I3DHandle>(*handle);
if(h.get())
return h->setConeAngleOuter(value);
return false;
}
AUD_API float AUD_Handle_getConeVolumeOuter(AUD_Handle* handle)
{
assert(handle);
std::shared_ptr<I3DHandle> h = std::dynamic_pointer_cast<I3DHandle>(*handle);
if(h.get())
return h->getConeVolumeOuter();
return 0.0f;
}
AUD_API int AUD_Handle_setConeVolumeOuter(AUD_Handle* handle, float value)
{
assert(handle);
std::shared_ptr<I3DHandle> h = std::dynamic_pointer_cast<I3DHandle>(*handle);
if(h.get())
return h->setConeVolumeOuter(value);
return false;
}
AUD_API float AUD_Handle_getDistanceMaximum(AUD_Handle* handle)
{
assert(handle);
std::shared_ptr<I3DHandle> h = std::dynamic_pointer_cast<I3DHandle>(*handle);
if(h.get())
return h->getDistanceMaximum();
return 0.0f;
}
AUD_API int AUD_Handle_setDistanceMaximum(AUD_Handle* handle, float value)
{
assert(handle);
std::shared_ptr<I3DHandle> h = std::dynamic_pointer_cast<I3DHandle>(*handle);
if(h.get())
return h->setDistanceMaximum(value);
return false;
}
AUD_API float AUD_Handle_getDistanceReference(AUD_Handle* handle)
{
assert(handle);
std::shared_ptr<I3DHandle> h = std::dynamic_pointer_cast<I3DHandle>(*handle);
if(h.get())
return h->getDistanceReference();
return 0.0f;
}
AUD_API int AUD_Handle_setDistanceReference(AUD_Handle* handle, float value)
{
assert(handle);
std::shared_ptr<I3DHandle> h = std::dynamic_pointer_cast<I3DHandle>(*handle);
if(h.get())
return h->setDistanceReference(value);
return false;
}
AUD_API int AUD_Handle_doesKeep(AUD_Handle* handle)
{
assert(handle);
return (*handle)->getKeep();
}
AUD_API int AUD_Handle_setKeep(AUD_Handle* handle, int value)
{
assert(handle);
return (*handle)->setKeep(value);
}
AUD_API int AUD_Handle_getLocation(AUD_Handle* handle, float value[3])
{
assert(handle);
std::shared_ptr<I3DHandle> h = std::dynamic_pointer_cast<I3DHandle>(*handle);
if(h.get())
{
Vector3 v = h->getLocation();
value[0] = v.x();
value[1] = v.y();
value[2] = v.z();
return true;
}
return false;
}
AUD_API int AUD_Handle_setLocation(AUD_Handle* handle, const float value[3])
{
assert(handle);
std::shared_ptr<I3DHandle> h = std::dynamic_pointer_cast<I3DHandle>(*handle);
if(h.get())
{
Vector3 v = Vector3(value[0], value[1], value[2]);
return h->setLocation(v);
}
return false;
}
AUD_API int AUD_Handle_getLoopCount(AUD_Handle* handle)
{
assert(handle);
return (*handle)->getLoopCount();
}
AUD_API int AUD_Handle_setLoopCount(AUD_Handle* handle, int value)
{
assert(handle);
return (*handle)->setLoopCount(value);
}
AUD_API int AUD_Handle_getOrientation(AUD_Handle* handle, float value[4])
{
assert(handle);
std::shared_ptr<I3DHandle> h = std::dynamic_pointer_cast<I3DHandle>(*handle);
if(h.get())
{
Quaternion v = h->getOrientation();
value[0] = v.x();
value[1] = v.y();
value[2] = v.z();
value[3] = v.w();
return true;
}
return false;
}
AUD_API int AUD_Handle_setOrientation(AUD_Handle* handle, const float value[4])
{
assert(handle);
std::shared_ptr<I3DHandle> h = std::dynamic_pointer_cast<I3DHandle>(*handle);
if(h.get())
{
Quaternion v(value[3], value[0], value[1], value[2]);
return h->setOrientation(v);
}
return false;
}
AUD_API float AUD_Handle_getPitch(AUD_Handle* handle)
{
assert(handle);
return (*handle)->getPitch();
}
AUD_API int AUD_Handle_setPitch(AUD_Handle* handle, float value)
{
assert(handle);
return (*handle)->setPitch(value);
}
AUD_API float AUD_Handle_getPosition(AUD_Handle* handle)
{
assert(handle);
return (*handle)->getPosition();
}
AUD_API int AUD_Handle_setPosition(AUD_Handle* handle, float value)
{
assert(handle);
return (*handle)->seek(value);
}
AUD_API int AUD_Handle_isRelative(AUD_Handle* handle)
{
assert(handle);
std::shared_ptr<I3DHandle> h = std::dynamic_pointer_cast<I3DHandle>(*handle);
if(h.get())
return h->isRelative();
return true;
}
AUD_API int AUD_Handle_setRelative(AUD_Handle* handle, int value)
{
assert(handle);
std::shared_ptr<I3DHandle> h = std::dynamic_pointer_cast<I3DHandle>(*handle);
if(h.get())
return h->setRelative(value);
return false;
}
AUD_API AUD_Status AUD_Handle_getStatus(AUD_Handle* handle)
{
assert(handle);
return static_cast<AUD_Status>((*handle)->getStatus());
}
AUD_API int AUD_Handle_getVelocity(AUD_Handle* handle, float value[3])
{
assert(handle);
std::shared_ptr<I3DHandle> h = std::dynamic_pointer_cast<I3DHandle>(*handle);
if(h.get())
{
Vector3 v = h->getVelocity();
value[0] = v.x();
value[1] = v.y();
value[2] = v.z();
return true;
}
return false;
}
AUD_API int AUD_Handle_setVelocity(AUD_Handle* handle, const float value[3])
{
assert(handle);
std::shared_ptr<I3DHandle> h = std::dynamic_pointer_cast<I3DHandle>(*handle);
if(h.get())
{
Vector3 v = Vector3(value[0], value[1], value[2]);
return h->setVelocity(v);
}
return false;
}
AUD_API float AUD_Handle_getVolume(AUD_Handle* handle)
{
assert(handle);
return (*handle)->getVolume();
}
AUD_API int AUD_Handle_setVolume(AUD_Handle* handle, float value)
{
assert(handle);
return (*handle)->setVolume(value);
}
AUD_API float AUD_Handle_getVolumeMaximum(AUD_Handle* handle)
{
assert(handle);
std::shared_ptr<I3DHandle> h = std::dynamic_pointer_cast<I3DHandle>(*handle);
if(h.get())
return h->getVolumeMaximum();
return 0.0f;
}
AUD_API int AUD_Handle_setVolumeMaximum(AUD_Handle* handle, float value)
{
assert(handle);
std::shared_ptr<I3DHandle> h = std::dynamic_pointer_cast<I3DHandle>(*handle);
if(h.get())
return h->setVolumeMaximum(value);
return false;
}
AUD_API float AUD_Handle_getVolumeMinimum(AUD_Handle* handle)
{
assert(handle);
std::shared_ptr<I3DHandle> h = std::dynamic_pointer_cast<I3DHandle>(*handle);
if(h.get())
return h->getVolumeMinimum();
return 0.0f;
}
AUD_API int AUD_Handle_setVolumeMinimum(AUD_Handle* handle, float value)
{
assert(handle);
std::shared_ptr<I3DHandle> h = std::dynamic_pointer_cast<I3DHandle>(*handle);
if(h.get())
return h->setVolumeMinimum(value);
return false;
}
AUD_API void AUD_Handle_free(AUD_Handle* handle)
{
delete handle;
}

308
extern/audaspace/bindings/C/AUD_Handle.h vendored Normal file
View File

@@ -0,0 +1,308 @@
/*******************************************************************************
* Copyright 2009-2016 Jörg Müller
*
* 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.
******************************************************************************/
#pragma once
#include "AUD_Types.h"
#ifdef __cplusplus
extern "C" {
#endif
/// Status of a playback handle.
typedef enum
{
AUD_STATUS_INVALID = 0, /// Invalid handle. Maybe due to stopping.
AUD_STATUS_PLAYING, /// Sound is playing.
AUD_STATUS_PAUSED, /// Sound is being paused.
AUD_STATUS_STOPPED /// Sound is stopped but kept in the device.
} AUD_Status;
/**
* Pauses a played back sound.
* \param handle The handle to the sound.
* \return Whether the handle has been playing or not.
*/
extern AUD_API int AUD_Handle_pause(AUD_Handle* handle);
/**
* Resumes a paused sound.
* \param handle The handle to the sound.
* \return Whether the handle has been paused or not.
*/
extern AUD_API int AUD_Handle_resume(AUD_Handle* handle);
/**
* Stops a playing or paused sound.
* \param handle The handle to the sound.
* \return Whether the handle has been valid or not.
*/
extern AUD_API int AUD_Handle_stop(AUD_Handle* handle);
/**
* Retrieves the attenuation of a handle.
* param handle The handle to get the attenuation from.
* return The attenuation of the handle.
*/
extern AUD_API float AUD_Handle_getAttenuation(AUD_Handle* handle);
/**
* Sets the attenuation of a handle.
* param handle The handle to set the attenuation from.
* param value The new attenuation to set.
*/
extern AUD_API int AUD_Handle_setAttenuation(AUD_Handle* handle, float value);
/**
* Retrieves the cone angle inner of a handle.
* param handle The handle to get the cone angle inner from.
* return The cone angle inner of the handle.
*/
extern AUD_API float AUD_Handle_getConeAngleInner(AUD_Handle* handle);
/**
* Sets the cone angle inner of a handle.
* param handle The handle to set the cone angle inner from.
* param value The new cone angle inner to set.
*/
extern AUD_API int AUD_Handle_setConeAngleInner(AUD_Handle* handle, float value);
/**
* Retrieves the cone angle outer of a handle.
* param handle The handle to get the cone angle outer from.
* return The cone angle outer of the handle.
*/
extern AUD_API float AUD_Handle_getConeAngleOuter(AUD_Handle* handle);
/**
* Sets the cone angle outer of a handle.
* param handle The handle to set the cone angle outer from.
* param value The new cone angle outer to set.
*/
extern AUD_API int AUD_Handle_setConeAngleOuter(AUD_Handle* handle, float value);
/**
* Retrieves the cone volume outer of a handle.
* param handle The handle to get the cone volume outer from.
* return The cone volume outer of the handle.
*/
extern AUD_API float AUD_Handle_getConeVolumeOuter(AUD_Handle* handle);
/**
* Sets the cone volume outer of a handle.
* param handle The handle to set the cone volume outer from.
* param value The new cone volume outer to set.
*/
extern AUD_API int AUD_Handle_setConeVolumeOuter(AUD_Handle* handle, float value);
/**
* Retrieves the distance maximum of a handle.
* param handle The handle to get the distance maximum from.
* return The distance maximum of the handle.
*/
extern AUD_API float AUD_Handle_getDistanceMaximum(AUD_Handle* handle);
/**
* Sets the distance maximum of a handle.
* param handle The handle to set the distance maximum from.
* param value The new distance maximum to set.
*/
extern AUD_API int AUD_Handle_setDistanceMaximum(AUD_Handle* handle, float value);
/**
* Retrieves the distance reference of a handle.
* param handle The handle to get the distance reference from.
* return The distance reference of the handle.
*/
extern AUD_API float AUD_Handle_getDistanceReference(AUD_Handle* handle);
/**
* Sets the distance reference of a handle.
* param handle The handle to set the distance reference from.
* param value The new distance reference to set.
*/
extern AUD_API int AUD_Handle_setDistanceReference(AUD_Handle* handle, float value);
/**
* Retrieves the keep of a handle.
* param handle The handle to get the keep from.
* return The keep of the handle.
*/
extern AUD_API int AUD_Handle_doesKeep(AUD_Handle* handle);
/**
* Sets the keep of a handle.
* param handle The handle to set the keep from.
* param value The new keep to set.
*/
extern AUD_API int AUD_Handle_setKeep(AUD_Handle* handle, int value);
/**
* Retrieves the location of a handle.
* param handle The handle to get the location from.
* return The location of the handle.
*/
extern AUD_API int AUD_Handle_getLocation(AUD_Handle* handle, float value[3]);
/**
* Sets the location of a handle.
* param handle The handle to set the location from.
* param value The new location to set.
*/
extern AUD_API int AUD_Handle_setLocation(AUD_Handle* handle, const float value[3]);
/**
* Retrieves the loop count of a handle.
* param handle The handle to get the loop count from.
* return The loop count of the handle.
*/
extern AUD_API int AUD_Handle_getLoopCount(AUD_Handle* handle);
/**
* Sets the loop count of a handle.
* param handle The handle to set the loop count from.
* param value The new loop count to set.
*/
extern AUD_API int AUD_Handle_setLoopCount(AUD_Handle* handle, int value);
/**
* Retrieves the orientation of a handle.
* param handle The handle to get the orientation from.
* return The orientation of the handle.
*/
extern AUD_API int AUD_Handle_getOrientation(AUD_Handle* handle, float value[4]);
/**
* Sets the orientation of a handle.
* param handle The handle to set the orientation from.
* param value The new orientation to set.
*/
extern AUD_API int AUD_Handle_setOrientation(AUD_Handle* handle, const float value[4]);
/**
* Retrieves the pitch of a handle.
* param handle The handle to get the pitch from.
* return The pitch of the handle.
*/
extern AUD_API float AUD_Handle_getPitch(AUD_Handle* handle);
/**
* Sets the pitch of a handle.
* param handle The handle to set the pitch from.
* param value The new pitch to set.
*/
extern AUD_API int AUD_Handle_setPitch(AUD_Handle* handle, float value);
/**
* Retrieves the position of a handle.
* param handle The handle to get the position from.
* return The position of the handle.
*/
extern AUD_API float AUD_Handle_getPosition(AUD_Handle* handle);
/**
* Sets the position of a handle.
* param handle The handle to set the position from.
* param value The new position to set.
*/
extern AUD_API int AUD_Handle_setPosition(AUD_Handle* handle, float value);
/**
* Retrieves the relative of a handle.
* param handle The handle to get the relative from.
* return The relative of the handle.
*/
extern AUD_API int AUD_Handle_isRelative(AUD_Handle* handle);
/**
* Sets the relative of a handle.
* param handle The handle to set the relative from.
* param value The new relative to set.
*/
extern AUD_API int AUD_Handle_setRelative(AUD_Handle* handle, int value);
/**
* Retrieves the status of a handle.
* param handle The handle to get the status from.
* return The status of the handle.
*/
extern AUD_API AUD_Status AUD_Handle_getStatus(AUD_Handle* handle);
/**
* Retrieves the velocity of a handle.
* param handle The handle to get the velocity from.
* return The velocity of the handle.
*/
extern AUD_API int AUD_Handle_getVelocity(AUD_Handle* handle, float value[3]);
/**
* Sets the velocity of a handle.
* param handle The handle to set the velocity from.
* param value The new velocity to set.
*/
extern AUD_API int AUD_Handle_setVelocity(AUD_Handle* handle, const float value[3]);
/**
* Retrieves the volume of a handle.
* param handle The handle to get the volume from.
* return The volume of the handle.
*/
extern AUD_API float AUD_Handle_getVolume(AUD_Handle* handle);
/**
* Sets the volume of a handle.
* param handle The handle to set the volume from.
* param value The new volume to set.
*/
extern AUD_API int AUD_Handle_setVolume(AUD_Handle* handle, float value);
/**
* Retrieves the volume maximum of a handle.
* param handle The handle to get the volume maximum from.
* return The volume maximum of the handle.
*/
extern AUD_API float AUD_Handle_getVolumeMaximum(AUD_Handle* handle);
/**
* Sets the volume maximum of a handle.
* param handle The handle to set the volume maximum from.
* param value The new volume maximum to set.
*/
extern AUD_API int AUD_Handle_setVolumeMaximum(AUD_Handle* handle, float value);
/**
* Retrieves the volume minimum of a handle.
* param handle The handle to get the volume minimum from.
* return The volume minimum of the handle.
*/
extern AUD_API float AUD_Handle_getVolumeMinimum(AUD_Handle* handle);
/**
* Sets the volume minimum of a handle.
* param handle The handle to set the volume minimum from.
* param value The new volume minimum to set.
*/
extern AUD_API int AUD_Handle_setVolumeMinimum(AUD_Handle* handle, float value);
/**
* Frees a handle.
* \param channel Handle to free.
*/
extern AUD_API void AUD_Handle_free(AUD_Handle* channel);
#ifdef __cplusplus
}
#endif

View File

@@ -0,0 +1,44 @@
/*******************************************************************************
* Copyright 2009-2015 Juan Francisco Crespo Galán
*
* 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 "Exception.h"
#include <cassert>
using namespace aud;
#define AUD_CAPI_IMPLEMENTATION
#include "AUD_ImpulseResponse.h"
AUD_API AUD_ImpulseResponse* AUD_ImpulseResponse_create(AUD_Sound* sound)
{
assert(sound);
try
{
return new AUD_ImpulseResponse(new ImpulseResponse(std::make_shared<StreamBuffer>(*sound)));
}
catch(Exception&)
{
return nullptr;
}
}
AUD_API void AUD_ImpulseResponse_free(AUD_ImpulseResponse* filter)
{
assert(filter);
delete filter;
}

View File

@@ -0,0 +1,40 @@
/*******************************************************************************
* Copyright 2009-2015 Juan Francisco Crespo Galán
*
* 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.
******************************************************************************/
#pragma once
#include "AUD_Types.h"
#ifdef __cplusplus
extern "C" {
#endif
/**
* Creates a new ImpulseResponse object.
* \param sound A Sound object representing a impulse response.
* \return The new ImpulseResponse object.
*/
extern AUD_API AUD_ImpulseResponse* AUD_ImpulseResponse_create(AUD_Sound* sound);
/**
* Deletes a ImpulseResponse object.
* \param threadPool The ImpulseResponse object to be deleted.
*/
extern AUD_API void AUD_ImpulseResponse_free(AUD_ImpulseResponse* filter);
#ifdef __cplusplus
}
#endif

View File

@@ -0,0 +1,94 @@
/*******************************************************************************
* Copyright 2015-2016 Juan Francisco Crespo Galán
*
* 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 "Exception.h"
#include <cassert>
using namespace aud;
#define AUD_CAPI_IMPLEMENTATION
#include "AUD_PlaybackManager.h"
AUD_API AUD_PlaybackManager* AUD_PlaybackManager_create(AUD_Device* device)
{
assert(device);
try
{
return new AUD_PlaybackManager(new PlaybackManager(*device));
}
catch(Exception&)
{
return nullptr;
}
}
AUD_API void AUD_PlaybackManager_free(AUD_PlaybackManager* manager)
{
assert(manager);
delete manager;
}
AUD_API void AUD_PlaybackManager_play(AUD_PlaybackManager* manager, AUD_Sound* sound, unsigned int catKey)
{
assert(manager);
assert(sound);
(*manager)->play(*sound, catKey);
}
AUD_API int AUD_PlaybackManager_resume(AUD_PlaybackManager* manager, unsigned int catKey)
{
assert(manager);
return (*manager)->resume(catKey);
}
AUD_API int AUD_PlaybackManager_pause(AUD_PlaybackManager* manager, unsigned int catKey)
{
assert(manager);
return (*manager)->pause(catKey);
}
AUD_API unsigned int AUD_PlaybackManager_addCategory(AUD_PlaybackManager* manager, float volume)
{
assert(manager);
return (*manager)->addCategory(volume);
}
AUD_API float AUD_PlaybackManager_getVolume(AUD_PlaybackManager* manager, unsigned int catKey)
{
assert(manager);
return (*manager)->getVolume(catKey);
}
AUD_API int AUD_PlaybackManager_setVolume(AUD_PlaybackManager* manager, float volume, unsigned int catKey)
{
assert(manager);
return (*manager)->setVolume(volume, catKey);
}
AUD_API int AUD_PlaybackManager_stop(AUD_PlaybackManager* manager, unsigned int catKey)
{
assert(manager);
return (*manager)->stop(catKey);
}
AUD_API void AUD_PlaybackManager_clean(AUD_PlaybackManager* manager)
{
assert(manager);
(*manager)->clean();
}

View File

@@ -0,0 +1,103 @@
/*******************************************************************************
* Copyright 2015-2016 Juan Francisco Crespo Galán
*
* 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.
******************************************************************************/
#pragma once
#include "AUD_Types.h"
#ifdef __cplusplus
extern "C" {
#endif
/**
* Creates a new PlaybackManager object.
* \param device The device that will be used to play sounds.
* \return The new PlaybackManager object.
*/
extern AUD_API AUD_PlaybackManager* AUD_PlaybackManager_create(AUD_Device* device);
/**
* Deletes a PlaybackManager object.
* \param manager The PlaybackManager object to be deleted.
*/
extern AUD_API void AUD_PlaybackManager_free(AUD_PlaybackManager* manager);
/**
* Plays a sound through the playback manager, adding it into a category.
* \param manager The PlaybackManager object.
* \param sound The sound to be played.
* \param catKey The key of the category into which the sound will be added. If it doesn't exist a new one will be creatd.
*/
extern AUD_API void AUD_PlaybackManager_play(AUD_PlaybackManager* manager, AUD_Sound* sound, unsigned int catKey);
/**
* Resumes the playback of all the paused sounds assigned to a category of a playback manager.
* \param manager The PlaybackManager object.
* \param catKey The key of the category.
* \return 0 if the category doesn't exist.
*/
extern AUD_API int AUD_PlaybackManager_resume(AUD_PlaybackManager* manager, unsigned int catKey);
/**
* Pauses all the sounds assigned to a category of a playback manager.
* \param manager The PlaybackManager object.
* \param catKey The key of the category.
* \return 0 if the category doesn't exist.
*/
extern AUD_API int AUD_PlaybackManager_pause(AUD_PlaybackManager* manager, unsigned int catKey);
/**
* Adds a new category with a custom volume.
* \param manager The PlaybackManager object.
* \param volume The volume value.
* \return The key of the new category.
*/
extern AUD_API unsigned int AUD_PlaybackManager_addCategory(AUD_PlaybackManager* manager, float volume);
/**
* Retrieves the volume of a category of a playback manager.
* \param manager The PlaybackManager object.
* \param catKey The key of the category.
* \return The volume of the category.
*/
extern AUD_API float AUD_PlaybackManager_getVolume(AUD_PlaybackManager* manager, unsigned int catKey);
/**
* Changes the voulume of a category of a playback manager.
* \param manager The PlaybackManager object.
* \param volume The new volume of the category.
* \param catKey The key of the category.
* \return 0 if the category doesn't exist.
*/
extern AUD_API int AUD_PlaybackManager_setVolume(AUD_PlaybackManager* manager, float volume, unsigned int catKey);
/**
* Stops all the sounds assigned to a category of a playback manager.
* \param manager The PlaybackManager object.
* \param catKey The key of the category.
* \return 0 if the category doesn't exist.
*/
extern AUD_API int AUD_PlaybackManager_stop(AUD_PlaybackManager* manager, unsigned int catKey);
/**
* Cleans all the invalid handles in a playback manager
* \param manager The PlaybackManager object.
*/
extern AUD_API void AUD_PlaybackManager_clean(AUD_PlaybackManager* manager);
#ifdef __cplusplus
}
#endif

View File

@@ -0,0 +1,315 @@
/*******************************************************************************
* Copyright 2009-2016 Jörg Müller
*
* 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 "devices/I3DDevice.h"
#include "devices/DeviceManager.h"
#include "sequence/Sequence.h"
#include "Exception.h"
#include <cassert>
using namespace aud;
#define AUD_CAPI_IMPLEMENTATION
#include "AUD_Sequence.h"
AUD_API AUD_Sound* AUD_Sequence_create(float fps, int muted)
{
// specs are changed at a later point!
Specs specs;
specs.channels = CHANNELS_STEREO;
specs.rate = RATE_48000;
AUD_Sound* sequence = new AUD_Sound(std::shared_ptr<Sequence>(new Sequence(specs, fps, muted)));
return sequence;
}
AUD_API void AUD_Sequence_free(AUD_Sound* sequence)
{
delete sequence;
}
AUD_API AUD_SequenceEntry* AUD_Sequence_add(AUD_Sound* sequence, AUD_Sound* sound, float begin, float end, float skip)
{
if(!sound)
return new AUD_SequenceEntry(((Sequence *)sequence->get())->add(AUD_Sound(), begin, end, skip));
return new AUD_SequenceEntry(((Sequence *)sequence->get())->add(*sound, begin, end, skip));
}
AUD_API void AUD_Sequence_remove(AUD_Sound* sequence, AUD_SequenceEntry* entry)
{
dynamic_cast<Sequence *>(sequence->get())->remove(*entry);
delete entry;
}
AUD_API void AUD_Sequence_setAnimationData(AUD_Sound* sequence, AUD_AnimateablePropertyType type, int frame, float* data, char animated)
{
AnimateableProperty* prop = dynamic_cast<Sequence *>(sequence->get())->getAnimProperty(static_cast<AnimateablePropertyType>(type));
if(animated)
{
if(frame >= 0)
{
prop->write(data, frame, 1);
}
}
else
{
prop->write(data);
}
}
AUD_API AUD_DistanceModel AUD_Sequence_getDistanceModel(AUD_Sound* sequence)
{
assert(sequence);
return static_cast<AUD_DistanceModel>(dynamic_cast<Sequence *>(sequence->get())->getDistanceModel());
}
AUD_API void AUD_Sequence_setDistanceModel(AUD_Sound* sequence, AUD_DistanceModel value)
{
assert(sequence);
dynamic_cast<Sequence *>(sequence->get())->setDistanceModel(static_cast<DistanceModel>(value));
}
AUD_API float AUD_Sequence_getDopplerFactor(AUD_Sound* sequence)
{
assert(sequence);
return dynamic_cast<Sequence *>(sequence->get())->getDopplerFactor();
}
AUD_API void AUD_Sequence_setDopplerFactor(AUD_Sound* sequence, float value)
{
assert(sequence);
dynamic_cast<Sequence *>(sequence->get())->setDopplerFactor(value);
}
AUD_API float AUD_Sequence_getFPS(AUD_Sound* sequence)
{
assert(sequence);
return dynamic_cast<Sequence *>(sequence->get())->getFPS();
}
AUD_API void AUD_Sequence_setFPS(AUD_Sound* sequence, float value)
{
assert(sequence);
dynamic_cast<Sequence *>(sequence->get())->setFPS(value);
}
AUD_API int AUD_Sequence_isMuted(AUD_Sound* sequence)
{
assert(sequence);
return dynamic_cast<Sequence *>(sequence->get())->isMuted();
}
AUD_API void AUD_Sequence_setMuted(AUD_Sound* sequence, int value)
{
assert(sequence);
dynamic_cast<Sequence *>(sequence->get())->mute(value);
}
static inline AUD_Specs convSpecToC(aud::Specs specs)
{
AUD_Specs s;
s.channels = static_cast<AUD_Channels>(specs.channels);
s.rate = static_cast<AUD_SampleRate>(specs.rate);
return s;
}
static inline aud::Specs convCToSpec(AUD_Specs specs)
{
aud::Specs s;
s.channels = static_cast<Channels>(specs.channels);
s.rate = static_cast<SampleRate>(specs.rate);
return s;
}
AUD_API AUD_Specs AUD_Sequence_getSpecs(AUD_Sound* sequence)
{
assert(sequence);
return convSpecToC(dynamic_cast<Sequence *>(sequence->get())->getSpecs());
}
AUD_API void AUD_Sequence_setSpecs(AUD_Sound* sequence, AUD_Specs value)
{
assert(sequence);
dynamic_cast<Sequence *>(sequence->get())->setSpecs(convCToSpec(value));
}
AUD_API float AUD_Sequence_getSpeedOfSound(AUD_Sound* sequence)
{
assert(sequence);
return dynamic_cast<Sequence *>(sequence->get())->getSpeedOfSound();
}
AUD_API void AUD_Sequence_setSpeedOfSound(AUD_Sound* sequence, float value)
{
assert(sequence);
dynamic_cast<Sequence *>(sequence->get())->setSpeedOfSound(value);
}
AUD_API void AUD_SequenceEntry_move(AUD_SequenceEntry* entry, float begin, float end, float skip)
{
(*entry)->move(begin, end, skip);
}
AUD_API void AUD_SequenceEntry_setAnimationData(AUD_SequenceEntry* entry, AUD_AnimateablePropertyType type, int frame, float* data, char animated)
{
AnimateableProperty* prop = (*entry)->getAnimProperty(static_cast<AnimateablePropertyType>(type));
if(animated)
{
if(frame >= 0)
prop->write(data, frame, 1);
}
else
{
prop->write(data);
}
}
AUD_API float AUD_SequenceEntry_getAttenuation(AUD_SequenceEntry* sequence_entry)
{
assert(sequence_entry);
return (*sequence_entry)->getAttenuation();
}
AUD_API void AUD_SequenceEntry_setAttenuation(AUD_SequenceEntry* sequence_entry, float value)
{
assert(sequence_entry);
(*sequence_entry)->setAttenuation(value);
}
AUD_API float AUD_SequenceEntry_getConeAngleInner(AUD_SequenceEntry* sequence_entry)
{
assert(sequence_entry);
return (*sequence_entry)->getConeAngleInner();
}
AUD_API void AUD_SequenceEntry_setConeAngleInner(AUD_SequenceEntry* sequence_entry, float value)
{
assert(sequence_entry);
(*sequence_entry)->setConeAngleInner(value);
}
AUD_API float AUD_SequenceEntry_getConeAngleOuter(AUD_SequenceEntry* sequence_entry)
{
assert(sequence_entry);
return (*sequence_entry)->getConeAngleOuter();
}
AUD_API void AUD_SequenceEntry_setConeAngleOuter(AUD_SequenceEntry* sequence_entry, float value)
{
assert(sequence_entry);
(*sequence_entry)->setConeAngleOuter(value);
}
AUD_API float AUD_SequenceEntry_getConeVolumeOuter(AUD_SequenceEntry* sequence_entry)
{
assert(sequence_entry);
return (*sequence_entry)->getConeVolumeOuter();
}
AUD_API void AUD_SequenceEntry_setConeVolumeOuter(AUD_SequenceEntry* sequence_entry, float value)
{
assert(sequence_entry);
(*sequence_entry)->setConeVolumeOuter(value);
}
AUD_API float AUD_SequenceEntry_getDistanceMaximum(AUD_SequenceEntry* sequence_entry)
{
assert(sequence_entry);
return (*sequence_entry)->getDistanceMaximum();
}
AUD_API void AUD_SequenceEntry_setDistanceMaximum(AUD_SequenceEntry* sequence_entry, float value)
{
assert(sequence_entry);
(*sequence_entry)->setDistanceMaximum(value);
}
AUD_API float AUD_SequenceEntry_getDistanceReference(AUD_SequenceEntry* sequence_entry)
{
assert(sequence_entry);
return (*sequence_entry)->getDistanceReference();
}
AUD_API void AUD_SequenceEntry_setDistanceReference(AUD_SequenceEntry* sequence_entry, float value)
{
assert(sequence_entry);
(*sequence_entry)->setDistanceReference(value);
}
AUD_API int AUD_SequenceEntry_isMuted(AUD_SequenceEntry* sequence_entry)
{
assert(sequence_entry);
return (*sequence_entry)->isMuted();
}
AUD_API void AUD_SequenceEntry_setMuted(AUD_SequenceEntry* sequence_entry, int value)
{
assert(sequence_entry);
(*sequence_entry)->mute(value);
}
AUD_API int AUD_SequenceEntry_isRelative(AUD_SequenceEntry* sequence_entry)
{
assert(sequence_entry);
return (*sequence_entry)->isRelative();
}
AUD_API void AUD_SequenceEntry_setRelative(AUD_SequenceEntry* sequence_entry, int value)
{
assert(sequence_entry);
(*sequence_entry)->setRelative(value);
}
AUD_API AUD_Sound* AUD_SequenceEntry_getSound(AUD_SequenceEntry* sequence_entry)
{
assert(sequence_entry);
return new std::shared_ptr<ISound>((*sequence_entry)->getSound());
}
AUD_API void AUD_SequenceEntry_setSound(AUD_SequenceEntry* sequence_entry, AUD_Sound* value)
{
assert(sequence_entry);
if(value)
(*sequence_entry)->setSound(*value);
else
(*sequence_entry)->setSound(AUD_Sound());
}
AUD_API float AUD_SequenceEntry_getVolumeMaximum(AUD_SequenceEntry* sequence_entry)
{
assert(sequence_entry);
return (*sequence_entry)->getVolumeMaximum();
}
AUD_API void AUD_SequenceEntry_setVolumeMaximum(AUD_SequenceEntry* sequence_entry, float value)
{
assert(sequence_entry);
(*sequence_entry)->setVolumeMaximum(value);
}
AUD_API float AUD_SequenceEntry_getVolumeMinimum(AUD_SequenceEntry* sequence_entry)
{
assert(sequence_entry);
return (*sequence_entry)->getVolumeMinimum();
}
AUD_API void AUD_SequenceEntry_setVolumeMinimum(AUD_SequenceEntry* sequence_entry, float value)
{
assert(sequence_entry);
(*sequence_entry)->setVolumeMinimum(value);
}

View File

@@ -0,0 +1,338 @@
/*******************************************************************************
* Copyright 2009-2016 Jörg Müller
*
* 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.
******************************************************************************/
#pragma once
#include "AUD_Device.h"
#ifdef __cplusplus
extern "C" {
#endif
/// Possible animatable properties for Sequence Factories and Entries.
typedef enum
{
AUD_AP_VOLUME,
AUD_AP_PANNING,
AUD_AP_PITCH,
AUD_AP_LOCATION,
AUD_AP_ORIENTATION
} AUD_AnimateablePropertyType;
/**
* Creates a new sequenced sound scene.
* \param fps The FPS of the scene.
* \param muted Whether the scene is muted.
* \return The new sound scene.
*/
extern AUD_API AUD_Sound* AUD_Sequence_create(float fps, int muted);
/**
* Deletes a sound scene.
* \param sequence The sound scene.
*/
extern AUD_API void AUD_Sequence_free(AUD_Sound* sequence);
/**
* Adds a new entry to the scene.
* \param sequence The sound scene.
* \param sound The sound this entry should play.
* \param begin The start time.
* \param end The end time or a negative value if determined by the sound.
* \param skip How much seconds should be skipped at the beginning.
* \return The entry added.
*/
extern AUD_API AUD_SequenceEntry* AUD_Sequence_add(AUD_Sound* sequence, AUD_Sound* sound, float begin, float end, float skip);
/**
* Removes an entry from the scene.
* \param sequence The sound scene.
* \param entry The entry to remove.
*/
extern AUD_API void AUD_Sequence_remove(AUD_Sound* sequence, AUD_SequenceEntry* entry);
/**
* Writes animation data to a sequence.
* \param sequence The sound scene.
* \param type The type of animation data.
* \param frame The frame this data is for.
* \param data The data to write.
* \param animated Whether the attribute is animated.
*/
extern AUD_API void AUD_Sequence_setAnimationData(AUD_Sound* sequence, AUD_AnimateablePropertyType type, int frame, float* data, char animated);
/**
* Retrieves the distance model of a sequence.
* param sequence The sequence to get the distance model from.
* return The distance model of the sequence.
*/
extern AUD_API AUD_DistanceModel AUD_Sequence_getDistanceModel(AUD_Sound* sequence);
/**
* Sets the distance model of a sequence.
* param sequence The sequence to set the distance model from.
* param value The new distance model to set.
*/
extern AUD_API void AUD_Sequence_setDistanceModel(AUD_Sound* sequence, AUD_DistanceModel value);
/**
* Retrieves the doppler factor of a sequence.
* param sequence The sequence to get the doppler factor from.
* return The doppler factor of the sequence.
*/
extern AUD_API float AUD_Sequence_getDopplerFactor(AUD_Sound* sequence);
/**
* Sets the doppler factor of a sequence.
* param sequence The sequence to set the doppler factor from.
* param value The new doppler factor to set.
*/
extern AUD_API void AUD_Sequence_setDopplerFactor(AUD_Sound* sequence, float value);
/**
* Retrieves the fps of a sequence.
* param sequence The sequence to get the fps from.
* return The fps of the sequence.
*/
extern AUD_API float AUD_Sequence_getFPS(AUD_Sound* sequence);
/**
* Sets the fps of a sequence.
* param sequence The sequence to set the fps from.
* param value The new fps to set.
*/
extern AUD_API void AUD_Sequence_setFPS(AUD_Sound* sequence, float value);
/**
* Retrieves the muted of a sequence.
* param sequence The sequence to get the muted from.
* return The muted of the sequence.
*/
extern AUD_API int AUD_Sequence_isMuted(AUD_Sound* sequence);
/**
* Sets the muted of a sequence.
* param sequence The sequence to set the muted from.
* param value The new muted to set.
*/
extern AUD_API void AUD_Sequence_setMuted(AUD_Sound* sequence, int value);
/**
* Retrieves the specs of a sequence.
* param sequence The sequence to get the specs from.
* return The specs of the sequence.
*/
extern AUD_API AUD_Specs AUD_Sequence_getSpecs(AUD_Sound* sequence);
/**
* Sets the specs of a sequence.
* param sequence The sequence to set the specs from.
* param value The new specs to set.
*/
extern AUD_API void AUD_Sequence_setSpecs(AUD_Sound* sequence, AUD_Specs value);
/**
* Retrieves the speed of sound of a sequence.
* param sequence The sequence to get the speed of sound from.
* return The speed of sound of the sequence.
*/
extern AUD_API float AUD_Sequence_getSpeedOfSound(AUD_Sound* sequence);
/**
* Sets the speed of sound of a sequence.
* param sequence The sequence to set the speed of sound from.
* param value The new speed of sound to set.
*/
extern AUD_API void AUD_Sequence_setSpeedOfSound(AUD_Sound* sequence, float value);
/**
* Moves the entry.
* \param entry The sequenced entry.
* \param begin The new start time.
* \param end The new end time or a negative value if unknown.
* \param skip How many seconds to skip at the beginning.
*/
extern AUD_API void AUD_SequenceEntry_move(AUD_SequenceEntry* entry, float begin, float end, float skip);
/**
* Writes animation data to a sequenced entry.
* \param entry The sequenced entry.
* \param type The type of animation data.
* \param frame The frame this data is for.
* \param data The data to write.
* \param animated Whether the attribute is animated.
*/
extern AUD_API void AUD_SequenceEntry_setAnimationData(AUD_SequenceEntry* entry, AUD_AnimateablePropertyType type, int frame, float* data, char animated);
/**
* Retrieves the attenuation of a sequence_entry.
* param sequence_entry The sequence_entry to get the attenuation from.
* return The attenuation of the sequence_entry.
*/
extern AUD_API float AUD_SequenceEntry_getAttenuation(AUD_SequenceEntry* sequence_entry);
/**
* Sets the attenuation of a sequence_entry.
* param sequence_entry The sequence_entry to set the attenuation from.
* param value The new attenuation to set.
*/
extern AUD_API void AUD_SequenceEntry_setAttenuation(AUD_SequenceEntry* sequence_entry, float value);
/**
* Retrieves the cone angle inner of a sequence_entry.
* param sequence_entry The sequence_entry to get the cone angle inner from.
* return The cone angle inner of the sequence_entry.
*/
extern AUD_API float AUD_SequenceEntry_getConeAngleInner(AUD_SequenceEntry* sequence_entry);
/**
* Sets the cone angle inner of a sequence_entry.
* param sequence_entry The sequence_entry to set the cone angle inner from.
* param value The new cone angle inner to set.
*/
extern AUD_API void AUD_SequenceEntry_setConeAngleInner(AUD_SequenceEntry* sequence_entry, float value);
/**
* Retrieves the cone angle outer of a sequence_entry.
* param sequence_entry The sequence_entry to get the cone angle outer from.
* return The cone angle outer of the sequence_entry.
*/
extern AUD_API float AUD_SequenceEntry_getConeAngleOuter(AUD_SequenceEntry* sequence_entry);
/**
* Sets the cone angle outer of a sequence_entry.
* param sequence_entry The sequence_entry to set the cone angle outer from.
* param value The new cone angle outer to set.
*/
extern AUD_API void AUD_SequenceEntry_setConeAngleOuter(AUD_SequenceEntry* sequence_entry, float value);
/**
* Retrieves the cone volume outer of a sequence_entry.
* param sequence_entry The sequence_entry to get the cone volume outer from.
* return The cone volume outer of the sequence_entry.
*/
extern AUD_API float AUD_SequenceEntry_getConeVolumeOuter(AUD_SequenceEntry* sequence_entry);
/**
* Sets the cone volume outer of a sequence_entry.
* param sequence_entry The sequence_entry to set the cone volume outer from.
* param value The new cone volume outer to set.
*/
extern AUD_API void AUD_SequenceEntry_setConeVolumeOuter(AUD_SequenceEntry* sequence_entry, float value);
/**
* Retrieves the distance maximum of a sequence_entry.
* param sequence_entry The sequence_entry to get the distance maximum from.
* return The distance maximum of the sequence_entry.
*/
extern AUD_API float AUD_SequenceEntry_getDistanceMaximum(AUD_SequenceEntry* sequence_entry);
/**
* Sets the distance maximum of a sequence_entry.
* param sequence_entry The sequence_entry to set the distance maximum from.
* param value The new distance maximum to set.
*/
extern AUD_API void AUD_SequenceEntry_setDistanceMaximum(AUD_SequenceEntry* sequence_entry, float value);
/**
* Retrieves the distance reference of a sequence_entry.
* param sequence_entry The sequence_entry to get the distance reference from.
* return The distance reference of the sequence_entry.
*/
extern AUD_API float AUD_SequenceEntry_getDistanceReference(AUD_SequenceEntry* sequence_entry);
/**
* Sets the distance reference of a sequence_entry.
* param sequence_entry The sequence_entry to set the distance reference from.
* param value The new distance reference to set.
*/
extern AUD_API void AUD_SequenceEntry_setDistanceReference(AUD_SequenceEntry* sequence_entry, float value);
/**
* Retrieves the muted of a sequence_entry.
* param sequence_entry The sequence_entry to get the muted from.
* return The muted of the sequence_entry.
*/
extern AUD_API int AUD_SequenceEntry_isMuted(AUD_SequenceEntry* sequence_entry);
/**
* Sets the muted of a sequence_entry.
* param sequence_entry The sequence_entry to set the muted from.
* param value The new muted to set.
*/
extern AUD_API void AUD_SequenceEntry_setMuted(AUD_SequenceEntry* sequence_entry, int value);
/**
* Retrieves the relative of a sequence_entry.
* param sequence_entry The sequence_entry to get the relative from.
* return The relative of the sequence_entry.
*/
extern AUD_API int AUD_SequenceEntry_isRelative(AUD_SequenceEntry* sequence_entry);
/**
* Sets the relative of a sequence_entry.
* param sequence_entry The sequence_entry to set the relative from.
* param value The new relative to set.
*/
extern AUD_API void AUD_SequenceEntry_setRelative(AUD_SequenceEntry* sequence_entry, int value);
/**
* Retrieves the sound of a sequence_entry.
* param sequence_entry The sequence_entry to get the sound from.
* return The sound of the sequence_entry.
*/
extern AUD_API AUD_Sound* AUD_SequenceEntry_getSound(AUD_SequenceEntry* sequence_entry);
/**
* Sets the sound of a sequence_entry.
* param sequence_entry The sequence_entry to set the sound from.
* param value The new sound to set.
*/
extern AUD_API void AUD_SequenceEntry_setSound(AUD_SequenceEntry* sequence_entry, AUD_Sound* value);
/**
* Retrieves the volume maximum of a sequence_entry.
* param sequence_entry The sequence_entry to get the volume maximum from.
* return The volume maximum of the sequence_entry.
*/
extern AUD_API float AUD_SequenceEntry_getVolumeMaximum(AUD_SequenceEntry* sequence_entry);
/**
* Sets the volume maximum of a sequence_entry.
* param sequence_entry The sequence_entry to set the volume maximum from.
* param value The new volume maximum to set.
*/
extern AUD_API void AUD_SequenceEntry_setVolumeMaximum(AUD_SequenceEntry* sequence_entry, float value);
/**
* Retrieves the volume minimum of a sequence_entry.
* param sequence_entry The sequence_entry to get the volume minimum from.
* return The volume minimum of the sequence_entry.
*/
extern AUD_API float AUD_SequenceEntry_getVolumeMinimum(AUD_SequenceEntry* sequence_entry);
/**
* Sets the volume minimum of a sequence_entry.
* param sequence_entry The sequence_entry to set the volume minimum from.
* param value The new volume minimum to set.
*/
extern AUD_API void AUD_SequenceEntry_setVolumeMinimum(AUD_SequenceEntry* sequence_entry, float value);
#ifdef __cplusplus
}
#endif

View File

@@ -0,0 +1,709 @@
/*******************************************************************************
* Copyright 2009-2016 Jörg Müller
*
* 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 "generator/Sawtooth.h"
#include "generator/Sine.h"
#include "generator/Silence.h"
#include "generator/Square.h"
#include "generator/Triangle.h"
#include "file/File.h"
#include "file/FileWriter.h"
#include "util/StreamBuffer.h"
#include "fx/Accumulator.h"
#include "fx/ADSR.h"
#include "fx/Delay.h"
#include "fx/Envelope.h"
#include "fx/Fader.h"
#include "fx/Highpass.h"
#include "fx/IIRFilter.h"
#include "fx/Limiter.h"
#include "fx/Loop.h"
#include "fx/Lowpass.h"
#include "fx/Pitch.h"
#include "fx/Reverse.h"
#include "fx/Sum.h"
#include "fx/Threshold.h"
#include "fx/Volume.h"
#include "fx/SoundList.h"
#include "fx/MutableSound.h"
#include "sequence/Double.h"
#include "sequence/Superpose.h"
#include "sequence/PingPong.h"
#include "respec/LinearResample.h"
#include "respec/JOSResample.h"
#include "respec/JOSResampleReader.h"
#include "respec/ChannelMapper.h"
#include "respec/ChannelMapperReader.h"
#include "util/Buffer.h"
#include "Exception.h"
#ifdef WITH_CONVOLUTION
#include "fx/BinauralSound.h"
#include "fx/ConvolverSound.h"
#endif
#include <cassert>
#include <cstring>
using namespace aud;
#define AUD_CAPI_IMPLEMENTATION
#include "AUD_Sound.h"
static inline AUD_Specs convSpecToC(aud::Specs specs)
{
AUD_Specs s;
s.channels = static_cast<AUD_Channels>(specs.channels);
s.rate = static_cast<AUD_SampleRate>(specs.rate);
return s;
}
static inline aud::Specs convCToSpec(AUD_Specs specs)
{
aud::Specs s;
s.channels = static_cast<Channels>(specs.channels);
s.rate = static_cast<SampleRate>(specs.rate);
return s;
}
AUD_API AUD_Specs AUD_Sound_getSpecs(AUD_Sound* sound)
{
assert(sound);
return convSpecToC((*sound)->createReader()->getSpecs());
}
AUD_API int AUD_Sound_getLength(AUD_Sound* sound)
{
assert(sound);
return (*sound)->createReader()->getLength();
}
AUD_API sample_t* AUD_Sound_data(AUD_Sound* sound, int* length, AUD_Specs* specs)
{
assert(sound);
assert(length);
assert(specs);
auto stream_buffer = std::dynamic_pointer_cast<StreamBuffer>(*sound);
if(!stream_buffer)
stream_buffer = std::make_shared<StreamBuffer>(*sound);
*specs = convSpecToC(stream_buffer->getSpecs());
auto buffer = stream_buffer->getBuffer();
*length = buffer->getSize() / AUD_SAMPLE_SIZE((*specs));
sample_t* data = new sample_t[buffer->getSize()];
std::memcpy(data, buffer->getBuffer(), buffer->getSize());
return data;
}
AUD_API void AUD_Sound_freeData(sample_t* data)
{
delete[] data;
}
AUD_API const char* AUD_Sound_write(AUD_Sound* sound, const char* filename, AUD_SampleRate rate, AUD_Channels channels, AUD_SampleFormat format, AUD_Container container, AUD_Codec codec, int bitrate, int buffersize)
{
assert(sound);
assert(filename);
try
{
std::shared_ptr<IReader> reader = (*sound)->createReader();
DeviceSpecs specs;
specs.specs = reader->getSpecs();
if((rate != RATE_INVALID) && (specs.rate != rate))
{
specs.rate = rate;
reader = std::make_shared<JOSResampleReader>(reader, rate);
}
if((channels != AUD_CHANNELS_INVALID) && (specs.channels != static_cast<Channels>(channels)))
{
specs.channels = static_cast<Channels>(channels);
reader = std::make_shared<ChannelMapperReader>(reader, specs.channels);
}
if(format == AUD_FORMAT_INVALID)
format = AUD_FORMAT_S16;
specs.format = static_cast<SampleFormat>(format);
const char* invalid_container_error = "Container could not be determined from filename.";
if(container == AUD_CONTAINER_INVALID)
{
std::string path = filename;
if(path.length() < 4)
return invalid_container_error;
std::string extension = path.substr(path.length() - 4);
if(extension == ".ac3")
container = AUD_CONTAINER_AC3;
else if(extension == "flac")
container = AUD_CONTAINER_FLAC;
else if(extension == ".mkv")
container = AUD_CONTAINER_MATROSKA;
else if(extension == ".mp2")
container = AUD_CONTAINER_MP2;
else if(extension == ".mp3")
container = AUD_CONTAINER_MP3;
else if(extension == ".ogg")
container = AUD_CONTAINER_OGG;
else if(extension == ".wav")
container = AUD_CONTAINER_WAV;
else
return invalid_container_error;
}
if(codec == AUD_CODEC_INVALID)
{
switch(container)
{
case AUD_CONTAINER_AC3:
codec = AUD_CODEC_AC3;
break;
case AUD_CONTAINER_FLAC:
codec = AUD_CODEC_FLAC;
break;
case AUD_CONTAINER_MATROSKA:
codec = AUD_CODEC_OPUS;
break;
case AUD_CONTAINER_MP2:
codec = AUD_CODEC_MP2;
break;
case AUD_CONTAINER_MP3:
codec = AUD_CODEC_MP3;
break;
case AUD_CONTAINER_OGG:
codec = AUD_CODEC_VORBIS;
break;
case AUD_CONTAINER_WAV:
codec = AUD_CODEC_PCM;
break;
default:
return "Unknown container, cannot select default codec.";
}
}
if(buffersize <= 0)
buffersize = AUD_DEFAULT_BUFFER_SIZE;
std::shared_ptr<IWriter> writer = FileWriter::createWriter(filename, specs, static_cast<Container>(container), static_cast<Codec>(codec), bitrate);
FileWriter::writeReader(reader, writer, 0, buffersize);
}
catch(Exception& e)
{
return "An exception occured while writing.";
}
return nullptr;
}
AUD_API AUD_Sound* AUD_Sound_buffer(sample_t* data, int length, AUD_Specs specs)
{
assert(data);
if(length <= 0 || specs.rate <= 0 || specs.channels <= 0)
{
return nullptr;
}
int size = length * AUD_SAMPLE_SIZE(specs);
std::shared_ptr<Buffer> buffer = std::make_shared<Buffer>(size);
std::memcpy(buffer->getBuffer(), data, size);
try
{
return new AUD_Sound(new StreamBuffer(buffer, convCToSpec(specs)));
}
catch(Exception&)
{
return nullptr;
}
}
AUD_API AUD_Sound* AUD_Sound_bufferFile(unsigned char* buffer, int size)
{
assert(buffer);
return new AUD_Sound(new File(buffer, size));
}
AUD_API AUD_Sound* AUD_Sound_cache(AUD_Sound* sound)
{
assert(sound);
try
{
return new AUD_Sound(new StreamBuffer(*sound));
}
catch(Exception&)
{
return nullptr;
}
}
AUD_API AUD_Sound* AUD_Sound_file(const char* filename)
{
assert(filename);
return new AUD_Sound(new File(filename));
}
AUD_API AUD_Sound* AUD_Sound_sawtooth(float frequency, AUD_SampleRate rate)
{
return new AUD_Sound(new Sawtooth(frequency, rate));
}
AUD_API AUD_Sound*AUD_Sound_silence()
{
return new AUD_Sound(new Silence());
}
AUD_API AUD_Sound* AUD_Sound_sine(float frequency, AUD_SampleRate rate)
{
return new AUD_Sound(new Sine(frequency, rate));
}
AUD_API AUD_Sound* AUD_Sound_square(float frequency, AUD_SampleRate rate)
{
return new AUD_Sound(new Square(frequency, rate));
}
AUD_API AUD_Sound* AUD_Sound_triangle(float frequency, AUD_SampleRate rate)
{
return new AUD_Sound(new Triangle(frequency, rate));
}
AUD_API AUD_Sound* AUD_Sound_accumulate(AUD_Sound* sound, int additive)
{
assert(sound);
try
{
return new AUD_Sound(new Accumulator(*sound, additive));
}
catch(Exception&)
{
return nullptr;
}
}
AUD_API AUD_Sound* AUD_Sound_ADSR(AUD_Sound* sound, float attack, float decay, float sustain, float release)
{
assert(sound);
try
{
return new AUD_Sound(new ADSR(*sound, attack, decay, sustain, release));
}
catch(Exception&)
{
return nullptr;
}
}
AUD_API AUD_Sound* AUD_Sound_delay(AUD_Sound* sound, float delay)
{
assert(sound);
try
{
return new AUD_Sound(new Delay(*sound, delay));
}
catch(Exception&)
{
return nullptr;
}
}
AUD_API AUD_Sound* AUD_Sound_envelope(AUD_Sound* sound, float attack, float release, float threshold, float arthreshold)
{
assert(sound);
try
{
return new AUD_Sound(new Envelope(*sound, attack, release, threshold, arthreshold));
}
catch(Exception&)
{
return nullptr;
}
}
AUD_API AUD_Sound* AUD_Sound_fadein(AUD_Sound* sound, float start, float length)
{
assert(sound);
try
{
return new AUD_Sound(new Fader(*sound, FADE_IN, start, length));
}
catch(Exception&)
{
return nullptr;
}
}
AUD_API AUD_Sound* AUD_Sound_fadeout(AUD_Sound* sound, float start, float length)
{
assert(sound);
try
{
return new AUD_Sound(new Fader(*sound, FADE_OUT, start, length));
}
catch(Exception&)
{
return nullptr;
}
}
AUD_API AUD_Sound* AUD_Sound_filter(AUD_Sound* sound, float* b, int b_length, float* a, int a_length)
{
assert(sound);
try
{
std::vector<float> a_coeff, b_coeff;
if(b)
for(int i = 0; i < b_length; i++)
b_coeff.push_back(b[i]);
if(a)
{
for(int i = 0; i < a_length; i++)
a_coeff.push_back(a[i]);
if(*a == 0.0f)
a_coeff[0] = 1.0f;
}
return new AUD_Sound(new IIRFilter(*sound, b_coeff, a_coeff));
}
catch(Exception&)
{
return nullptr;
}
}
AUD_API AUD_Sound* AUD_Sound_highpass(AUD_Sound* sound, float frequency, float Q)
{
assert(sound);
try
{
return new AUD_Sound(new Highpass(*sound, frequency, Q));
}
catch(Exception&)
{
return nullptr;
}
}
AUD_API AUD_Sound* AUD_Sound_limit(AUD_Sound* sound, float start, float end)
{
assert(sound);
try
{
return new AUD_Sound(new Limiter(*sound, start, end));
}
catch(Exception&)
{
return nullptr;
}
}
AUD_API AUD_Sound* AUD_Sound_loop(AUD_Sound* sound, int count)
{
assert(sound);
try
{
return new AUD_Sound(new Loop(*sound, count));
}
catch(Exception&)
{
return nullptr;
}
}
AUD_API AUD_Sound* AUD_Sound_lowpass(AUD_Sound* sound, float frequency, float Q)
{
assert(sound);
try
{
return new AUD_Sound(new Lowpass(*sound, frequency, Q));
}
catch(Exception&)
{
return nullptr;
}
}
AUD_API AUD_Sound* AUD_Sound_pitch(AUD_Sound* sound, float factor)
{
assert(sound);
try
{
return new AUD_Sound(new Pitch(*sound, factor));
}
catch(Exception&)
{
return nullptr;
}
}
AUD_API AUD_Sound* AUD_Sound_rechannel(AUD_Sound* sound, AUD_Channels channels)
{
assert(sound);
try
{
DeviceSpecs specs;
specs.channels = static_cast<Channels>(channels);
specs.rate = RATE_INVALID;
specs.format = FORMAT_INVALID;
return new AUD_Sound(new ChannelMapper(*sound, specs));
}
catch(Exception&)
{
return nullptr;
}
}
AUD_API AUD_Sound* AUD_Sound_resample(AUD_Sound* sound, AUD_SampleRate rate, bool high_quality)
{
assert(sound);
try
{
DeviceSpecs specs;
specs.channels = CHANNELS_INVALID;
specs.rate = rate;
specs.format = FORMAT_INVALID;
if(high_quality)
return new AUD_Sound(new JOSResample(*sound, specs));
else
return new AUD_Sound(new LinearResample(*sound, specs));
}
catch(Exception&)
{
return nullptr;
}
}
AUD_API AUD_Sound* AUD_Sound_reverse(AUD_Sound* sound)
{
assert(sound);
try
{
return new AUD_Sound(new Reverse(*sound));
}
catch(Exception&)
{
return nullptr;
}
}
AUD_API AUD_Sound* AUD_Sound_sum(AUD_Sound* sound)
{
assert(sound);
try
{
return new AUD_Sound(new Sum(*sound));
}
catch(Exception&)
{
return nullptr;
}
}
AUD_API AUD_Sound* AUD_Sound_threshold(AUD_Sound* sound, float threshold)
{
assert(sound);
try
{
return new AUD_Sound(new Threshold(*sound, threshold));
}
catch(Exception&)
{
return nullptr;
}
}
AUD_API AUD_Sound* AUD_Sound_volume(AUD_Sound* sound, float volume)
{
assert(sound);
try
{
return new AUD_Sound(new Volume(*sound, volume));
}
catch(Exception&)
{
return nullptr;
}
}
AUD_API AUD_Sound* AUD_Sound_join(AUD_Sound* first, AUD_Sound* second)
{
assert(first);
assert(second);
try
{
return new AUD_Sound(new Double(*first, *second));
}
catch(Exception&)
{
return nullptr;
}
}
AUD_API AUD_Sound* AUD_Sound_mix(AUD_Sound* first, AUD_Sound* second)
{
assert(first);
assert(second);
try
{
return new AUD_Sound(new Superpose(*first, *second));
}
catch(Exception&)
{
return nullptr;
}
}
AUD_API AUD_Sound* AUD_Sound_pingpong(AUD_Sound* sound)
{
assert(sound);
try
{
return new AUD_Sound(new PingPong(*sound));
}
catch(Exception&)
{
return nullptr;
}
}
AUD_API void AUD_Sound_free(AUD_Sound* sound)
{
assert(sound);
delete sound;
}
AUD_API AUD_Sound* AUD_Sound_copy(AUD_Sound* sound)
{
return new std::shared_ptr<ISound>(*sound);
}
AUD_API AUD_Sound* AUD_Sound_list(int random)
{
try
{
return new AUD_Sound(new SoundList(random));
}
catch(Exception&)
{
return nullptr;
}
}
AUD_API int AUD_SoundList_addSound(AUD_Sound* list, AUD_Sound* sound)
{
assert(sound);
assert(list);
std::shared_ptr<SoundList> s = std::dynamic_pointer_cast<SoundList>(*list);
if(s.get())
{
s->addSound(*sound);
return 1;
}
else
return 0;
}
AUD_API AUD_Sound* AUD_Sound_mutable(AUD_Sound* sound)
{
assert(sound);
try
{
return new AUD_Sound(new MutableSound(*sound));
}
catch(Exception&)
{
return nullptr;
}
}
#ifdef WITH_CONVOLUTION
AUD_API AUD_Sound* AUD_Sound_Convolver(AUD_Sound* sound, AUD_ImpulseResponse* filter, AUD_ThreadPool* threadPool)
{
assert(sound);
assert(filter);
assert(threadPool);
try
{
return new AUD_Sound(new ConvolverSound(*sound, *filter, *threadPool));
}
catch(Exception&)
{
return nullptr;
}
}
AUD_API AUD_Sound* AUD_Sound_Binaural(AUD_Sound* sound, AUD_HRTF* hrtfs, AUD_Source* source, AUD_ThreadPool* threadPool)
{
assert(sound);
assert(hrtfs);
assert(source);
assert(threadPool);
try
{
return new AUD_Sound(new BinauralSound(*sound, *hrtfs, *source, *threadPool));
}
catch(Exception&)
{
return nullptr;
}
}
#endif

370
extern/audaspace/bindings/C/AUD_Sound.h vendored Normal file
View File

@@ -0,0 +1,370 @@
/*******************************************************************************
* Copyright 2009-2016 Jörg Müller
*
* 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.
******************************************************************************/
#pragma once
#include "AUD_Types.h"
#ifdef __cplusplus
extern "C" {
#endif
/**
* Retrieves the sample specification of the sound.
* \param sound The sound to retrieve from.
* \return The sample specification of the sound.
* \note This function creates a reader from the sound and deletes it again.
*/
extern AUD_API AUD_Specs AUD_Sound_getSpecs(AUD_Sound* sound);
/**
* Retrieves the approximate length of the sound.
* \param sound The sound to retrieve from.
* \return The length of the sound in samples.
* \note This function creates a reader from the sound and deletes it again.
*/
extern AUD_API int AUD_getLength(AUD_Sound* sound);
/**
* Reads a sound's samples into memory.
* \param sound The sound to read.
* \param length Pointer to store the length of memory read.
* \param specs Pointer to store the data's sample specification.
* \return A pointer to the sample data.
* \warning The data has to be freed with AUD_Sound_freeData.
*/
extern AUD_API sample_t* AUD_Sound_data(AUD_Sound* sound, int* length, AUD_Specs* specs);
/**
* Frees a buffer previously allocated with AUD_Sound_data.
* \param data The buffer to be freed.
*/
extern AUD_API void AUD_Sound_freeData(sample_t* data);
/**
* Writes the sound to a file.
* \param sound The sound to write.
* \param filename The path to write to..
* \param rate The sample rate to write with.
* \param channels The number of channels to write with.
* \param format The sample format to write with.
* \param container The container format for the file.
* \param codec The codec to use in the file.
* \param bitrate The bitrate to write with.
* \param buffersize The size of the writing buffer.
* \return A nullptr or an error message in case of error.
* \note Most parameters can be set to zero for default values.
*/
extern AUD_API const char* AUD_Sound_write(AUD_Sound* sound, const char* filename, AUD_SampleRate rate, AUD_Channels channels, AUD_SampleFormat format, AUD_Container container, AUD_Codec codec, int bitrate, int buffersize);
/**
* Creates a sound from a data buffer.
* \param data The data as interleaved samples.
* \param length The data's length in samples.
* \param specs The data's sample specification.
* \return A handle of the sound.
* \note The data gets copied to an internal memory buffer.
* The pointer does not need to stay valid for the lifetime of the object.
*/
extern AUD_API AUD_Sound* AUD_Sound_buffer(sample_t* data, int length, AUD_Specs specs);
/**
* Loads a sound file from a memory buffer.
* \param buffer The buffer which contains the sound file.
* \param size The size of the buffer.
* \return A handle of the sound file.
*/
extern AUD_API AUD_Sound* AUD_Sound_bufferFile(unsigned char* buffer, int size);
/**
* Caches a sound into a memory buffer.
* \param sound The sound to cache.
* \return A handle of the cached sound.
*/
extern AUD_API AUD_Sound* AUD_Sound_cache(AUD_Sound* sound);
/**
* Loads a sound file.
* \param filename The filename of the sound file.
* \return A handle of the sound file.
*/
extern AUD_API AUD_Sound* AUD_Sound_file(const char* filename);
/**
* Creates a sawtooth sound.
* \param frequency The frequency of the generated sawtooth sound.
* \param rate The sample rate of the sawtooth sound.
* \return A handle of the sound.
*/
extern AUD_API AUD_Sound* AUD_Sound_sawtooth(float frequency, AUD_SampleRate rate);
/**
* Creates a quiet sound.
* \return A handle of the sound.
*/
extern AUD_API AUD_Sound* AUD_Sound_silence();
/**
* Creates a sine sound.
* \param frequency The frequency of the generated sine sound.
* \param rate The sample rate of the sine sound.
* \return A handle of the sound.
*/
extern AUD_API AUD_Sound* AUD_Sound_sine(float frequency, AUD_SampleRate rate);
/**
* Creates a square sound.
* \param frequency The frequency of the generated square sound.
* \param rate The sample rate of the square sound.
* \return A handle of the sound.
*/
extern AUD_API AUD_Sound* AUD_Sound_square(float frequency, AUD_SampleRate rate);
/**
* Creates a triangle sound.
* \param frequency The frequency of the generated triangle sound.
* \param rate The sample rate of the triangle sound.
* \return A handle of the sound.
*/
extern AUD_API AUD_Sound* AUD_Sound_triangle(float frequency, AUD_SampleRate rate);
/**
* Accumulates a sound by summing over positive input differences thus generating a monotonic sigal.
* If additivity is set to true negative input differences get added too, but positive ones with a factor of two.
* Note that with additivity the signal is not monotonic anymore.
* \param sound The sound to accumulate.
* \param additive Whether the accumulation should be additive or not.
* \return A handle of the accumulated sound.
*/
extern AUD_API AUD_Sound* AUD_Sound_accumulate(AUD_Sound* sound, int additive);
/**
* Attack-Decay-Sustain-Release envelopes the volume of a sound.
* Note: there is currently no way to trigger the release with this API.
* \param sound The sound to filter.
* \param attack The attack time in seconds.
* \param decay The decay time in seconds.
* \param sustain The sustain level.
* \param release The release time in seconds.
* \return A handle of the filtered sound.
*/
extern AUD_API AUD_Sound* AUD_Sound_ADSR(AUD_Sound* sound, float attack, float decay, float sustain, float release);
/**
* Delays a sound.
* \param sound The sound to dealy.
* \param delay The delay in seconds.
* \return A handle of the delayed sound.
*/
extern AUD_API AUD_Sound* AUD_Sound_delay(AUD_Sound* sound, float delay);
/**
* Envelopes a sound.
* \param sound The sound to envelope.
* \param attack The attack factor.
* \param release The release factor.
* \param threshold The general threshold value.
* \param arthreshold The attack/release threshold value.
* \return A handle of the enveloped sound.
*/
extern AUD_API AUD_Sound* AUD_Sound_envelope(AUD_Sound* sound, float attack, float release, float threshold, float arthreshold);
/**
* Fade in a sound.
* \param sound The sound to be fade in.
* \param start The time when the fading should start in seconds.
* \param length The duration of the fade in seconds.
* \return A handle of the faded sound.
*/
extern AUD_API AUD_Sound* AUD_Sound_fadein(AUD_Sound* sound, float start, float length);
/**
* Fade out a sound.
* \param sound The sound to be fade out.
* \param start The time when the fading should start in seconds.
* \param length The duration of the fade in seconds.
* \return A handle of the faded sound.
*/
extern AUD_API AUD_Sound* AUD_Sound_fadeout(AUD_Sound* sound, float start, float length);
/**
* Filter a sound.
* \param sound The sound to be filtered.
* \param b The nominator filter coefficients, may be NULL.
* \param b_length The length of the b array.
* \param a The denominator filter coefficients, may be NULL.
* \param a_length The length of the a array.
* \return A handle of the filtered sound.
*/
extern AUD_API AUD_Sound* AUD_Sound_filter(AUD_Sound* sound, float* b, int b_length, float* a, int a_length);
/**
* Highpass filters a sound.
* \param sound The sound to filter.
* \param frequency The filter cut-off frequency.
* \param Q The filter quality. If usunsure which value to use, pass 1.0f.
* \return A handle of the filtered sound.
*/
extern AUD_API AUD_Sound* AUD_Sound_highpass(AUD_Sound* sound, float frequency, float Q);
/**
* Limits a sound.
* \param sound The sound to limit.
* \param start The start time in seconds.
* \param end The stop time in seconds.
* \return A handle of the limited sound.
*/
extern AUD_API AUD_Sound* AUD_Sound_limit(AUD_Sound* sound, float start, float end);
/**
* Loops a sound.
* \param sound The sound to loop.
* \param count How often the sound should be looped. Negative values mean endlessly.
* \return A handle of the looped sound.
*/
extern AUD_API AUD_Sound* AUD_Sound_loop(AUD_Sound* sound, int count);
/**
* Lowpass filters a sound.
* \param sound The sound to filter.
* \param frequency The filter cut-off frequency.
* \param Q The filter quality. If usunsure which value to use, pass 1.0f.
* \return A handle of the filtered sound.
*/
extern AUD_API AUD_Sound* AUD_Sound_lowpass(AUD_Sound* sound, float frequency, float Q);
/**
* Changes the pitch of a sound.
* \param sound The sound to change.
* \param factor The factor to change the pitch with.
* \return A handle of the pitched sound.
*/
extern AUD_API AUD_Sound* AUD_Sound_pitch(AUD_Sound* sound, float factor);
/**
* Rechannels the sound.
* \param sound The sound to rechannel.
* \param channels The new channel configuration.
* \return The rechanneled sound.
*/
extern AUD_API AUD_Sound* AUD_Sound_rechannel(AUD_Sound* sound, AUD_Channels channels);
/**
* Resamples the sound.
* \param sound The sound to resample.
* \param rate The new sample rate.
* \param high_quality When true use a higher quality but slower resampler.
* \return The resampled sound.
*/
extern AUD_API AUD_Sound* AUD_Sound_resample(AUD_Sound* sound, AUD_SampleRate rate, bool high_quality);
/**
* Reverses a sound. Make sure the sound source can be reversed.
* \param sound The sound to reverse.
* \return A handle of the reversed sound.
*/
extern AUD_API AUD_Sound* AUD_Sound_reverse(AUD_Sound* sound);
/**
* Sums the samples of a sound.
* \param sound The sound to sum.
* \return A handle of the summed sound.
*/
extern AUD_API AUD_Sound* AUD_Sound_sum(AUD_Sound* sound);
/**
* Turns a sound into a square wave by thresholding.
* \param sound The sound to threshold.
* \param threshold Threshold value over which an amplitude counts non-zero.
* \return A handle of the thresholded sound.
*/
extern AUD_API AUD_Sound* AUD_Sound_threshold(AUD_Sound* sound, float threshold);
/**
* Changes the volume of a sound.
* \param sound The sound to change.
* \param volume The new volume of the sound. Should be in the range 0 to 1. Use higher values with caution.
* \return A handle of the amplified sound.
*/
extern AUD_API AUD_Sound* AUD_Sound_volume(AUD_Sound* sound, float volume);
/**
* Joins two sound, which means playing them one after the other.
* \param first The first sound.
* \param second The second sound.
* \return A handle of the joined sound.
*/
extern AUD_API AUD_Sound* AUD_Sound_join(AUD_Sound* first, AUD_Sound* second);
/**
* Mixes two sound, which means superposing the sound samples.
* \param first The first sound.
* \param second The second sound.
* \return A handle of the mixed sound.
*/
extern AUD_API AUD_Sound* AUD_Sound_mix(AUD_Sound* first, AUD_Sound* second);
/**
* Ping pongs a sound.
* \param sound The sound to ping pong.
* \return A handle of the ping pong sound.
*/
extern AUD_API AUD_Sound* AUD_Sound_pingpong(AUD_Sound* sound);
/**
* Unloads a sound of any type.
* \param sound The handle of the sound.
*/
extern AUD_API void AUD_Sound_free(AUD_Sound* sound);
/**
* Copies a sound.
* \param sound Sound to copy.
* \return Copied sound.
*/
extern AUD_API AUD_Sound* AUD_Sound_copy(AUD_Sound* sound);
/**
* Creates an empty sound list that can contain several sounds.
* \param random A flag that indicates how the list will be played: Randomly or sequentially.
* if 0 the playback will be sequential, if not 0 the playback will be random.
* \return A handle of the sound list.
*/
extern AUD_API AUD_Sound* AUD_Sound_list(int random);
/**
* Adds a new sound to a sound list.
* \param list The sound list in which the sound will be added.
* \param sound The sound that will be added to the list.
* \return 0 if the sound couldn't be added (the list parameter isn't a sound list).
*/
extern AUD_API int AUD_SoundList_addSound(AUD_Sound* list, AUD_Sound* sound);
/**
* Creates a sound that will be restarted when sought backwards. If the original sound is a sound list, the playing sound can change.
* \param sound The handle of the sound.
* \return A handle of the mutable sound.
*/
extern AUD_API AUD_Sound* AUD_Sound_mutable(AUD_Sound* sound);
#ifdef WITH_CONVOLUTION
extern AUD_API AUD_Sound* AUD_Sound_Convolver(AUD_Sound* sound, AUD_ImpulseResponse* filter, AUD_ThreadPool* threadPool);
extern AUD_API AUD_Sound* AUD_Sound_Binaural(AUD_Sound* sound, AUD_HRTF* hrtfs, AUD_Source* source, AUD_ThreadPool* threadPool);
#endif
#ifdef __cplusplus
}
#endif

View File

@@ -0,0 +1,84 @@
/*******************************************************************************
* Copyright 2009-2015 Juan Francisco Crespo Galán
*
* 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 "Exception.h"
#include <cassert>
using namespace aud;
#define AUD_CAPI_IMPLEMENTATION
#include "AUD_Source.h"
extern AUD_API AUD_Source* AUD_Source_create(float azimuth, float elevation, float distance)
{
try
{
return new AUD_Source(new Source(azimuth, elevation, distance));
}
catch(Exception&)
{
return nullptr;
}
}
extern AUD_API void AUD_Source_free(AUD_Source* source)
{
assert(source);
delete source;
}
extern AUD_API float AUD_Source_getAzimuth(AUD_Source* source)
{
assert(source);
return (*source)->getAzimuth();
}
extern AUD_API float AUD_Source_getElevation(AUD_Source* source)
{
assert(source);
return (*source)->getElevation();
}
extern AUD_API float AUD_Source_getDistance(AUD_Source* source)
{
assert(source);
return (*source)->getDistance();
}
extern AUD_API void AUD_Source_setAzimuth(AUD_Source* source, float azimuth)
{
assert(source);
(*source)->setAzimuth(azimuth);
}
extern AUD_API void AUD_Source_setElevation(AUD_Source* source, float elevation)
{
assert(source);
(*source)->setElevation(elevation);
}
extern AUD_API void AUD_Source_setDistance(AUD_Source* source, float distance)
{
assert(source);
(*source)->setDistance(distance);
}

View File

@@ -0,0 +1,84 @@
/*******************************************************************************
* Copyright 2009-2015 Juan Francisco Crespo Galán
*
* 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.
******************************************************************************/
#pragma once
#include "AUD_Types.h"
#ifdef __cplusplus
extern "C" {
#endif
/**
* Creates a new Source object.
* \param azimuth The azimuth angle.
* \param elevation The elevation angle.
* \param elevation The distance value. [0,1]
* \return The new Source object.
*/
extern AUD_API AUD_Source* AUD_Source_create(float azimuth, float elevation, float distance);
/**
* Deletes a Source object.
* \param source The Source object to be deleted.
*/
extern AUD_API void AUD_Source_free(AUD_Source* source);
/**
* Retrieves the azimuth angle of a Source object.
* \param source The Source object.
* \return The azimuth angle.
*/
extern AUD_API float AUD_Source_getAzimuth(AUD_Source* source);
/**
* Retrieves the elevation angle oa a Source object.
* \param source The Source object.
* \return The elevation angle.
*/
extern AUD_API float AUD_Source_getElevation(AUD_Source* source);
/**
* Retrieves the distance of a Source object. [0,1]
* \param source The Source object.
* \return The distance.
*/
extern AUD_API float AUD_Source_getDistance(AUD_Source* distance);
/**
* Changes the azimuth angle of a Source object.
* \param source The Source object.
* \param azimuth The azimuth angle.
*/
extern AUD_API void AUD_Source_setAzimuth(AUD_Source* source, float azimuth);
/**
* Changes the elevation angle of a Source object.
* \param source The Source object.
* \param elevation The elevation angle.
*/
extern AUD_API void AUD_Source_setElevation(AUD_Source* source, float elevation);
/**
* Changes the distance of a Source object. [0,1]
* \param source The Source object.
* \param distance The distance.
*/
extern AUD_API void AUD_Source_setDistance(AUD_Source* source, float distance);
#ifdef __cplusplus
}
#endif

View File

@@ -0,0 +1,420 @@
/*******************************************************************************
* Copyright 2009-2016 Jörg Müller
*
* 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 "Exception.h"
#include "IReader.h"
#include "file/File.h"
#include "respec/ChannelMapper.h"
#include "fx/Lowpass.h"
#include "fx/Highpass.h"
#include "fx/Envelope.h"
#include "respec/LinearResample.h"
#include "fx/Threshold.h"
#include "fx/Accumulator.h"
#include "fx/Sum.h"
#include "generator/Silence.h"
#include "fx/Limiter.h"
#include "devices/DeviceManager.h"
#include "sequence/Sequence.h"
#include "file/FileWriter.h"
#include "devices/ReadDevice.h"
#include "plugin/PluginManager.h"
#include "devices/DeviceManager.h"
#include "devices/IDeviceFactory.h"
#include "devices/NULLDevice.h"
#include <cassert>
#include <cstring>
#include <cmath>
#include <sstream>
using namespace aud;
#define AUD_CAPI_IMPLEMENTATION
#include "AUD_Special.h"
static inline AUD_Specs convSpecToC(aud::Specs specs)
{
AUD_Specs s;
s.channels = static_cast<AUD_Channels>(specs.channels);
s.rate = static_cast<AUD_SampleRate>(specs.rate);
return s;
}
static inline aud::Specs convCToSpec(AUD_Specs specs)
{
aud::Specs s;
s.channels = static_cast<Channels>(specs.channels);
s.rate = static_cast<SampleRate>(specs.rate);
return s;
}
static inline AUD_DeviceSpecs convDSpecToC(aud::DeviceSpecs specs)
{
AUD_DeviceSpecs s;
s.specs = convSpecToC(specs.specs);
s.format = static_cast<AUD_SampleFormat>(specs.format);
return s;
}
static inline aud::DeviceSpecs convCToDSpec(AUD_DeviceSpecs specs)
{
aud::DeviceSpecs s;
s.specs = convCToSpec(specs.specs);
s.format = static_cast<SampleFormat>(specs.format);
return s;
}
AUD_API AUD_SoundInfo AUD_getInfo(AUD_Sound* sound)
{
assert(sound);
AUD_SoundInfo info;
info.specs.channels = AUD_CHANNELS_INVALID;
info.specs.rate = AUD_RATE_INVALID;
info.length = 0.0f;
try
{
std::shared_ptr<IReader> reader = (*sound)->createReader();
if(reader.get())
{
info.specs = convSpecToC(reader->getSpecs());
info.length = reader->getLength() / (float) info.specs.rate;
}
}
catch(Exception&)
{
}
return info;
}
AUD_API float* AUD_readSoundBuffer(const char* filename, float low, float high,
float attack, float release, float threshold,
int accumulate, int additive, int square,
float sthreshold, double samplerate, int* length)
{
Buffer buffer;
DeviceSpecs specs;
specs.channels = CHANNELS_MONO;
specs.rate = (SampleRate)samplerate;
std::shared_ptr<ISound> sound;
std::shared_ptr<ISound> file = std::shared_ptr<ISound>(new File(filename));
int position = 0;
try
{
std::shared_ptr<IReader> reader = file->createReader();
SampleRate rate = reader->getSpecs().rate;
sound = std::shared_ptr<ISound>(new ChannelMapper(file, specs));
if(high < rate)
sound = std::shared_ptr<ISound>(new Lowpass(sound, high));
if(low > 0)
sound = std::shared_ptr<ISound>(new Highpass(sound, low));
sound = std::shared_ptr<ISound>(new Envelope(sound, attack, release, threshold, 0.1f));
sound = std::shared_ptr<ISound>(new LinearResample(sound, specs));
if(square)
sound = std::shared_ptr<ISound>(new Threshold(sound, sthreshold));
if(accumulate)
sound = std::shared_ptr<ISound>(new Accumulator(sound, additive));
else if(additive)
sound = std::shared_ptr<ISound>(new Sum(sound));
reader = sound->createReader();
if(!reader.get())
return nullptr;
int len;
bool eos;
do
{
len = samplerate;
buffer.resize((position + len) * sizeof(float), true);
reader->read(len, eos, buffer.getBuffer() + position);
position += len;
} while(!eos);
}
catch(Exception&)
{
return nullptr;
}
float * result = (float *)malloc(position * sizeof(float));
std::memcpy(result, buffer.getBuffer(), position * sizeof(float));
*length = position;
return result;
}
static void pauseSound(AUD_Handle* handle)
{
assert(handle);
(*handle)->pause();
}
AUD_API AUD_Handle* AUD_pauseAfter(AUD_Handle* handle, float seconds)
{
std::shared_ptr<ISound> silence = std::shared_ptr<ISound>(new Silence);
std::shared_ptr<ISound> limiter = std::shared_ptr<ISound>(new Limiter(silence, 0, seconds));
auto device = DeviceManager::getDevice();
std::lock_guard<ILockable> lock(*device);
try
{
AUD_Handle handle2 = device->play(limiter);
if(handle2.get())
{
handle2->setStopCallback((stopCallback)pauseSound, handle);
return new AUD_Handle(handle2);
}
}
catch(Exception&)
{
}
return nullptr;
}
AUD_API int AUD_readSound(AUD_Sound* sound, float* buffer, int length, int samples_per_second, short* interrupt)
{
DeviceSpecs specs;
float* buf;
Buffer aBuffer;
specs.rate = RATE_INVALID;
specs.channels = CHANNELS_MONO;
specs.format = FORMAT_INVALID;
std::shared_ptr<IReader> reader = ChannelMapper(*sound, specs).createReader();
specs.specs = reader->getSpecs();
int len;
float samplejump = specs.rate / samples_per_second;
float min, max, power, overallmax;
bool eos;
overallmax = 0;
for(int i = 0; i < length; i++)
{
len = floor(samplejump * (i+1)) - floor(samplejump * i);
if(*interrupt)
return 0;
aBuffer.assureSize(len * AUD_SAMPLE_SIZE(specs));
buf = aBuffer.getBuffer();
reader->read(len, eos, buf);
max = min = *buf;
power = *buf * *buf;
for(int j = 1; j < len; j++)
{
if(buf[j] < min)
min = buf[j];
if(buf[j] > max)
max = buf[j];
power += buf[j] * buf[j];
}
buffer[i * 3] = min;
buffer[i * 3 + 1] = max;
buffer[i * 3 + 2] = sqrt(power) / len;
if(overallmax < max)
overallmax = max;
if(overallmax < -min)
overallmax = -min;
if(eos)
{
length = i;
break;
}
}
if(overallmax > 1.0f)
{
for(int i = 0; i < length * 3; i++)
{
buffer[i] /= overallmax;
}
}
return length;
}
AUD_API const char* AUD_mixdown(AUD_Sound* sound, unsigned int start, unsigned int length, unsigned int buffersize, const char* filename, AUD_DeviceSpecs specs, AUD_Container format, AUD_Codec codec, unsigned int bitrate)
{
try
{
Sequence* f = dynamic_cast<Sequence *>(sound->get());
f->setSpecs(convCToSpec(specs.specs));
std::shared_ptr<IReader> reader = f->createQualityReader();
reader->seek(start);
std::shared_ptr<IWriter> writer = FileWriter::createWriter(filename, convCToDSpec(specs), static_cast<Container>(format), static_cast<Codec>(codec), bitrate);
FileWriter::writeReader(reader, writer, length, buffersize);
return nullptr;
}
catch(Exception& e)
{
return e.getMessage().c_str();
}
}
AUD_API const char* AUD_mixdown_per_channel(AUD_Sound* sound, unsigned int start, unsigned int length, unsigned int buffersize, const char* filename, AUD_DeviceSpecs specs, AUD_Container format, AUD_Codec codec, unsigned int bitrate)
{
try
{
Sequence* f = dynamic_cast<Sequence *>(sound->get());
f->setSpecs(convCToSpec(specs.specs));
std::vector<std::shared_ptr<IWriter> > writers;
int channels = specs.channels;
specs.channels = AUD_CHANNELS_MONO;
for(int i = 0; i < channels; i++)
{
std::stringstream stream;
std::string fn = filename;
size_t index = fn.find_last_of('.');
size_t index_slash = fn.find_last_of('/');
size_t index_backslash = fn.find_last_of('\\');
if((index == std::string::npos) ||
((index < index_slash) && (index_slash != std::string::npos)) ||
((index < index_backslash) && (index_backslash != std::string::npos)))
{
stream << filename << "_" << (i + 1);
}
else
{
stream << fn.substr(0, index) << "_" << (i + 1) << fn.substr(index);
}
writers.push_back(FileWriter::createWriter(stream.str(), convCToDSpec(specs), static_cast<Container>(format), static_cast<Codec>(codec), bitrate));
}
std::shared_ptr<IReader> reader = f->createQualityReader();
reader->seek(start);
FileWriter::writeReader(reader, writers, length, buffersize);
return nullptr;
}
catch(Exception& e)
{
return e.getMessage().c_str();
}
}
AUD_API AUD_Device* AUD_openMixdownDevice(AUD_DeviceSpecs specs, AUD_Sound* sequencer, float volume, float start)
{
try
{
ReadDevice* device = new ReadDevice(convCToDSpec(specs));
device->setQuality(true);
device->setVolume(volume);
Sequence* f = dynamic_cast<Sequence*>(sequencer->get());
f->setSpecs(convCToSpec(specs.specs));
AUD_Handle handle = device->play(f->createQualityReader());
if(handle.get())
{
handle->seek(start);
}
return new AUD_Device(device);
}
catch(Exception&)
{
return nullptr;
}
}
AUD_API void AUD_initOnce()
{
PluginManager::loadPlugins();
NULLDevice::registerPlugin();
}
AUD_API void AUD_exitOnce()
{
}
AUD_API AUD_Device* AUD_init(const char* device, AUD_DeviceSpecs specs, int buffersize, const char* name)
{
try
{
std::shared_ptr<IDeviceFactory> factory = DeviceManager::getDeviceFactory(device);
if(factory)
{
factory->setName(name);
factory->setBufferSize(buffersize);
factory->setSpecs(convCToDSpec(specs));
auto device = factory->openDevice();
DeviceManager::setDevice(device);
return new AUD_Device(device);
}
}
catch(Exception&)
{
}
return nullptr;
}
AUD_API void AUD_exit(AUD_Device* device)
{
delete device;
DeviceManager::releaseDevice();
}
AUD_API char** AUD_getDeviceNames()
{
std::vector<std::string> v_names = DeviceManager::getAvailableDeviceNames();
char** names = (char**) malloc(sizeof(char*) * (v_names.size() + 1));
for(int i = 0; i < v_names.size(); i++)
{
std::string name = v_names[i];
names[i] = (char*) malloc(sizeof(char) * (name.length() + 1));
strcpy(names[i], name.c_str());
}
names[v_names.size()] = nullptr;
return names;
}

View File

@@ -0,0 +1,138 @@
/*******************************************************************************
* Copyright 2009-2016 Jörg Müller
*
* 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.
******************************************************************************/
#pragma once
#include "AUD_Types.h"
#ifdef __cplusplus
extern "C" {
#endif
/**
* Returns information about a sound.
* \param sound The sound to get the info about.
* \return The AUD_SoundInfo structure with filled in data.
*/
extern AUD_API AUD_SoundInfo AUD_getInfo(AUD_Sound* sound);
/**
* Reads a sound file into a newly created float buffer.
* The sound is therefore bandpassed, rectified and resampled.
*/
extern AUD_API float* AUD_readSoundBuffer(const char* filename, float low, float high,
float attack, float release, float threshold,
int accumulate, int additive, int square,
float sthreshold, double samplerate,
int* length);
/**
* Pauses a playing sound after a specific amount of time.
* \param handle The handle to the sound.
* \param seconds The time in seconds.
* \return The silence handle.
*/
extern AUD_API AUD_Handle* AUD_pauseAfter(AUD_Handle* handle, float seconds);
/**
* Reads a sound into a buffer for drawing at a specific sampling rate.
* \param sound The sound to read.
* \param buffer The buffer to write to. Must have a size of 3*4*length.
* \param length How many samples to read from the sound.
* \param samples_per_second How many samples to read per second of the sound.
* \return How many samples really have been read. Always <= length.
*/
extern AUD_API int AUD_readSound(AUD_Sound* sound, float* buffer, int length, int samples_per_second, short* interrupt);
/**
* Mixes a sound down into a file.
* \param sound The sound scene to mix down.
* \param start The start frame.
* \param length The count of frames to write.
* \param buffersize How many samples should be written at once.
* \param filename The file to write to.
* \param specs The file's audio specification.
* \param format The file's container format.
* \param codec The codec used for encoding the audio data.
* \param bitrate The bitrate for encoding.
* \return An error message or NULL in case of success.
*/
extern AUD_API const char* AUD_mixdown(AUD_Sound* sound, unsigned int start, unsigned int length,
unsigned int buffersize, const char* filename,
AUD_DeviceSpecs specs, AUD_Container format,
AUD_Codec codec, unsigned int bitrate);
/**
* Mixes a sound down into multiple files.
* \param sound The sound scene to mix down.
* \param start The start frame.
* \param length The count of frames to write.
* \param buffersize How many samples should be written at once.
* \param filename The file to write to, the channel number and an underscore are added at the beginning.
* \param specs The file's audio specification.
* \param format The file's container format.
* \param codec The codec used for encoding the audio data.
* \param bitrate The bitrate for encoding.
* \return An error message or NULL in case of success.
*/
extern AUD_API const char* AUD_mixdown_per_channel(AUD_Sound* sound, unsigned int start, unsigned int length,
unsigned int buffersize, const char* filename,
AUD_DeviceSpecs specs, AUD_Container format,
AUD_Codec codec, unsigned int bitrate);
/**
* Opens a read device and prepares it for mixdown of the sound scene.
* \param specs Output audio specifications.
* \param sequencer The sound scene to mix down.
* \param volume The overall mixdown volume.
* \param start The start time of the mixdown in the sound scene.
* \return The read device for the mixdown.
*/
extern AUD_API AUD_Device* AUD_openMixdownDevice(AUD_DeviceSpecs specs, AUD_Sound* sequencer, float volume, float start);
/**
* Initializes audio routines (FFMPEG/JACK if it is enabled).
*/
extern AUD_API void AUD_initOnce();
/**
* Unitinitializes an audio routines.
*/
extern AUD_API void AUD_exitOnce();
/**
* Initializes an audio device.
* \param device The device type that should be used.
* \param specs The audio specification to be used.
* \param buffersize The buffersize for the device.
* \return Whether the device has been initialized.
*/
extern AUD_API AUD_Device* AUD_init(const char* device, AUD_DeviceSpecs specs, int buffersize, const char* name);
/**
* Unitinitializes an audio device.
* \param device The device to free.
*/
extern AUD_API void AUD_exit(AUD_Device* device);
/**
* Retrieves available devices. Note that all memory returned has to be freed!
*/
extern AUD_API char** AUD_getDeviceNames();
#ifdef __cplusplus
}
#endif

View File

@@ -0,0 +1,42 @@
/*******************************************************************************
* Copyright 2009-2015 Juan Francisco Crespo Galán
*
* 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 "Exception.h"
#include <cassert>
using namespace aud;
#define AUD_CAPI_IMPLEMENTATION
#include "AUD_ThreadPool.h"
AUD_API AUD_ThreadPool* AUD_ThreadPool_create(int nThreads)
{
try
{
return new AUD_ThreadPool(new ThreadPool(nThreads));
}
catch(Exception&)
{
return nullptr;
}
}
AUD_API void AUD_ThreadPool_free(AUD_ThreadPool* pool)
{
assert(pool);
delete pool;
}

View File

@@ -0,0 +1,40 @@
/*******************************************************************************
* Copyright 2009-2015 Juan Francisco Crespo Galán
*
* 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.
******************************************************************************/
#pragma once
#include "AUD_Types.h"
#ifdef __cplusplus
extern "C" {
#endif
/**
* Creates a new ThreadPool object.
* \param nThreads The number of threads of the pool.
* \return The new ThreadPool object.
*/
extern AUD_API AUD_ThreadPool* AUD_ThreadPool_create(int nThreads);
/**
* Deletes a ThreadPool object.
* \param threadPool The ThreadPool object to be deleted.
*/
extern AUD_API void AUD_ThreadPool_free(AUD_ThreadPool* threadPool);
#ifdef __cplusplus
}
#endif

179
extern/audaspace/bindings/C/AUD_Types.h vendored Normal file
View File

@@ -0,0 +1,179 @@
/*******************************************************************************
* Copyright 2009-2016 Jörg Müller
*
* 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.
******************************************************************************/
#pragma once
#include "Audaspace.h"
#ifdef __cplusplus
using namespace aud;
#endif
#ifdef AUD_CAPI_IMPLEMENTATION
#include "ISound.h"
#include "devices/IHandle.h"
#include "devices/IDevice.h"
#include "sequence/SequenceEntry.h"
#include "fx/PlaybackManager.h"
#include "fx/DynamicMusic.h"
#include "fx/Source.h"
#include "util/ThreadPool.h"
#ifdef WITH_CONVOLUTION
#include "fx/ImpulseResponse.h"
#include "fx/HRTF.h"
#endif
typedef std::shared_ptr<aud::ISound> AUD_Sound;
typedef std::shared_ptr<aud::IHandle> AUD_Handle;
typedef std::shared_ptr<aud::IDevice> AUD_Device;
typedef std::shared_ptr<aud::SequenceEntry> AUD_SequenceEntry;
typedef std::shared_ptr<aud::PlaybackManager> AUD_PlaybackManager;
typedef std::shared_ptr<aud::DynamicMusic> AUD_DynamicMusic;
typedef std::shared_ptr<aud::ThreadPool> AUD_ThreadPool;
typedef std::shared_ptr<aud::Source> AUD_Source;
#ifdef WITH_CONVOLUTION
typedef std::shared_ptr<aud::ImpulseResponse> AUD_ImpulseResponse;
typedef std::shared_ptr<aud::HRTF> AUD_HRTF;
#endif
#else
typedef void AUD_Sound;
typedef void AUD_Handle;
typedef void AUD_Device;
typedef void AUD_SequenceEntry;
typedef void AUD_PlaybackManager;
typedef void AUD_DynamicMusic;
typedef void AUD_ThreadPool;
typedef void AUD_Source;
#ifdef WITH_CONVOLUTION
typedef void AUD_ImpulseResponse;
typedef void AUD_HRTF;
#endif
#endif
/// Container formats for writers.
typedef enum
{
AUD_CONTAINER_INVALID = 0,
AUD_CONTAINER_AC3,
AUD_CONTAINER_FLAC,
AUD_CONTAINER_MATROSKA,
AUD_CONTAINER_MP2,
AUD_CONTAINER_MP3,
AUD_CONTAINER_OGG,
AUD_CONTAINER_WAV
} AUD_Container;
/// Audio codecs for writers.
typedef enum
{
AUD_CODEC_INVALID = 0,
AUD_CODEC_AAC,
AUD_CODEC_AC3,
AUD_CODEC_FLAC,
AUD_CODEC_MP2,
AUD_CODEC_MP3,
AUD_CODEC_PCM,
AUD_CODEC_VORBIS,
AUD_CODEC_OPUS
} AUD_Codec;
/**
* The format of a sample.
* The last 4 bit save the byte count of the format.
*/
typedef enum
{
AUD_FORMAT_INVALID = 0x00, /// Invalid sample format.
AUD_FORMAT_U8 = 0x01, /// 1 byte unsigned byte.
AUD_FORMAT_S16 = 0x12, /// 2 byte signed integer.
AUD_FORMAT_S24 = 0x13, /// 3 byte signed integer.
AUD_FORMAT_S32 = 0x14, /// 4 byte signed integer.
AUD_FORMAT_FLOAT32 = 0x24, /// 4 byte float.
AUD_FORMAT_FLOAT64 = 0x28 /// 8 byte float.
} AUD_SampleFormat;
/// The channel count.
typedef enum
{
AUD_CHANNELS_INVALID = 0, /// Invalid channel count.
AUD_CHANNELS_MONO = 1, /// Mono.
AUD_CHANNELS_STEREO = 2, /// Stereo.
AUD_CHANNELS_STEREO_LFE = 3, /// Stereo with LFE channel.
AUD_CHANNELS_SURROUND4 = 4, /// 4 channel surround sound.
AUD_CHANNELS_SURROUND5 = 5, /// 5 channel surround sound.
AUD_CHANNELS_SURROUND51 = 6, /// 5.1 surround sound.
AUD_CHANNELS_SURROUND61 = 7, /// 6.1 surround sound.
AUD_CHANNELS_SURROUND71 = 8 /// 7.1 surround sound.
} AUD_Channels;
/**
* The sample rate tells how many samples are played back within one second.
* Some exotic formats may use other sample rates than provided here.
*/
typedef enum
{
AUD_RATE_INVALID = 0, /// Invalid sample rate.
AUD_RATE_8000 = 8000, /// 8000 Hz.
AUD_RATE_16000 = 16000, /// 16000 Hz.
AUD_RATE_11025 = 11025, /// 11025 Hz.
AUD_RATE_22050 = 22050, /// 22050 Hz.
AUD_RATE_32000 = 32000, /// 32000 Hz.
AUD_RATE_44100 = 44100, /// 44100 Hz.
AUD_RATE_48000 = 48000, /// 48000 Hz.
AUD_RATE_88200 = 88200, /// 88200 Hz.
AUD_RATE_96000 = 96000, /// 96000 Hz.
AUD_RATE_192000 = 192000 /// 192000 Hz.
} AUD_DefaultSampleRate;
/// Sample rate type.
typedef double AUD_SampleRate;
/// Specification of a sound source.
typedef struct
{
/// Sample rate in Hz.
AUD_SampleRate rate;
/// Channel count.
AUD_Channels channels;
} AUD_Specs;
/// Specification of a sound device.
typedef struct
{
/// Sample format.
AUD_SampleFormat format;
union
{
struct
{
/// Sample rate in Hz.
AUD_SampleRate rate;
/// Channel count.
AUD_Channels channels;
};
AUD_Specs specs;
};
} AUD_DeviceSpecs;
/// Sound information structure.
typedef struct
{
AUD_Specs specs;
float length;
} AUD_SoundInfo;

261
extern/audaspace/bindings/doc/conf.py.in vendored Normal file
View File

@@ -0,0 +1,261 @@
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
#
# audaspace documentation build configuration file, created by
# sphinx-quickstart on Tue Sep 9 01:48:48 2014.
#
# This file is execfile()d with the current directory set to its
# containing dir.
#
# Note that not all possible configuration values are present in this
# autogenerated file.
#
# All configuration values have a default; values that are commented out
# serve to show the default.
import sys
import os
# If extensions (or modules to document with autodoc) are in another directory,
# add these directories to sys.path here. If the directory is relative to the
# documentation root, use os.path.abspath to make it absolute, like shown here.
#sys.path.insert(0, os.path.abspath('.'))
# -- General configuration ------------------------------------------------
# If your documentation needs a minimal Sphinx version, state it here.
#needs_sphinx = '1.0'
# Add any Sphinx extension module names here, as strings. They can be
# extensions coming with Sphinx (named 'sphinx.ext.*') or your custom
# ones.
extensions = [
'sphinx.ext.autodoc',
]
# Add any paths that contain templates here, relative to this directory.
templates_path = []
# The suffix of source filenames.
source_suffix = '.rst'
# The encoding of source files.
#source_encoding = 'utf-8-sig'
# The master toctree document.
master_doc = 'index'
# General information about the project.
project = 'audaspace'
copyright = '2009-2015, Jörg Müller'
# The version info for the project you're documenting, acts as replacement for
# |version| and |release|, also used in various other places throughout the
# built documents.
#
# The short X.Y version.
version = '@AUDASPACE_VERSION@'
# The full version, including alpha/beta/rc tags.
release = '@AUDASPACE_LONG_VERSION@'
# The language for content autogenerated by Sphinx. Refer to documentation
# for a list of supported languages.
#language = None
# There are two options for replacing |today|: either, you set today to some
# non-false value, then it is used:
#today = ''
# Else, today_fmt is used as the format for a strftime call.
#today_fmt = '%B %d, %Y'
# List of patterns, relative to source directory, that match files and
# directories to ignore when looking for source files.
exclude_patterns = []
# The reST default role (used for this markup: `text`) to use for all
# documents.
#default_role = None
# If true, '()' will be appended to :func: etc. cross-reference text.
#add_function_parentheses = True
# If true, the current module name will be prepended to all description
# unit titles (such as .. function::).
#add_module_names = True
# If true, sectionauthor and moduleauthor directives will be shown in the
# output. They are ignored by default.
#show_authors = False
# The name of the Pygments (syntax highlighting) style to use.
pygments_style = 'sphinx'
# A list of ignored prefixes for module index sorting.
#modindex_common_prefix = []
# If true, keep warnings as "system message" paragraphs in the built documents.
#keep_warnings = False
# -- Options for HTML output ----------------------------------------------
# The theme to use for HTML and HTML Help pages. See the documentation for
# a list of builtin themes.
html_theme = 'alabaster'
# Theme options are theme-specific and customize the look and feel of a theme
# further. For a list of options available for each theme, see the
# documentation.
#html_theme_options = {}
# Add any paths that contain custom themes here, relative to this directory.
#html_theme_path = []
# The name for this set of Sphinx documents. If None, it defaults to
# "<project> v<release> documentation".
#html_title = None
# A shorter title for the navigation bar. Default is the same as html_title.
#html_short_title = None
# The name of an image file (relative to this directory) to place at the top
# of the sidebar.
#html_logo = None
# The name of an image file (within the static path) to use as favicon of the
# docs. This file should be a Windows icon file (.ico) being 16x16 or 32x32
# pixels large.
#html_favicon = None
# Add any paths that contain custom static files (such as style sheets) here,
# relative to this directory. They are copied after the builtin static files,
# so a file named "default.css" will overwrite the builtin "default.css".
html_static_path = []
# Add any extra paths that contain custom files (such as robots.txt or
# .htaccess) here, relative to this directory. These files are copied
# directly to the root of the documentation.
#html_extra_path = []
# If not '', a 'Last updated on:' timestamp is inserted at every page bottom,
# using the given strftime format.
#html_last_updated_fmt = '%b %d, %Y'
# If true, SmartyPants will be used to convert quotes and dashes to
# typographically correct entities.
#html_use_smartypants = True
# Custom sidebar templates, maps document names to template names.
#html_sidebars = {}
# Additional templates that should be rendered to pages, maps page names to
# template names.
#html_additional_pages = {}
# If false, no module index is generated.
#html_domain_indices = True
# If false, no index is generated.
#html_use_index = True
# If true, the index is split into individual pages for each letter.
#html_split_index = False
# If true, links to the reST sources are added to the pages.
#html_show_sourcelink = True
# If true, "Created using Sphinx" is shown in the HTML footer. Default is True.
#html_show_sphinx = True
# If true, "(C) Copyright ..." is shown in the HTML footer. Default is True.
#html_show_copyright = True
# If true, an OpenSearch description file will be output, and all pages will
# contain a <link> tag referring to it. The value of this option must be the
# base URL from which the finished HTML is served.
#html_use_opensearch = ''
# This is the file name suffix for HTML files (e.g. ".xhtml").
#html_file_suffix = None
# Output file base name for HTML help builder.
htmlhelp_basename = 'audaspacedoc'
# -- Options for LaTeX output ---------------------------------------------
latex_elements = {
# The paper size ('letterpaper' or 'a4paper').
#'papersize': 'letterpaper',
# The font size ('10pt', '11pt' or '12pt').
#'pointsize': '10pt',
# Additional stuff for the LaTeX preamble.
#'preamble': '',
}
# Grouping the document tree into LaTeX files. List of tuples
# (source start file, target name, title,
# author, documentclass [howto, manual, or own class]).
latex_documents = [
('index', 'audaspace.tex', 'audaspace Documentation',
'Jörg Müller', 'manual'),
]
# The name of an image file (relative to this directory) to place at the top of
# the title page.
#latex_logo = None
# For "manual" documents, if this is true, then toplevel headings are parts,
# not chapters.
#latex_use_parts = False
# If true, show page references after internal links.
#latex_show_pagerefs = False
# If true, show URL addresses after external links.
#latex_show_urls = False
# Documents to append as an appendix to all manuals.
#latex_appendices = []
# If false, no module index is generated.
#latex_domain_indices = True
# -- Options for manual page output ---------------------------------------
# One entry per manual page. List of tuples
# (source start file, name, description, authors, manual section).
man_pages = [
('index', 'audaspace', 'audaspace Documentation',
['Jörg Müller'], 1)
]
# If true, show URL addresses after external links.
#man_show_urls = False
# -- Options for Texinfo output -------------------------------------------
# Grouping the document tree into Texinfo files. List of tuples
# (source start file, target name, title, author,
# dir menu entry, description, category)
texinfo_documents = [
('index', 'audaspace', 'audaspace Documentation',
'Jörg Müller', 'audaspace', 'One line description of project.',
'Miscellaneous'),
]
# Documents to append as an appendix to all manuals.
#texinfo_appendices = []
# If false, no module index is generated.
#texinfo_domain_indices = True
# How to display URL addresses: 'footnote', 'no', or 'inline'.
#texinfo_show_urls = 'footnote'
# If true, do not generate a @detailmenu in the "Top" node's menu.
#texinfo_no_detailmenu = False

View File

@@ -0,0 +1,7 @@
Device
======
.. currentmodule:: aud
.. autoclass:: Device
:members:

View File

@@ -0,0 +1,7 @@
Handle
======
.. currentmodule:: aud
.. autoclass:: Handle
:members:

35
extern/audaspace/bindings/doc/index.rst vendored Normal file
View File

@@ -0,0 +1,35 @@
.. audaspace documentation master file, created by
sphinx-quickstart on Tue Sep 9 01:48:48 2014.
You can adapt this file completely to your liking, but it should at least
contain the root `toctree` directive.
Welcome to audaspace's documentation!
=====================================
.. automodule:: aud
This documentation is valid for both the Python and C bindings of audaspace. If you are looking for installation instructions check the `C++ API documentation <../index.html>`_. As C is not an object oriented language everything is accessible via functions where the first paramter is always the object. For methods these are named as ``AUD_ClassName_method()`` and properties are accessed via ``AUD_ClassName_property_get/set()``. Python users simply ``import aud`` to access the library.
.. toctree::
:maxdepth: 2
tutorials
Classes:
.. toctree::
:maxdepth: 2
device
sound
handle
sequence
sequence_entry
Indices and tables
==================
* :ref:`genindex`
* :ref:`modindex`
* :ref:`search`

View File

@@ -0,0 +1,7 @@
Sequence
========
.. currentmodule:: aud
.. autoclass:: Sequence
:members:

View File

@@ -0,0 +1,7 @@
Sequence Entry
==============
.. currentmodule:: aud
.. autoclass:: SequenceEntry
:members:

View File

@@ -0,0 +1,7 @@
Sound
=====
.. currentmodule:: aud
.. autoclass:: Sound
:members:

View File

@@ -0,0 +1,166 @@
Tutorials
=========
Introduction
------------
The C and Python binding for audaspace were designed with simplicity in mind. This means however that to use the full capabilities of audaspace, there is no way around the C++ library.
Simple Demo
-----------
The **simple.py** example program contains all the basic building blocks for an application using audaspace. These building blocks are basically the classes :class:`aud.Device`, :class:`aud.Sound` and :class:`aud.Handle`.
We start with importing :mod:`aud` and :mod:`time` as the modules we need for our simple example.
.. code-block:: python
#!/usr/bin/python
import aud, time
The first step now is to open an output device and this can simply be done by allocating a :class:`aud.Device` object.
.. code-block:: python
device = aud.Device()
To create a sound we can choose to load one from a :func:`aud.Sound.file`, or we use one of our signal generators. We decide to do the latter and create a :func:`aud.Sound.sine` signal with a frequency of 440 Hz.
.. code-block:: python
sine = aud.Sound.sine(440)
.. note:: At this point nothing is playing back yet, :class:`aud.Sound` objects are just descriptions of sounds.
However instead of a sine wave, we would like to have a square wave to produce a more retro gaming sound. We could of course use the :func:`aud.Sound.square` generator instead of sine, but we want to show how to apply effects, so we apply a :func:`aud.Sound.threshold` which makes a square wave out of our sine too, even if less efficient than directly generating the square wave.
.. code-block:: python
square = sine.threshold()
.. note:: The :class:`aud.Sound` class offers generator and effect functions.
The we can play our sound by calling the :func:`aud.Device.play` method of our device. This method returns a :class:`aud.Handle` which is used to control the playback of the sound.
.. code-block:: python
handle = device.play(square)
Now if we do nothing else anymore the application will quit immediately, so we won't hear much of our square wave, so we decide to wait for three seconds before quitting the application by calling :func:`time.sleep`.
.. code-block:: python
time.sleep(3)
Audioplayer
-----------
Now that we know the basics of audaspace, we can build our own music player easily by just slightly changing the previous program. The **player.py** example does exactly that, let's have a short look at the differences:
Instead of creating a sine signal and thresholding it, we in fact use the :func:`aud.Sound.file` function to load a sound from a file. The filename we pass is the first command line argument our application got.
.. code-block:: python
sound = aud.Sound.file(sys.argv[1])
When the sound gets played back we now want to wait until the whole file has been played, so we use the :data:`aud.Handle.status` property to determine whether the sound finished playing.
.. code-block:: python
while handle.status:
time.sleep(0.1)
We don't make any error checks if the user actually added a command line argument. As an exercise you could extend this program to play any number of command line supplied files in sequence.
Siren
-----
Let's get a little bit more complex. The **siren.py** example plays a generated siren sound that circles around your head. Depending on how many speakers you have and if the output device used supports the speaker setup, you will hear this effect. With stereo speakers you should at least hear some left-right-panning.
We start off again with importing the modules we need and we also define some properties of our siren sound. We want it to consist of two sine sounds with different frequencies. We define a length for the sine sounds and how long a fade in/out should take. We also know already how to open a device.
.. code-block:: python
#!/usr/bin/python
import aud, math, time
length = 0.5
fadelength = 0.05
device = aud.Device()
The next thing to do is to define our sine waves and apply all the required effects. As each of the effect functions returns the corresponding sound, we can easily chain those calls together.
.. code-block:: python
high = aud.Sound.sine(880).limit(0, length).fadein(0, fadelength).fadeout(length - fadelength, length)
low = aud.Sound.sine(700).limit(0, length).fadein(0, fadelength).fadeout(length - fadelength, length).volume(0.6)
The next step is to connect the two sines, which we do using the :func:`aud.Sound.join` function.
.. code-block:: python
sound = high.join(low)
The generated siren sound can now be played back and what we also do is to loop it. Therefore we set the :data:`aud.Handle.loop_count` to a negative value to loop forever.
.. code-block:: python
handle = device.play(sound)
handle.loop_count = -1
Now we use some timing code to make sure our demo runs for 10 seconds, but we also use the time to update the location of our playing sound, with the :data:`aud.Handle.location` property, which is a three dimensional vector. The trigonometic calculation based on the running time of the program keeps the sound on the XZ plane letting it follow a circle around us.
.. code-block:: python
start = time.time()
while time.time() - start < 10:
angle = time.time() - start
handle.location = [math.sin(angle), 0, -math.cos(angle)]
As an exercise you could try to let the sound come from the far left and go to the far right and a little bit in front of you within the 10 second runtime of the program. With this change you should be able to hear the volume of the sound change, depending on how far it is away from you. Updating the :data:`aud.Handle.velocity` property properly also enables the doppler effect. Compare your solution to the **siren2.py** demo.
Tetris
------
The **tetris.py** demo application shows an even more complex application which generates retro tetris music. Looking at the source code there should be nothing new here, again the functions used from audaspace are the same as in the previous examples. In the :func:`parseNote` function all single notes get joined which leads to a very long chain of sounds. If you think of :func:`aud.Sound.join` as a function that creates a binary tree with the two joined sounds as leaves then the :func:`parseNote` function creates a very unbalanced tree.
Insted we could rewrite the code to use two other classes: :class:`aud.Sequence` and :class:`aud.SequenceEntry` to sequence the notes. The **tetris2.py** application does exactly that. Before the while loop we add a variable that stores the current position in the score and create a new :class:`aud.Sequence` object.
.. code-block:: python
position = 0
sequence = aud.Sequence()
Then in the loop we can create the note simply by chaining the :func:`aud.Sound.square` generator and :func:`aud.Sound.fadein` and :func:`aud.Sound.fadeout` effects.
.. code-block:: python
note = aud.Sound.square(freq, rate).fadein(0, fadelength).fadeout(length - fadelength, fadelength)
Now instead of using :func:`aud.Sound.limit` and :func:`aud.Sound.join` we simply add the sound to the sequence.
.. code-block:: python
entry = sequence.add(note, position, position + length, 0)
The entry returned from the :func:`aud.Sequence.add` function is an object of the :class:`aud.SequenceEntry` class. We can use this entry to mute the note in case it's actually a pause.
.. code-block:: python
if char == 'p':
entry.muted = True
Lastly we have to update our position variable.
.. code-block:: python
position += length
Now in **tetris2.py** we used the :data:`aud.SequenceEntry.muted` property to show how the :class:`aud.SequenceEntry` class can be used, but it would actually be smarter to not even create a note for pauses and just skip them. You can try to implement this as an exercise and then check out the solution in **tetris3.py**.
Conclusion
----------
We introduced all five currently available classes in the audaspace Python API. Of course all classes offer a lot more functions than have been used in these demo applications, check out the specific class documentation for more details.

View File

@@ -0,0 +1,231 @@
/*******************************************************************************
* Copyright 2009-2016 Jörg Müller
*
* 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 "PyAPI.h"
#include "PySound.h"
#include "PyHandle.h"
#include "PyDevice.h"
#include "PySequenceEntry.h"
#include "PySequence.h"
#include "PyPlaybackManager.h"
#include "PyDynamicMusic.h"
#include "PyThreadPool.h"
#include "PySource.h"
#ifdef WITH_CONVOLUTION
#include "PyImpulseResponse.h"
#include "PyHRTF.h"
#endif
#include "respec/Specification.h"
#include "devices/IHandle.h"
#include "devices/I3DDevice.h"
#include "file/IWriter.h"
#include "plugin/PluginManager.h"
#include "sequence/AnimateableProperty.h"
#include "ISound.h"
#include <memory>
#include <structmember.h>
using namespace aud;
// ====================================================================
#define PY_MODULE_ADD_CONSTANT(module, name) PyModule_AddIntConstant(module, #name, name)
// ====================================================================
extern PyObject* AUDError;
PyObject* AUDError = nullptr;
// ====================================================================
PyDoc_STRVAR(M_aud_doc,
"Audaspace (pronounced \"outer space\") is a high level audio library.");
static struct PyModuleDef audmodule = {
PyModuleDef_HEAD_INIT,
"aud", /* name of module */
M_aud_doc, /* module documentation */
-1, /* size of per-interpreter state of the module,
or -1 if the module keeps state in global variables. */
nullptr, nullptr, nullptr, nullptr, nullptr
};
PyMODINIT_FUNC
PyInit_aud()
{
PyObject* module;
PluginManager::loadPlugins();
if(!initializeSound())
return nullptr;
if(!initializeDevice())
return nullptr;
if(!initializeHandle())
return nullptr;
if(!initializeSequenceEntry())
return nullptr;
if(!initializeSequence())
return nullptr;
if(!initializeDynamicMusic())
return nullptr;
if(!initializePlaybackManager())
return nullptr;
if(!initializeThreadPool())
return nullptr;
if(!initializeSource())
return nullptr;
#ifdef WITH_CONVOLUTION
if(!initializeImpulseResponse())
return nullptr;
if(!initializeHRTF())
return nullptr;
#endif
module = PyModule_Create(&audmodule);
if(module == nullptr)
return nullptr;
addSoundToModule(module);
addHandleToModule(module);
addDeviceToModule(module);
addSequenceEntryToModule(module);
addSequenceToModule(module);
addDynamicMusicToModule(module);
addPlaybackManagerToModule(module);
addThreadPoolToModule(module);
addSourceToModule(module);
#ifdef WITH_CONVOLUTION
addImpulseResponseToModule(module);
addHRTFToModule(module);
#endif
AUDError = PyErr_NewException("aud.error", nullptr, nullptr);
Py_INCREF(AUDError);
PyModule_AddObject(module, "error", AUDError);
// animatable property type constants
PY_MODULE_ADD_CONSTANT(module, AP_VOLUME);
PY_MODULE_ADD_CONSTANT(module, AP_PANNING);
PY_MODULE_ADD_CONSTANT(module, AP_PITCH);
PY_MODULE_ADD_CONSTANT(module, AP_LOCATION);
PY_MODULE_ADD_CONSTANT(module, AP_ORIENTATION);
// channels constants
PY_MODULE_ADD_CONSTANT(module, CHANNELS_INVALID);
PY_MODULE_ADD_CONSTANT(module, CHANNELS_MONO);
PY_MODULE_ADD_CONSTANT(module, CHANNELS_STEREO);
PY_MODULE_ADD_CONSTANT(module, CHANNELS_STEREO_LFE);
PY_MODULE_ADD_CONSTANT(module, CHANNELS_SURROUND4);
PY_MODULE_ADD_CONSTANT(module, CHANNELS_SURROUND5);
PY_MODULE_ADD_CONSTANT(module, CHANNELS_SURROUND51);
PY_MODULE_ADD_CONSTANT(module, CHANNELS_SURROUND61);
PY_MODULE_ADD_CONSTANT(module, CHANNELS_SURROUND71);
// codec constants
PY_MODULE_ADD_CONSTANT(module, CODEC_INVALID);
PY_MODULE_ADD_CONSTANT(module, CODEC_AAC);
PY_MODULE_ADD_CONSTANT(module, CODEC_AC3);
PY_MODULE_ADD_CONSTANT(module, CODEC_FLAC);
PY_MODULE_ADD_CONSTANT(module, CODEC_MP2);
PY_MODULE_ADD_CONSTANT(module, CODEC_MP3);
PY_MODULE_ADD_CONSTANT(module, CODEC_PCM);
PY_MODULE_ADD_CONSTANT(module, CODEC_VORBIS);
PY_MODULE_ADD_CONSTANT(module, CODEC_OPUS);
// container constants
PY_MODULE_ADD_CONSTANT(module, CONTAINER_INVALID);
PY_MODULE_ADD_CONSTANT(module, CONTAINER_AC3);
PY_MODULE_ADD_CONSTANT(module, CONTAINER_FLAC);
PY_MODULE_ADD_CONSTANT(module, CONTAINER_MATROSKA);
PY_MODULE_ADD_CONSTANT(module, CONTAINER_MP2);
PY_MODULE_ADD_CONSTANT(module, CONTAINER_MP3);
PY_MODULE_ADD_CONSTANT(module, CONTAINER_OGG);
PY_MODULE_ADD_CONSTANT(module, CONTAINER_WAV);
// distance model constants
PY_MODULE_ADD_CONSTANT(module, DISTANCE_MODEL_EXPONENT);
PY_MODULE_ADD_CONSTANT(module, DISTANCE_MODEL_EXPONENT_CLAMPED);
PY_MODULE_ADD_CONSTANT(module, DISTANCE_MODEL_INVERSE);
PY_MODULE_ADD_CONSTANT(module, DISTANCE_MODEL_INVERSE_CLAMPED);
PY_MODULE_ADD_CONSTANT(module, DISTANCE_MODEL_LINEAR);
PY_MODULE_ADD_CONSTANT(module, DISTANCE_MODEL_LINEAR_CLAMPED);
PY_MODULE_ADD_CONSTANT(module, DISTANCE_MODEL_INVALID);
// format constants
PY_MODULE_ADD_CONSTANT(module, FORMAT_INVALID);
PY_MODULE_ADD_CONSTANT(module, FORMAT_FLOAT32);
PY_MODULE_ADD_CONSTANT(module, FORMAT_FLOAT64);
PY_MODULE_ADD_CONSTANT(module, FORMAT_INVALID);
PY_MODULE_ADD_CONSTANT(module, FORMAT_S16);
PY_MODULE_ADD_CONSTANT(module, FORMAT_S24);
PY_MODULE_ADD_CONSTANT(module, FORMAT_S32);
PY_MODULE_ADD_CONSTANT(module, FORMAT_U8);
// rate constants
PY_MODULE_ADD_CONSTANT(module, RATE_INVALID);
PY_MODULE_ADD_CONSTANT(module, RATE_8000);
PY_MODULE_ADD_CONSTANT(module, RATE_16000);
PY_MODULE_ADD_CONSTANT(module, RATE_11025);
PY_MODULE_ADD_CONSTANT(module, RATE_22050);
PY_MODULE_ADD_CONSTANT(module, RATE_32000);
PY_MODULE_ADD_CONSTANT(module, RATE_44100);
PY_MODULE_ADD_CONSTANT(module, RATE_48000);
PY_MODULE_ADD_CONSTANT(module, RATE_88200);
PY_MODULE_ADD_CONSTANT(module, RATE_96000);
PY_MODULE_ADD_CONSTANT(module, RATE_192000);
// status constants
PY_MODULE_ADD_CONSTANT(module, STATUS_INVALID);
PY_MODULE_ADD_CONSTANT(module, STATUS_PAUSED);
PY_MODULE_ADD_CONSTANT(module, STATUS_PLAYING);
PY_MODULE_ADD_CONSTANT(module, STATUS_STOPPED);
return module;
}
AUD_API PyObject* AUD_getPythonSound(void* sound)
{
if(sound)
{
Sound* object = (Sound*) Sound_empty();
if(object)
{
object->sound = new std::shared_ptr<ISound>(*reinterpret_cast<std::shared_ptr<ISound>*>(sound));
return (PyObject *) object;
}
}
return nullptr;
}
AUD_API void* AUD_getSoundFromPython(PyObject* object)
{
Sound* sound = checkSound(object);
if(!sound)
return nullptr;
return new std::shared_ptr<ISound>(*reinterpret_cast<std::shared_ptr<ISound>*>(sound->sound));
}

View File

@@ -0,0 +1,45 @@
/*******************************************************************************
* Copyright 2009-2016 Jörg Müller
*
* 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.
******************************************************************************/
#pragma once
#include <Python.h>
#include "Audaspace.h"
#ifdef __cplusplus
extern "C" {
#endif
PyMODINIT_FUNC
PyInit_aud();
/**
* Retrieves the python factory of a sound.
* \param sound The sound factory.
* \return The python factory.
*/
extern AUD_API PyObject* AUD_getPythonSound(void* sound);
/**
* Retrieves the sound factory of a python factory.
* \param sound The python factory.
* \return The sound factory.
*/
extern AUD_API void* AUD_getSoundFromPython(PyObject* object);
#ifdef __cplusplus
}
#endif

View File

@@ -0,0 +1,785 @@
/*******************************************************************************
* Copyright 2009-2016 Jörg Müller
*
* 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 "PyDevice.h"
#include "PySound.h"
#include "PyHandle.h"
#include "Exception.h"
#include "devices/IDevice.h"
#include "devices/I3DDevice.h"
#include "devices/DeviceManager.h"
#include "devices/IDeviceFactory.h"
#include <structmember.h>
using namespace aud;
extern PyObject* AUDError;
static const char* device_not_3d_error = "Device is not a 3D device!";
// ====================================================================
static void
Device_dealloc(Device* self)
{
if(self->device)
delete reinterpret_cast<std::shared_ptr<IDevice>*>(self->device);
Py_TYPE(self)->tp_free((PyObject *)self);
}
static PyObject *
Device_new(PyTypeObject* type, PyObject* args, PyObject* kwds)
{
Device* self;
static const char* kwlist[] = {"type", "rate", "channels", "format", "buffer_size", "name", nullptr};
const char* device = nullptr;
double rate = RATE_48000;
int channels = CHANNELS_STEREO;
int format = FORMAT_FLOAT32;
int buffersize = AUD_DEFAULT_BUFFER_SIZE;
const char* name = "";
if(!PyArg_ParseTupleAndKeywords(args, kwds, "|sdiiis:Device", const_cast<char**>(kwlist),
&device, &rate, &channels, &format, &buffersize, &name))
return nullptr;
if(buffersize < 128)
{
PyErr_SetString(PyExc_ValueError, "buffer_size must be at least 128!");
return nullptr;
}
self = (Device*)type->tp_alloc(type, 0);
if(self != nullptr)
{
DeviceSpecs specs;
specs.channels = (Channels)channels;
specs.format = (SampleFormat)format;
specs.rate = (SampleRate)rate;
self->device = nullptr;
try
{
if(!device)
{
auto dev = DeviceManager::getDevice();
if(!dev)
{
DeviceManager::openDefaultDevice();
dev = DeviceManager::getDevice();
}
self->device = new std::shared_ptr<IDevice>(dev);
}
else
{
std::shared_ptr<IDeviceFactory> factory;
if(!*device)
factory = DeviceManager::getDefaultDeviceFactory();
else
factory = DeviceManager::getDeviceFactory(device);
if(factory)
{
factory->setName(name);
factory->setSpecs(specs);
factory->setBufferSize(buffersize);
self->device = new std::shared_ptr<IDevice>(factory->openDevice());
}
}
}
catch(Exception& e)
{
Py_DECREF(self);
PyErr_SetString(AUDError, e.what());
return nullptr;
}
if(!self->device)
{
Py_DECREF(self);
PyErr_SetString(AUDError, "Unsupported device type!");
return nullptr;
}
}
return (PyObject *)self;
}
PyDoc_STRVAR(M_aud_Device_lock_doc,
"lock()\n\n"
"Locks the device so that it's guaranteed, that no samples are "
"read from the streams until :meth:`unlock` is called.\n"
"This is useful if you want to do start/stop/pause/resume some "
"sounds at the same time.\n\n"
".. note:: The device has to be unlocked as often as locked to be "
"able to continue playback.\n\n"
".. warning:: Make sure the time between locking and unlocking is "
"as short as possible to avoid clicks.");
static PyObject *
Device_lock(Device* self)
{
try
{
(*reinterpret_cast<std::shared_ptr<IDevice>*>(self->device))->lock();
Py_RETURN_NONE;
}
catch(Exception& e)
{
PyErr_SetString(AUDError, e.what());
return nullptr;
}
}
PyDoc_STRVAR(M_aud_Device_play_doc,
"play(sound, keep=False)\n\n"
"Plays a sound.\n\n"
":arg sound: The sound to play.\n"
":type sound: :class:`Sound`\n"
":arg keep: See :attr:`Handle.keep`.\n"
":type keep: bool\n"
":return: The playback handle with which playback can be "
"controlled with.\n"
":rtype: :class:`Handle`");
static PyObject *
Device_play(Device* self, PyObject* args, PyObject* kwds)
{
PyObject* object;
PyObject* keepo = nullptr;
bool keep = false;
static const char* kwlist[] = {"sound", "keep", nullptr};
if(!PyArg_ParseTupleAndKeywords(args, kwds, "O|O:play", const_cast<char**>(kwlist), &object, &keepo))
return nullptr;
Sound* sound = checkSound(object);
if(!sound)
return nullptr;
if(keepo != nullptr)
{
if(!PyBool_Check(keepo))
{
PyErr_SetString(PyExc_TypeError, "keep is not a boolean!");
return nullptr;
}
keep = keepo == Py_True;
}
Handle* handle;
handle = (Handle*)Handle_empty();
if(handle != nullptr)
{
try
{
handle->handle = new std::shared_ptr<IHandle>((*reinterpret_cast<std::shared_ptr<IDevice>*>(self->device))->play(*reinterpret_cast<std::shared_ptr<ISound>*>(sound->sound), keep));
}
catch(Exception& e)
{
Py_DECREF(handle);
PyErr_SetString(AUDError, e.what());
return nullptr;
}
}
return (PyObject *)handle;
}
PyDoc_STRVAR(M_aud_Device_stopAll_doc,
"stopAll()\n\n"
"Stops all playing and paused sounds.");
static PyObject *
Device_stopAll(Device* self)
{
try
{
(*reinterpret_cast<std::shared_ptr<IDevice>*>(self->device))->stopAll();
Py_RETURN_NONE;
}
catch(Exception& e)
{
PyErr_SetString(AUDError, e.what());
return nullptr;
}
}
PyDoc_STRVAR(M_aud_Device_unlock_doc,
"unlock()\n\n"
"Unlocks the device after a lock call, see :meth:`lock` for "
"details.");
static PyObject *
Device_unlock(Device* self)
{
try
{
(*reinterpret_cast<std::shared_ptr<IDevice>*>(self->device))->unlock();
Py_RETURN_NONE;
}
catch(Exception& e)
{
PyErr_SetString(AUDError, e.what());
return nullptr;
}
}
static PyMethodDef Device_methods[] = {
{"lock", (PyCFunction)Device_lock, METH_NOARGS,
M_aud_Device_lock_doc
},
{"play", (PyCFunction)Device_play, METH_VARARGS | METH_KEYWORDS,
M_aud_Device_play_doc
},
{"stopAll", (PyCFunction)Device_stopAll, METH_NOARGS,
M_aud_Device_stopAll_doc
},
{"unlock", (PyCFunction)Device_unlock, METH_NOARGS,
M_aud_Device_unlock_doc
},
{nullptr} /* Sentinel */
};
PyDoc_STRVAR(M_aud_Device_channels_doc,
"The channel count of the device.");
static PyObject *
Device_get_channels(Device* self, void* nothing)
{
try
{
DeviceSpecs specs = (*reinterpret_cast<std::shared_ptr<IDevice>*>(self->device))->getSpecs();
return Py_BuildValue("i", specs.channels);
}
catch(Exception& e)
{
PyErr_SetString(AUDError, e.what());
return nullptr;
}
}
PyDoc_STRVAR(M_aud_Device_distance_model_doc,
"The distance model of the device.\n\n"
".. seealso:: http://connect.creativelabs.com/openal/Documentation/OpenAL%201.1%20Specification.htm#_Toc199835864");
static PyObject *
Device_get_distance_model(Device* self, void* nothing)
{
try
{
I3DDevice* device = dynamic_cast<I3DDevice*>(reinterpret_cast<std::shared_ptr<IDevice>*>(self->device)->get());
if(device)
{
return Py_BuildValue("i", int(device->getDistanceModel()));
}
else
{
PyErr_SetString(AUDError, device_not_3d_error);
return nullptr;
}
}
catch(Exception& e)
{
PyErr_SetString(AUDError, e.what());
return nullptr;
}
}
static int
Device_set_distance_model(Device* self, PyObject* args, void* nothing)
{
int model;
if(!PyArg_Parse(args, "i:distance_model", &model))
return -1;
try
{
I3DDevice* device = dynamic_cast<I3DDevice*>(reinterpret_cast<std::shared_ptr<IDevice>*>(self->device)->get());
if(device)
{
device->setDistanceModel(DistanceModel(model));
return 0;
}
else
PyErr_SetString(AUDError, device_not_3d_error);
}
catch(Exception& e)
{
PyErr_SetString(AUDError, e.what());
}
return -1;
}
PyDoc_STRVAR(M_aud_Device_doppler_factor_doc,
"The doppler factor of the device.\n"
"This factor is a scaling factor for the velocity vectors in "
"doppler calculation. So a value bigger than 1 will exaggerate "
"the effect as it raises the velocity.");
static PyObject *
Device_get_doppler_factor(Device* self, void* nothing)
{
try
{
I3DDevice* device = dynamic_cast<I3DDevice*>(reinterpret_cast<std::shared_ptr<IDevice>*>(self->device)->get());
if(device)
{
return Py_BuildValue("f", device->getDopplerFactor());
}
else
{
PyErr_SetString(AUDError, device_not_3d_error);
return nullptr;
}
}
catch(Exception& e)
{
PyErr_SetString(AUDError, e.what());
return nullptr;
}
}
static int
Device_set_doppler_factor(Device* self, PyObject* args, void* nothing)
{
float factor;
if(!PyArg_Parse(args, "f:doppler_factor", &factor))
return -1;
try
{
I3DDevice* device = dynamic_cast<I3DDevice*>(reinterpret_cast<std::shared_ptr<IDevice>*>(self->device)->get());
if(device)
{
device->setDopplerFactor(factor);
return 0;
}
else
PyErr_SetString(AUDError, device_not_3d_error);
}
catch(Exception& e)
{
PyErr_SetString(AUDError, e.what());
}
return -1;
}
PyDoc_STRVAR(M_aud_Device_format_doc,
"The native sample format of the device.");
static PyObject *
Device_get_format(Device* self, void* nothing)
{
try
{
DeviceSpecs specs = (*reinterpret_cast<std::shared_ptr<IDevice>*>(self->device))->getSpecs();
return Py_BuildValue("i", specs.format);
}
catch(Exception& e)
{
PyErr_SetString(AUDError, e.what());
return nullptr;
}
}
PyDoc_STRVAR(M_aud_Device_listener_location_doc,
"The listeners's location in 3D space, a 3D tuple of floats.");
static PyObject *
Device_get_listener_location(Device* self, void* nothing)
{
try
{
I3DDevice* device = dynamic_cast<I3DDevice*>(reinterpret_cast<std::shared_ptr<IDevice>*>(self->device)->get());
if(device)
{
Vector3 v = device->getListenerLocation();
return Py_BuildValue("(fff)", v.x(), v.y(), v.z());
}
else
{
PyErr_SetString(AUDError, device_not_3d_error);
}
}
catch(Exception& e)
{
PyErr_SetString(AUDError, e.what());
}
return nullptr;
}
static int
Device_set_listener_location(Device* self, PyObject* args, void* nothing)
{
float x, y, z;
if(!PyArg_Parse(args, "(fff):listener_location", &x, &y, &z))
return -1;
try
{
I3DDevice* device = dynamic_cast<I3DDevice*>(reinterpret_cast<std::shared_ptr<IDevice>*>(self->device)->get());
if(device)
{
Vector3 location(x, y, z);
device->setListenerLocation(location);
return 0;
}
else
PyErr_SetString(AUDError, device_not_3d_error);
}
catch(Exception& e)
{
PyErr_SetString(AUDError, e.what());
}
return -1;
}
PyDoc_STRVAR(M_aud_Device_listener_orientation_doc,
"The listener's orientation in 3D space as quaternion, a 4 float tuple.");
static PyObject *
Device_get_listener_orientation(Device* self, void* nothing)
{
try
{
I3DDevice* device = dynamic_cast<I3DDevice*>(reinterpret_cast<std::shared_ptr<IDevice>*>(self->device)->get());
if(device)
{
Quaternion o = device->getListenerOrientation();
return Py_BuildValue("(ffff)", o.w(), o.x(), o.y(), o.z());
}
else
{
PyErr_SetString(AUDError, device_not_3d_error);
}
}
catch(Exception& e)
{
PyErr_SetString(AUDError, e.what());
}
return nullptr;
}
static int
Device_set_listener_orientation(Device* self, PyObject* args, void* nothing)
{
float w, x, y, z;
if(!PyArg_Parse(args, "(ffff):listener_orientation", &w, &x, &y, &z))
return -1;
try
{
I3DDevice* device = dynamic_cast<I3DDevice*>(reinterpret_cast<std::shared_ptr<IDevice>*>(self->device)->get());
if(device)
{
Quaternion orientation(w, x, y, z);
device->setListenerOrientation(orientation);
return 0;
}
else
PyErr_SetString(AUDError, device_not_3d_error);
}
catch(Exception& e)
{
PyErr_SetString(AUDError, e.what());
}
return -1;
}
PyDoc_STRVAR(M_aud_Device_listener_velocity_doc,
"The listener's velocity in 3D space, a 3D tuple of floats.");
static PyObject *
Device_get_listener_velocity(Device* self, void* nothing)
{
try
{
I3DDevice* device = dynamic_cast<I3DDevice*>(reinterpret_cast<std::shared_ptr<IDevice>*>(self->device)->get());
if(device)
{
Vector3 v = device->getListenerVelocity();
return Py_BuildValue("(fff)", v.x(), v.y(), v.z());
}
else
{
PyErr_SetString(AUDError, device_not_3d_error);
}
}
catch(Exception& e)
{
PyErr_SetString(AUDError, e.what());
}
return nullptr;
}
static int
Device_set_listener_velocity(Device* self, PyObject* args, void* nothing)
{
float x, y, z;
if(!PyArg_Parse(args, "(fff):listener_velocity", &x, &y, &z))
return -1;
try
{
I3DDevice* device = dynamic_cast<I3DDevice*>(reinterpret_cast<std::shared_ptr<IDevice>*>(self->device)->get());
if(device)
{
Vector3 velocity(x, y, z);
device->setListenerVelocity(velocity);
return 0;
}
else
PyErr_SetString(AUDError, device_not_3d_error);
}
catch(Exception& e)
{
PyErr_SetString(AUDError, e.what());
}
return -1;
}
PyDoc_STRVAR(M_aud_Device_rate_doc,
"The sampling rate of the device in Hz.");
static PyObject *
Device_get_rate(Device* self, void* nothing)
{
try
{
DeviceSpecs specs = (*reinterpret_cast<std::shared_ptr<IDevice>*>(self->device))->getSpecs();
return Py_BuildValue("d", specs.rate);
}
catch(Exception& e)
{
PyErr_SetString(AUDError, e.what());
return nullptr;
}
}
PyDoc_STRVAR(M_aud_Device_speed_of_sound_doc,
"The speed of sound of the device.\n"
"The speed of sound in air is typically 343.3 m/s.");
static PyObject *
Device_get_speed_of_sound(Device* self, void* nothing)
{
try
{
I3DDevice* device = dynamic_cast<I3DDevice*>(reinterpret_cast<std::shared_ptr<IDevice>*>(self->device)->get());
if(device)
{
return Py_BuildValue("f", device->getSpeedOfSound());
}
else
{
PyErr_SetString(AUDError, device_not_3d_error);
return nullptr;
}
}
catch(Exception& e)
{
PyErr_SetString(AUDError, e.what());
return nullptr;
}
}
static int
Device_set_speed_of_sound(Device* self, PyObject* args, void* nothing)
{
float speed;
if(!PyArg_Parse(args, "f:speed_of_sound", &speed))
return -1;
try
{
I3DDevice* device = dynamic_cast<I3DDevice*>(reinterpret_cast<std::shared_ptr<IDevice>*>(self->device)->get());
if(device)
{
device->setSpeedOfSound(speed);
return 0;
}
else
PyErr_SetString(AUDError, device_not_3d_error);
}
catch(Exception& e)
{
PyErr_SetString(AUDError, e.what());
}
return -1;
}
PyDoc_STRVAR(M_aud_Device_volume_doc,
"The overall volume of the device.");
static PyObject *
Device_get_volume(Device* self, void* nothing)
{
try
{
return Py_BuildValue("f", (*reinterpret_cast<std::shared_ptr<IDevice>*>(self->device))->getVolume());
}
catch(Exception& e)
{
PyErr_SetString(AUDError, e.what());
return nullptr;
}
}
static int
Device_set_volume(Device* self, PyObject* args, void* nothing)
{
float volume;
if(!PyArg_Parse(args, "f:volume", &volume))
return -1;
try
{
(*reinterpret_cast<std::shared_ptr<IDevice>*>(self->device))->setVolume(volume);
return 0;
}
catch(Exception& e)
{
PyErr_SetString(AUDError, e.what());
return -1;
}
}
static PyGetSetDef Device_properties[] = {
{(char*)"channels", (getter)Device_get_channels, nullptr,
M_aud_Device_channels_doc, nullptr },
{(char*)"distance_model", (getter)Device_get_distance_model, (setter)Device_set_distance_model,
M_aud_Device_distance_model_doc, nullptr },
{(char*)"doppler_factor", (getter)Device_get_doppler_factor, (setter)Device_set_doppler_factor,
M_aud_Device_doppler_factor_doc, nullptr },
{(char*)"format", (getter)Device_get_format, nullptr,
M_aud_Device_format_doc, nullptr },
{(char*)"listener_location", (getter)Device_get_listener_location, (setter)Device_set_listener_location,
M_aud_Device_listener_location_doc, nullptr },
{(char*)"listener_orientation", (getter)Device_get_listener_orientation, (setter)Device_set_listener_orientation,
M_aud_Device_listener_orientation_doc, nullptr },
{(char*)"listener_velocity", (getter)Device_get_listener_velocity, (setter)Device_set_listener_velocity,
M_aud_Device_listener_velocity_doc, nullptr },
{(char*)"rate", (getter)Device_get_rate, nullptr,
M_aud_Device_rate_doc, nullptr },
{(char*)"speed_of_sound", (getter)Device_get_speed_of_sound, (setter)Device_set_speed_of_sound,
M_aud_Device_speed_of_sound_doc, nullptr },
{(char*)"volume", (getter)Device_get_volume, (setter)Device_set_volume,
M_aud_Device_volume_doc, nullptr },
{nullptr} /* Sentinel */
};
PyDoc_STRVAR(M_aud_Device_doc,
"Device objects represent an audio output backend like OpenAL or "
"SDL, but might also represent a file output or RAM buffer "
"output.");
static PyTypeObject DeviceType = {
PyVarObject_HEAD_INIT(nullptr, 0)
"aud.Device", /* tp_name */
sizeof(Device), /* tp_basicsize */
0, /* tp_itemsize */
(destructor)Device_dealloc,/* tp_dealloc */
0, /* tp_print */
0, /* tp_getattr */
0, /* tp_setattr */
0, /* tp_reserved */
0, /* tp_repr */
0, /* tp_as_number */
0, /* tp_as_sequence */
0, /* tp_as_mapping */
0, /* tp_hash */
0, /* tp_call */
0, /* tp_str */
0, /* tp_getattro */
0, /* tp_setattro */
0, /* tp_as_buffer */
Py_TPFLAGS_DEFAULT, /* tp_flags */
M_aud_Device_doc, /* tp_doc */
0, /* tp_traverse */
0, /* tp_clear */
0, /* tp_richcompare */
0, /* tp_weaklistoffset */
0, /* tp_iter */
0, /* tp_iternext */
Device_methods, /* tp_methods */
0, /* tp_members */
Device_properties, /* tp_getset */
0, /* tp_base */
0, /* tp_dict */
0, /* tp_descr_get */
0, /* tp_descr_set */
0, /* tp_dictoffset */
0, /* tp_init */
0, /* tp_alloc */
Device_new, /* tp_new */
};
AUD_API PyObject* Device_empty()
{
return DeviceType.tp_alloc(&DeviceType, 0);
}
AUD_API Device* checkDevice(PyObject* device)
{
if(!PyObject_TypeCheck(device, &DeviceType))
{
PyErr_SetString(PyExc_TypeError, "Object is not of type Device!");
return nullptr;
}
return (Device*)device;
}
bool initializeDevice()
{
return PyType_Ready(&DeviceType) >= 0;
}
void addDeviceToModule(PyObject* module)
{
Py_INCREF(&DeviceType);
PyModule_AddObject(module, "Device", (PyObject *)&DeviceType);
}

View File

@@ -0,0 +1,33 @@
/*******************************************************************************
* Copyright 2009-2016 Jörg Müller
*
* 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.
******************************************************************************/
#pragma once
#include <Python.h>
#include "Audaspace.h"
typedef void Reference_IDevice;
typedef struct {
PyObject_HEAD
Reference_IDevice* device;
} Device;
extern AUD_API PyObject* Device_empty();
extern AUD_API Device* checkDevice(PyObject* device);
bool initializeDevice();
void addDeviceToModule(PyObject* module);

View File

@@ -0,0 +1,467 @@
/*******************************************************************************
* Copyright 2015-2016 Juan Francisco Crespo Galán
*
* 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 "PyDynamicMusic.h"
#include "PySound.h"
#include "PyHandle.h"
#include "PyDevice.h"
#include "Exception.h"
#include "fx/DynamicMusic.h"
extern PyObject* AUDError;
static PyObject *
DynamicMusic_new(PyTypeObject* type, PyObject* args, PyObject* kwds)
{
DynamicMusicP* self = (DynamicMusicP*)type->tp_alloc(type, 0);
if(self != nullptr)
{
PyObject* object;
if(!PyArg_ParseTuple(args, "O:device", &object))
return nullptr;
Device* device = checkDevice(object);
try
{
self->dynamicMusic = new std::shared_ptr<aud::DynamicMusic>(new aud::DynamicMusic(*reinterpret_cast<std::shared_ptr<aud::IDevice>*>(device->device)));
}
catch(aud::Exception& e)
{
Py_DECREF(self);
PyErr_SetString(AUDError, e.what());
return nullptr;
}
}
return (PyObject *)self;
}
static void
DynamicMusic_dealloc(DynamicMusicP* self)
{
if(self->dynamicMusic)
delete reinterpret_cast<std::shared_ptr<aud::DynamicMusic>*>(self->dynamicMusic);
Py_TYPE(self)->tp_free((PyObject *)self);
}
PyDoc_STRVAR(M_aud_DynamicMusic_addScene_doc,
"addScene(scene)\n\n"
"Adds a new scene.\n\n"
":arg scene: The scene sound.\n"
":type scene: :class:`Sound`\n"
":return: The new scene id.\n"
":rtype: int");
static PyObject *
DynamicMusic_addScene(DynamicMusicP* self, PyObject* args)
{
PyObject* object;
if(!PyArg_Parse(args, "O:sound", &object))
return nullptr;
Sound* sound = checkSound(object);
if(!sound)
return nullptr;
try
{
return Py_BuildValue("i", (*reinterpret_cast<std::shared_ptr<aud::DynamicMusic>*>(self->dynamicMusic))->addScene(*reinterpret_cast<std::shared_ptr<aud::ISound>*>(sound->sound)));
}
catch(aud::Exception& e)
{
PyErr_SetString(AUDError, e.what());
return nullptr;
}
}
PyDoc_STRVAR(M_aud_DynamicMusic_addTransition_doc,
"addTransition(ini, end, transition)\n\n"
"Adds a new scene.\n\n"
":arg ini: the initial scene foor the transition.\n"
":type ini: int\n"
":arg end: The final scene for the transition.\n"
":type end: int\n"
":arg transition: The transition sound.\n"
":type transition: :class:`Sound`\n"
":return: false if the ini or end scenes don't exist, true othrwise.\n"
":rtype: bool");
static PyObject *
DynamicMusic_addTransition(DynamicMusicP* self, PyObject* args)
{
PyObject* object;
int ini, end;
if(!PyArg_ParseTuple(args, "iiO:sound", &ini, &end, &object))
return nullptr;
Sound* sound = checkSound(object);
if(!sound)
return nullptr;
try
{
(*reinterpret_cast<std::shared_ptr<aud::DynamicMusic>*>(self->dynamicMusic))->addTransition(ini, end, *reinterpret_cast<std::shared_ptr<aud::ISound>*>(sound->sound));
Py_RETURN_NONE;
}
catch(aud::Exception& e)
{
PyErr_SetString(AUDError, e.what());
return nullptr;
}
}
PyDoc_STRVAR(M_aud_DynamicMusic_resume_doc,
"resume()\n\n"
"Resumes playback of the scene.\n\n"
":return: Whether the action succeeded.\n"
":rtype: bool");
static PyObject *
DynamicMusic_resume(DynamicMusicP* self)
{
try
{
return PyBool_FromLong((long)(*reinterpret_cast<std::shared_ptr<aud::DynamicMusic>*>(self->dynamicMusic))->resume());
}
catch(aud::Exception& e)
{
PyErr_SetString(AUDError, e.what());
return nullptr;
}
}
PyDoc_STRVAR(M_aud_DynamicMusic_pause_doc,
"pause()\n\n"
"Pauses playback of the scene.\n\n"
":return: Whether the action succeeded.\n"
":rtype: bool");
static PyObject *
DynamicMusic_pause(DynamicMusicP* self)
{
try
{
return PyBool_FromLong((long)(*reinterpret_cast<std::shared_ptr<aud::DynamicMusic>*>(self->dynamicMusic))->pause());
}
catch(aud::Exception& e)
{
PyErr_SetString(AUDError, e.what());
return nullptr;
}
}
PyDoc_STRVAR(M_aud_DynamicMusic_stop_doc,
"stop()\n\n"
"Stops playback of the scene.\n\n"
":return: Whether the action succeeded.\n"
":rtype: bool\n\n");
static PyObject *
DynamicMusic_stop(DynamicMusicP* self)
{
try
{
return PyBool_FromLong((long)(*reinterpret_cast<std::shared_ptr<aud::DynamicMusic>*>(self->dynamicMusic))->stop());
}
catch(aud::Exception& e)
{
PyErr_SetString(AUDError, e.what());
return nullptr;
}
}
static PyMethodDef DynamicMusic_methods[] = {
{ "addScene", (PyCFunction)DynamicMusic_addScene, METH_O,
M_aud_DynamicMusic_addScene_doc
},
{ "addTransition", (PyCFunction)DynamicMusic_addTransition, METH_VARARGS,
M_aud_DynamicMusic_addTransition_doc
},
{ "resume", (PyCFunction)DynamicMusic_resume, METH_NOARGS,
M_aud_DynamicMusic_resume_doc
},
{ "pause", (PyCFunction)DynamicMusic_pause, METH_NOARGS,
M_aud_DynamicMusic_pause_doc
},
{ "stop", (PyCFunction)DynamicMusic_stop, METH_NOARGS,
M_aud_DynamicMusic_stop_doc
},
{ nullptr } /* Sentinel */
};
/////////////////////////////////////////////////////
PyDoc_STRVAR(M_aud_DynamicMusic_status_doc,
"Whether the scene is playing, paused or stopped (=invalid).");
static PyObject *
DynamicMusic_get_status(DynamicMusicP* self, void* nothing)
{
try
{
return PyBool_FromLong((long)(*reinterpret_cast<std::shared_ptr<aud::DynamicMusic>*>(self->dynamicMusic))->getStatus());
}
catch(aud::Exception& e)
{
PyErr_SetString(AUDError, e.what());
return nullptr;
}
}
PyDoc_STRVAR(M_aud_DynamicMusic_position_doc,
"The playback position of the scene in seconds.");
static int
DynamicMusic_set_position(DynamicMusicP* self, PyObject* args, void* nothing)
{
float position;
if(!PyArg_Parse(args, "f:position", &position))
return -1;
try
{
if((*reinterpret_cast<std::shared_ptr<aud::DynamicMusic>*>(self->dynamicMusic))->seek(position))
return 0;
PyErr_SetString(AUDError, "Couldn't seek the sound!");
}
catch(aud::Exception& e)
{
PyErr_SetString(AUDError, e.what());
}
return -1;
}
static PyObject *
DynamicMusic_get_position(DynamicMusicP* self, void* nothing)
{
try
{
return Py_BuildValue("f", (*reinterpret_cast<std::shared_ptr<aud::DynamicMusic>*>(self->dynamicMusic))->getPosition());
}
catch(aud::Exception& e)
{
PyErr_SetString(AUDError, e.what());
return nullptr;
}
}
PyDoc_STRVAR(M_aud_DynamicMusic_fadeTime_doc,
"The length in seconds of the crossfade transition");
static int
DynamicMusic_set_fadeTime(DynamicMusicP* self, PyObject* args, void* nothing)
{
float fadeTime;
if(!PyArg_Parse(args, "f:fadeTime", &fadeTime))
return -1;
try
{
(*reinterpret_cast<std::shared_ptr<aud::DynamicMusic>*>(self->dynamicMusic))->setFadeTime(fadeTime);
return 0;
}
catch(aud::Exception& e)
{
PyErr_SetString(AUDError, e.what());
}
return -1;
}
static PyObject *
DynamicMusic_get_fadeTime(DynamicMusicP* self, void* nothing)
{
try
{
return Py_BuildValue("f", (*reinterpret_cast<std::shared_ptr<aud::DynamicMusic>*>(self->dynamicMusic))->getFadeTime());
}
catch(aud::Exception& e)
{
PyErr_SetString(AUDError, e.what());
return nullptr;
}
}
PyDoc_STRVAR(M_aud_DynamicMusic_scene_doc,
"The current scene");
static int
DynamicMusic_set_scene(DynamicMusicP* self, PyObject* args, void* nothing)
{
int scene;
if(!PyArg_Parse(args, "i:scene", &scene))
return -1;
try
{
if((*reinterpret_cast<std::shared_ptr<aud::DynamicMusic>*>(self->dynamicMusic))->changeScene(scene))
return 0;
PyErr_SetString(AUDError, "Couldn't change the scene!");
}
catch(aud::Exception& e)
{
PyErr_SetString(AUDError, e.what());
}
return -1;
}
static PyObject *
DynamicMusic_get_scene(DynamicMusicP* self, void* nothing)
{
try
{
return Py_BuildValue("i", (*reinterpret_cast<std::shared_ptr<aud::DynamicMusic>*>(self->dynamicMusic))->getScene());
}
catch(aud::Exception& e)
{
PyErr_SetString(AUDError, e.what());
return nullptr;
}
}
PyDoc_STRVAR(M_aud_DynamicMusic_volume_doc,
"The volume of the scene.");
static int
DynamicMusic_set_volume(DynamicMusicP* self, PyObject* args, void* nothing)
{
float volume;
if(!PyArg_Parse(args, "f:volume", &volume))
return -1;
try
{
if((*reinterpret_cast<std::shared_ptr<aud::DynamicMusic>*>(self->dynamicMusic))->setVolume(volume))
return 0;
PyErr_SetString(AUDError, "Couldn't change the volume!");
}
catch(aud::Exception& e)
{
PyErr_SetString(AUDError, e.what());
}
return -1;
}
static PyObject *
DynamicMusic_get_volume(DynamicMusicP* self, void* nothing)
{
try
{
return Py_BuildValue("f", (*reinterpret_cast<std::shared_ptr<aud::DynamicMusic>*>(self->dynamicMusic))->getVolume());
}
catch(aud::Exception& e)
{
PyErr_SetString(AUDError, e.what());
return nullptr;
}
}
static PyGetSetDef DynamicMusic_properties[] = {
{ (char*)"status", (getter)DynamicMusic_get_status, nullptr,
M_aud_DynamicMusic_status_doc, nullptr },
{ (char*)"position", (getter)DynamicMusic_get_position, (setter)DynamicMusic_set_position,
M_aud_DynamicMusic_position_doc, nullptr },
{ (char*)"fadeTime", (getter)DynamicMusic_get_fadeTime, (setter)DynamicMusic_set_fadeTime,
M_aud_DynamicMusic_fadeTime_doc, nullptr },
{ (char*)"scene", (getter)DynamicMusic_get_scene, (setter)DynamicMusic_set_scene,
M_aud_DynamicMusic_scene_doc, nullptr },
{ (char*)"volume", (getter)DynamicMusic_get_volume, (setter)DynamicMusic_set_volume,
M_aud_DynamicMusic_volume_doc, nullptr },
{ nullptr } /* Sentinel */
};
PyDoc_STRVAR(M_aud_DynamicMusic_doc,
"The DynamicMusic object allows to play music depending on a current scene, scene changes are managed by the class, with the possibility of custom transitions.\n"
"The default transition is a crossfade effect, and the default scene is silent and has id 0");
PyTypeObject DynamicMusicType = {
PyVarObject_HEAD_INIT(nullptr, 0)
"aud.DynamicMusic", /* tp_name */
sizeof(DynamicMusicP), /* tp_basicsize */
0, /* tp_itemsize */
(destructor)DynamicMusic_dealloc, /* tp_dealloc */
0, /* tp_print */
0, /* tp_getattr */
0, /* tp_setattr */
0, /* tp_reserved */
0, /* tp_repr */
0, /* tp_as_number */
0, /* tp_as_sequence */
0, /* tp_as_mapping */
0, /* tp_hash */
0, /* tp_call */
0, /* tp_str */
0, /* tp_getattro */
0, /* tp_setattro */
0, /* tp_as_buffer */
Py_TPFLAGS_DEFAULT, /* tp_flags */
M_aud_DynamicMusic_doc, /* tp_doc */
0, /* tp_traverse */
0, /* tp_clear */
0, /* tp_richcompare */
0, /* tp_weaklistoffset */
0, /* tp_iter */
0, /* tp_iternext */
DynamicMusic_methods, /* tp_methods */
0, /* tp_members */
DynamicMusic_properties, /* tp_getset */
0, /* tp_base */
0, /* tp_dict */
0, /* tp_descr_get */
0, /* tp_descr_set */
0, /* tp_dictoffset */
0, /* tp_init */
0, /* tp_alloc */
DynamicMusic_new, /* tp_new */
};
AUD_API PyObject* DynamicMusic_empty()
{
return DynamicMusicType.tp_alloc(&DynamicMusicType, 0);
}
AUD_API DynamicMusicP* checkDynamicMusic(PyObject* dynamicMusic)
{
if(!PyObject_TypeCheck(dynamicMusic, &DynamicMusicType))
{
PyErr_SetString(PyExc_TypeError, "Object is not of type DynamicMusic!");
return nullptr;
}
return (DynamicMusicP*)dynamicMusic;
}
bool initializeDynamicMusic()
{
return PyType_Ready(&DynamicMusicType) >= 0;
}
void addDynamicMusicToModule(PyObject* module)
{
Py_INCREF(&DynamicMusicType);
PyModule_AddObject(module, "DynamicMusic", (PyObject *)&DynamicMusicType);
}

View File

@@ -0,0 +1,33 @@
/*******************************************************************************
* Copyright 2015-2016 Juan Francisco Crespo Galán
*
* 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.
******************************************************************************/
#pragma once
#include <Python.h>
#include "Audaspace.h"
typedef void Reference_DynamicMusic;
typedef struct {
PyObject_HEAD
Reference_DynamicMusic* dynamicMusic;
} DynamicMusicP;
extern AUD_API PyObject* DynamicMusic_empty();
extern AUD_API DynamicMusicP* checkDynamicMusic(PyObject* dynamicMusic);
bool initializeDynamicMusic();
void addDynamicMusicToModule(PyObject* module);

View File

@@ -0,0 +1,247 @@
/*******************************************************************************
* Copyright 2009-2015 Juan Francisco Crespo Galán
*
* 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 "PyHRTF.h"
#include "PySound.h"
#include "Exception.h"
#include "fx/HRTF.h"
#include "fx/HRTFLoader.h"
extern PyObject* AUDError;
static PyObject *
HRTF_new(PyTypeObject* type, PyObject* args, PyObject* kwds)
{
HRTFP* self = (HRTFP*)type->tp_alloc(type, 0);
if(self != nullptr)
{
try
{
self->hrtf = new std::shared_ptr<aud::HRTF>(new aud::HRTF());
}
catch(aud::Exception& e)
{
Py_DECREF(self);
PyErr_SetString(AUDError, e.what());
return nullptr;
}
}
return (PyObject *)self;
}
static void
HRTF_dealloc(HRTFP* self)
{
if(self->hrtf)
delete reinterpret_cast<std::shared_ptr<aud::HRTF>*>(self->hrtf);
Py_TYPE(self)->tp_free((PyObject *)self);
}
PyDoc_STRVAR(M_aud_HRTF_addImpulseResponse_doc,
"addImpulseResponseFromSound(sound, azimuth, elevation)\n\n"
"Adds a new hrtf to the HRTF object\n\n"
":arg sound: The sound that contains the hrtf.\n"
":type sound: :class:`Sound`\n"
":arg azimuth: The azimuth angle of the hrtf.\n"
":type azimuth: float\n"
":arg elevation: The elevation angle of the hrtf.\n"
":type elevation: float\n"
":return: Whether the action succeeded.\n"
":rtype: bool");
static PyObject *
HRTF_addImpulseResponseFromSound(HRTFP* self, PyObject* args)
{
PyObject* object;
float azimuth, elevation;
if(!PyArg_ParseTuple(args, "Off:hrtf", &object, &azimuth, &elevation))
return nullptr;
Sound* ir = checkSound(object);
if(!ir)
return nullptr;
try
{
return PyBool_FromLong((long)(*reinterpret_cast<std::shared_ptr<aud::HRTF>*>(self->hrtf))->addImpulseResponse(std::make_shared<aud::StreamBuffer>(*reinterpret_cast<std::shared_ptr<aud::ISound>*>(ir->sound)), azimuth, elevation));
}
catch(aud::Exception& e)
{
PyErr_SetString(AUDError, e.what());
return nullptr;
}
}
PyDoc_STRVAR(M_aud_HRTF_loadLeftHrtfSet_doc,
"loadLeftHrtfSet(extension, directory)\n\n"
"Loads all HRTFs from a directory.\n\n"
":arg extension: The file extension of the hrtfs.\n"
":type extension: string\n"
":arg directory: The path to where the HRTF files are located.\n"
":type extension: string\n"
":return: The loaded :class:`HRTF` object.\n"
":rtype: :class:`HRTF`\n\n");
static PyObject *
HRTF_loadLeftHrtfSet(PyTypeObject* type, PyObject* args)
{
const char* dir = nullptr;
const char* ext = nullptr;
if(!PyArg_ParseTuple(args, "ss:hrtf", &ext, &dir))
return nullptr;
HRTFP* self;
self = (HRTFP*)type->tp_alloc(type, 0);
try
{
self->hrtf = new std::shared_ptr<aud::HRTF>(aud::HRTFLoader::loadLeftHRTFs(ext, dir));
}
catch(aud::Exception& e)
{
Py_DECREF(self);
PyErr_SetString(AUDError, e.what());
return nullptr;
}
return (PyObject *)self;
}
PyDoc_STRVAR(M_aud_HRTF_loadRightHrtfSet_doc,
"loadLeftHrtfSet(extension, directory)\n\n"
"Loads all HRTFs from a directory.\n\n"
":arg extension: The file extension of the hrtfs.\n"
":type extension: string\n"
":arg directory: The path to where the HRTF files are located.\n"
":type extension: string\n"
":return: The loaded :class:`HRTF` object.\n"
":rtype: :class:`HRTF`\n\n");
static PyObject *
HRTF_loadRightHrtfSet(PyTypeObject* type, PyObject* args)
{
const char* dir = nullptr;
const char* ext = nullptr;
if(!PyArg_ParseTuple(args, "ss:hrtf", &ext, &dir))
return nullptr;
HRTFP* self;
self = (HRTFP*)type->tp_alloc(type, 0);
try
{
self->hrtf = new std::shared_ptr<aud::HRTF>(aud::HRTFLoader::loadRightHRTFs(ext, dir));
}
catch(aud::Exception& e)
{
Py_DECREF(self);
PyErr_SetString(AUDError, e.what());
return nullptr;
}
return (PyObject *)self;
}
static PyMethodDef HRTF_methods[] = {
{ "addImpulseResponseFromSound", (PyCFunction)HRTF_addImpulseResponseFromSound, METH_VARARGS | METH_KEYWORDS,
M_aud_HRTF_addImpulseResponse_doc
},
{ "loadLeftHrtfSet", (PyCFunction)HRTF_loadLeftHrtfSet, METH_VARARGS | METH_CLASS,
M_aud_HRTF_loadLeftHrtfSet_doc
},
{ "loadRightHrtfSet", (PyCFunction)HRTF_loadRightHrtfSet, METH_VARARGS | METH_CLASS,
M_aud_HRTF_loadRightHrtfSet_doc
},
{ nullptr } /* Sentinel */
};
PyDoc_STRVAR(M_aud_HRTF_doc,
"An HRTF object represents a set of head related transfer functions as impulse responses. It's used for binaural sound");
PyTypeObject HRTFType = {
PyVarObject_HEAD_INIT(nullptr, 0)
"aud.HRTF", /* tp_name */
sizeof(HRTFP), /* tp_basicsize */
0, /* tp_itemsize */
(destructor)HRTF_dealloc, /* tp_dealloc */
0, /* tp_print */
0, /* tp_getattr */
0, /* tp_setattr */
0, /* tp_reserved */
0, /* tp_repr */
0, /* tp_as_number */
0, /* tp_as_sequence */
0, /* tp_as_mapping */
0, /* tp_hash */
0, /* tp_call */
0, /* tp_str */
0, /* tp_getattro */
0, /* tp_setattro */
0, /* tp_as_buffer */
Py_TPFLAGS_DEFAULT, /* tp_flags */
M_aud_HRTF_doc, /* tp_doc */
0, /* tp_traverse */
0, /* tp_clear */
0, /* tp_richcompare */
0, /* tp_weaklistoffset */
0, /* tp_iter */
0, /* tp_iternext */
HRTF_methods, /* tp_methods */
0, /* tp_members */
0, /* tp_getset */
0, /* tp_base */
0, /* tp_dict */
0, /* tp_descr_get */
0, /* tp_descr_set */
0, /* tp_dictoffset */
0, /* tp_init */
0, /* tp_alloc */
HRTF_new, /* tp_new */
};
AUD_API PyObject* HRTF_empty()
{
return HRTFType.tp_alloc(&HRTFType, 0);
}
AUD_API HRTFP* checkHRTF(PyObject* hrtf)
{
if(!PyObject_TypeCheck(hrtf, &HRTFType))
{
PyErr_SetString(PyExc_TypeError, "Object is not of type HRTF!");
return nullptr;
}
return (HRTFP*)hrtf;
}
bool initializeHRTF()
{
return PyType_Ready(&HRTFType) >= 0;
}
void addHRTFToModule(PyObject* module)
{
Py_INCREF(&HRTFType);
PyModule_AddObject(module, "HRTF", (PyObject *)&HRTFType);
}

View File

@@ -0,0 +1,33 @@
/*******************************************************************************
* Copyright 2009-2015 Juan Francisco Crespo Galán
*
* 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.
******************************************************************************/
#pragma once
#include <Python.h>
#include "Audaspace.h"
typedef void Reference_HRTF;
typedef struct {
PyObject_HEAD
Reference_HRTF* hrtf;
} HRTFP;
extern AUD_API PyObject* HRTF_empty();
extern AUD_API HRTFP* checkHRTF(PyObject* hrtf);
bool initializeHRTF();
void addHRTFToModule(PyObject* module);

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,33 @@
/*******************************************************************************
* Copyright 2009-2016 Jörg Müller
*
* 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.
******************************************************************************/
#pragma once
#include <Python.h>
#include "Audaspace.h"
typedef void Reference_IHandle;
typedef struct {
PyObject_HEAD
Reference_IHandle* handle;
} Handle;
extern AUD_API PyObject* Handle_empty();
extern AUD_API Handle* checkHandle(PyObject* handle);
bool initializeHandle();
void addHandleToModule(PyObject* module);

View File

@@ -0,0 +1,137 @@
/*******************************************************************************
* Copyright 2009-2015 Juan Francisco Crespo Galán
*
* 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 "PyImpulseResponse.h"
#include "PySound.h"
#include "Exception.h"
#include "fx/ImpulseResponse.h"
#include "util/StreamBuffer.h"
extern PyObject* AUDError;
static PyObject *
ImpulseResponse_new(PyTypeObject* type, PyObject* args, PyObject* kwds)
{
ImpulseResponseP* self = (ImpulseResponseP*)type->tp_alloc(type, 0);
if(self != nullptr)
{
PyObject* object;
if(!PyArg_ParseTuple(args, "O:sound", &object))
return nullptr;
Sound* sound = checkSound(object);
try
{
self->impulseResponse = new std::shared_ptr<aud::ImpulseResponse>(new aud::ImpulseResponse(std::make_shared<aud::StreamBuffer>(*reinterpret_cast<std::shared_ptr<aud::ISound>*>(sound->sound))));
}
catch(aud::Exception& e)
{
Py_DECREF(self);
PyErr_SetString(AUDError, e.what());
return nullptr;
}
}
return (PyObject *)self;
}
static void
ImpulseResponse_dealloc(ImpulseResponseP* self)
{
if(self->impulseResponse)
delete reinterpret_cast<std::shared_ptr<aud::ImpulseResponse>*>(self->impulseResponse);
Py_TYPE(self)->tp_free((PyObject *)self);
}
static PyMethodDef ImpulseResponse_methods[] = {
{ nullptr } /* Sentinel */
};
PyDoc_STRVAR(M_aud_ImpulseResponse_doc,
"An ImpulseResponse object represents a filter with which to convolve a sound.");
PyTypeObject ImpulseResponseType = {
PyVarObject_HEAD_INIT(nullptr, 0)
"aud.ImpulseResponse", /* tp_name */
sizeof(ImpulseResponseP), /* tp_basicsize */
0, /* tp_itemsize */
(destructor)ImpulseResponse_dealloc, /* tp_dealloc */
0, /* tp_print */
0, /* tp_getattr */
0, /* tp_setattr */
0, /* tp_reserved */
0, /* tp_repr */
0, /* tp_as_number */
0, /* tp_as_sequence */
0, /* tp_as_mapping */
0, /* tp_hash */
0, /* tp_call */
0, /* tp_str */
0, /* tp_getattro */
0, /* tp_setattro */
0, /* tp_as_buffer */
Py_TPFLAGS_DEFAULT, /* tp_flags */
M_aud_ImpulseResponse_doc, /* tp_doc */
0, /* tp_traverse */
0, /* tp_clear */
0, /* tp_richcompare */
0, /* tp_weaklistoffset */
0, /* tp_iter */
0, /* tp_iternext */
ImpulseResponse_methods, /* tp_methods */
0, /* tp_members */
0, /* tp_getset */
0, /* tp_base */
0, /* tp_dict */
0, /* tp_descr_get */
0, /* tp_descr_set */
0, /* tp_dictoffset */
0, /* tp_init */
0, /* tp_alloc */
ImpulseResponse_new, /* tp_new */
};
AUD_API PyObject* ImpulseResponse_empty()
{
return ImpulseResponseType.tp_alloc(&ImpulseResponseType, 0);
}
AUD_API ImpulseResponseP* checkImpulseResponse(PyObject* impulseResponse)
{
if(!PyObject_TypeCheck(impulseResponse, &ImpulseResponseType))
{
PyErr_SetString(PyExc_TypeError, "Object is not of type ImpulseResponse!");
return nullptr;
}
return (ImpulseResponseP*)impulseResponse;
}
bool initializeImpulseResponse()
{
return PyType_Ready(&ImpulseResponseType) >= 0;
}
void addImpulseResponseToModule(PyObject* module)
{
Py_INCREF(&ImpulseResponseType);
PyModule_AddObject(module, "ImpulseResponse", (PyObject *)&ImpulseResponseType);
}

View File

@@ -0,0 +1,33 @@
/*******************************************************************************
* Copyright 2009-2015 Juan Francisco Crespo Galán
*
* 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.
******************************************************************************/
#pragma once
#include <Python.h>
#include "Audaspace.h"
typedef void Reference_ImpulseResponse;
typedef struct {
PyObject_HEAD
Reference_ImpulseResponse* impulseResponse;
} ImpulseResponseP;
extern AUD_API PyObject* ImpulseResponse_empty();
extern AUD_API ImpulseResponseP* checkImpulseResponse(PyObject* impulseResponse);
bool initializeImpulseResponse();
void addImpulseResponseToModule(PyObject* module);

View File

@@ -0,0 +1,389 @@
/*******************************************************************************
* Copyright 2015-2016 Juan Francisco Crespo Galán
*
* 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 "PyPlaybackManager.h"
#include "PySound.h"
#include "PyHandle.h"
#include "PyDevice.h"
#include "Exception.h"
#include "fx/PlaybackManager.h"
extern PyObject* AUDError;
static PyObject *
PlaybackManager_new(PyTypeObject* type, PyObject* args, PyObject* kwds)
{
PlaybackManagerP* self = (PlaybackManagerP*)type->tp_alloc(type, 0);
if(self != nullptr)
{
PyObject* object;
if(!PyArg_ParseTuple(args, "O:catKey", &object))
return nullptr;
Device* device = checkDevice(object);
try
{
self->playbackManager = new std::shared_ptr<aud::PlaybackManager>(new aud::PlaybackManager(*reinterpret_cast<std::shared_ptr<aud::IDevice>*>(device->device)));
}
catch(aud::Exception& e)
{
Py_DECREF(self);
PyErr_SetString(AUDError, e.what());
return nullptr;
}
}
return (PyObject *)self;
}
static void
PlaybackManager_dealloc(PlaybackManagerP* self)
{
if(self->playbackManager)
delete reinterpret_cast<std::shared_ptr<aud::PlaybackManager>*>(self->playbackManager);
Py_TYPE(self)->tp_free((PyObject *)self);
}
PyDoc_STRVAR(M_aud_PlaybackManager_play_doc,
"setVolume(sound, catKey)\n\n"
"Plays a sound through the playback manager and assigns it to a category.\n\n"
":arg sound: The sound to play.\n"
":type sound: :class:`Sound`\n"
":arg catKey: the key of the category in which the sound will be added, if it doesn't exist, a new one will be created.\n"
":type catKey: int\n"
":return: The playback handle with which playback can be controlled with.\n"
":rtype: :class:`Handle`");
static PyObject *
PlaybackManager_play(PlaybackManagerP* self, PyObject* args)
{
PyObject* object;
unsigned int cat;
if(!PyArg_ParseTuple(args, "OI:catKey", &object, &cat))
return nullptr;
Sound* sound = checkSound(object);
if(!sound)
return nullptr;
Handle* handle;
handle = (Handle*)Handle_empty();
if(handle != nullptr)
{
try
{
handle->handle = new std::shared_ptr<aud::IHandle>((*reinterpret_cast<std::shared_ptr<aud::PlaybackManager>*>(self->playbackManager))->play(*reinterpret_cast<std::shared_ptr<aud::ISound>*>(sound->sound), cat));
}
catch(aud::Exception& e)
{
Py_DECREF(handle);
PyErr_SetString(AUDError, e.what());
return nullptr;
}
}
return (PyObject *)handle;
}
PyDoc_STRVAR(M_aud_PlaybackManager_resume_doc,
"resume(catKey)\n\n"
"Resumes playback of the catgory.\n\n"
":arg catKey: the key of the category.\n"
":type catKey: int\n"
":return: Whether the action succeeded.\n"
":rtype: bool");
static PyObject *
PlaybackManager_resume(PlaybackManagerP* self, PyObject* args)
{
unsigned int cat;
if(!PyArg_ParseTuple(args, "I:catKey", &cat))
return nullptr;
try
{
return PyBool_FromLong((long)(*reinterpret_cast<std::shared_ptr<aud::PlaybackManager>*>(self->playbackManager))->resume(cat));
}
catch(aud::Exception& e)
{
PyErr_SetString(AUDError, e.what());
return nullptr;
}
}
PyDoc_STRVAR(M_aud_PlaybackManager_pause_doc,
"pause(catKey)\n\n"
"Pauses playback of the category.\n\n"
":arg catKey: the key of the category.\n"
":type catKey: int\n"
":return: Whether the action succeeded.\n"
":rtype: bool");
static PyObject *
PlaybackManager_pause(PlaybackManagerP* self, PyObject* args)
{
unsigned int cat;
if(!PyArg_ParseTuple(args, "I:catKey", &cat))
return nullptr;
try
{
return PyBool_FromLong((long)(*reinterpret_cast<std::shared_ptr<aud::PlaybackManager>*>(self->playbackManager))->pause(cat));
}
catch(aud::Exception& e)
{
PyErr_SetString(AUDError, e.what());
return nullptr;
}
}
PyDoc_STRVAR(M_aud_PlaybackManager_add_category_doc,
"addCategory(volume)\n\n"
"Adds a category with a custom volume.\n\n"
":arg volume: The volume for ther new category.\n"
":type volume: float\n"
":return: The key of the new category.\n"
":rtype: int\n\n");
static PyObject *
PlaybackManager_add_category(PlaybackManagerP* self, PyObject* args)
{
float vol;
if(!PyArg_ParseTuple(args, "f:volume", &vol))
return nullptr;
try
{
return Py_BuildValue("I", (*reinterpret_cast<std::shared_ptr<aud::PlaybackManager>*>(self->playbackManager))->addCategory(vol));
}
catch(aud::Exception& e)
{
PyErr_SetString(AUDError, e.what());
return nullptr;
}
}
PyDoc_STRVAR(M_aud_PlaybackManager_get_volume_doc,
"getVolume(catKey)\n\n"
"Retrieves the volume of a category.\n\n"
":arg catKey: the key of the category.\n"
":type catKey: int\n"
":return: The volume of the cateogry.\n"
":rtype: float\n\n");
static PyObject *
PlaybackManager_get_volume(PlaybackManagerP* self, PyObject* args)
{
unsigned int cat;
if(!PyArg_ParseTuple(args, "I:catKey", &cat))
return nullptr;
try
{
return Py_BuildValue("f", (*reinterpret_cast<std::shared_ptr<aud::PlaybackManager>*>(self->playbackManager))->getVolume(cat));
}
catch(aud::Exception& e)
{
PyErr_SetString(AUDError, e.what());
return nullptr;
}
}
PyDoc_STRVAR(M_aud_PlaybackManager_set_volume_doc,
"setVolume(volume, catKey)\n\n"
"Changes the volume of a category.\n\n"
":arg volume: the new volume value.\n"
":type volume: float\n"
":arg catKey: the key of the category.\n"
":type catKey: int\n"
":return: Whether the action succeeded.\n"
":rtype: int\n\n");
static PyObject *
PlaybackManager_set_volume(PlaybackManagerP* self, PyObject* args)
{
float volume;
unsigned int cat;
if(!PyArg_ParseTuple(args, "fI:volume", &volume, &cat))
return nullptr;
try
{
return PyBool_FromLong((long)(*reinterpret_cast<std::shared_ptr<aud::PlaybackManager>*>(self->playbackManager))->setVolume(volume, cat));
}
catch(aud::Exception& e)
{
PyErr_SetString(AUDError, e.what());
return nullptr;
}
}
PyDoc_STRVAR(M_aud_PlaybackManager_stop_doc,
"stop(catKey)\n\n"
"Stops playback of the category.\n\n"
":arg catKey: the key of the category.\n"
":type catKey: int\n"
":return: Whether the action succeeded.\n"
":rtype: bool\n\n");
static PyObject *
PlaybackManager_stop(PlaybackManagerP* self, PyObject* args)
{
unsigned int cat;
if(!PyArg_ParseTuple(args, "I:catKey", &cat))
return nullptr;
try
{
return PyBool_FromLong((long)(*reinterpret_cast<std::shared_ptr<aud::PlaybackManager>*>(self->playbackManager))->stop(cat));
}
catch(aud::Exception& e)
{
PyErr_SetString(AUDError, e.what());
return nullptr;
}
}
PyDoc_STRVAR(M_aud_PlaybackManager_clean_doc,
"clean()\n\n"
"Cleans all the invalid and finished sound from the playback manager.\n\n");
static PyObject *
PlaybackManager_clean(PlaybackManagerP* self)
{
try
{
(*reinterpret_cast<std::shared_ptr<aud::PlaybackManager>*>(self->playbackManager))->clean();
Py_RETURN_NONE;
}
catch(aud::Exception& e)
{
PyErr_SetString(AUDError, e.what());
return nullptr;
}
}
static PyMethodDef PlaybackManager_methods[] = {
{ "play", (PyCFunction)PlaybackManager_play, METH_VARARGS | METH_KEYWORDS,
M_aud_PlaybackManager_play_doc
},
{ "resume", (PyCFunction)PlaybackManager_resume, METH_VARARGS,
M_aud_PlaybackManager_resume_doc
},
{ "pause", (PyCFunction)PlaybackManager_pause, METH_VARARGS,
M_aud_PlaybackManager_pause_doc
},
{ "stop", (PyCFunction)PlaybackManager_stop, METH_VARARGS,
M_aud_PlaybackManager_stop_doc
},
{ "addCategory", (PyCFunction)PlaybackManager_add_category, METH_VARARGS,
M_aud_PlaybackManager_add_category_doc
},
{ "getVolume", (PyCFunction)PlaybackManager_get_volume, METH_VARARGS,
M_aud_PlaybackManager_get_volume_doc
},
{ "setVolume", (PyCFunction)PlaybackManager_set_volume, METH_VARARGS,
M_aud_PlaybackManager_set_volume_doc
},
{ "clean", (PyCFunction)PlaybackManager_clean, METH_NOARGS,
M_aud_PlaybackManager_clean_doc
},
{ nullptr } /* Sentinel */
};
PyDoc_STRVAR(M_aud_PlaybackManager_doc,
"A PlabackManager object allows to easily control groups os sounds organized in categories.");
PyTypeObject PlaybackManagerType = {
PyVarObject_HEAD_INIT(nullptr, 0)
"aud.PlaybackManager", /* tp_name */
sizeof(PlaybackManagerP), /* tp_basicsize */
0, /* tp_itemsize */
(destructor)PlaybackManager_dealloc, /* tp_dealloc */
0, /* tp_print */
0, /* tp_getattr */
0, /* tp_setattr */
0, /* tp_reserved */
0, /* tp_repr */
0, /* tp_as_number */
0, /* tp_as_sequence */
0, /* tp_as_mapping */
0, /* tp_hash */
0, /* tp_call */
0, /* tp_str */
0, /* tp_getattro */
0, /* tp_setattro */
0, /* tp_as_buffer */
Py_TPFLAGS_DEFAULT, /* tp_flags */
M_aud_PlaybackManager_doc, /* tp_doc */
0, /* tp_traverse */
0, /* tp_clear */
0, /* tp_richcompare */
0, /* tp_weaklistoffset */
0, /* tp_iter */
0, /* tp_iternext */
PlaybackManager_methods, /* tp_methods */
0, /* tp_members */
0, /* tp_getset */
0, /* tp_base */
0, /* tp_dict */
0, /* tp_descr_get */
0, /* tp_descr_set */
0, /* tp_dictoffset */
0, /* tp_init */
0, /* tp_alloc */
PlaybackManager_new, /* tp_new */
};
AUD_API PyObject* PlaybackManager_empty()
{
return PlaybackManagerType.tp_alloc(&PlaybackManagerType, 0);
}
AUD_API PlaybackManagerP* checkPlaybackManager(PyObject* playbackManager)
{
if(!PyObject_TypeCheck(playbackManager, &PlaybackManagerType))
{
PyErr_SetString(PyExc_TypeError, "Object is not of type PlaybackManager!");
return nullptr;
}
return (PlaybackManagerP*)playbackManager;
}
bool initializePlaybackManager()
{
return PyType_Ready(&PlaybackManagerType) >= 0;
}
void addPlaybackManagerToModule(PyObject* module)
{
Py_INCREF(&PlaybackManagerType);
PyModule_AddObject(module, "PlaybackManager", (PyObject *)&PlaybackManagerType);
}

View File

@@ -0,0 +1,33 @@
/*******************************************************************************
* Copyright 2015-2016 Juan Francisco Crespo Galán
*
* 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.
******************************************************************************/
#pragma once
#include <Python.h>
#include "Audaspace.h"
typedef void Reference_PlaybackManager;
typedef struct {
PyObject_HEAD
Reference_PlaybackManager* playbackManager;
} PlaybackManagerP;
extern AUD_API PyObject* PlaybackManager_empty();
extern AUD_API PlaybackManagerP* checkPlaybackManager(PyObject* playbackManager);
bool initializePlaybackManager();
void addPlaybackManagerToModule(PyObject* module);

View File

@@ -0,0 +1,655 @@
/*******************************************************************************
* Copyright 2009-2016 Jörg Müller
*
* 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 "PySequence.h"
#include "PySound.h"
#include "PySequenceEntry.h"
#include "sequence/AnimateableProperty.h"
#include "sequence/Sequence.h"
#include "Exception.h"
#include <vector>
#include <structmember.h>
using aud::Channels;
using aud::DistanceModel;
using aud::Exception;
using aud::ISound;
using aud::AnimateableProperty;
using aud::AnimateablePropertyType;
using aud::Specs;
extern PyObject* AUDError;
// ====================================================================
static void
Sequence_dealloc(Sequence* self)
{
if(self->sequence)
delete reinterpret_cast<std::shared_ptr<aud::Sequence>*>(self->sequence);
Py_TYPE(self)->tp_free((PyObject *)self);
}
static PyObject *
Sequence_new(PyTypeObject* type, PyObject* args, PyObject* kwds)
{
Sequence* self;
int channels = aud::CHANNELS_STEREO;
double rate = aud::RATE_48000;
float fps = 30.0f;
bool muted = false;
PyObject* mutedo = nullptr;
self = (Sequence*)type->tp_alloc(type, 0);
if(self != nullptr)
{
static const char* kwlist[] = {"channels", "rate", "fps", "muted", nullptr};
if(!PyArg_ParseTupleAndKeywords(args, kwds, "|idfO:Sequence", const_cast<char**>(kwlist), &channels, &rate, &fps, &mutedo))
{
Py_DECREF(self);
return nullptr;
}
if(mutedo)
{
if(!PyBool_Check(mutedo))
{
PyErr_SetString(PyExc_TypeError, "muted is not a boolean!");
return nullptr;
}
muted = mutedo == Py_True;
}
aud::Specs specs;
specs.channels = static_cast<aud::Channels>(channels);
specs.rate = rate;
try
{
self->sequence = new std::shared_ptr<aud::Sequence>(new aud::Sequence(specs, fps, muted));
}
catch(Exception& e)
{
Py_DECREF(self);
PyErr_SetString(AUDError, e.what());
return nullptr;
}
}
return (PyObject *)self;
}
PyDoc_STRVAR(M_aud_Sequence_add_doc,
"add()\n\n"
"Adds a new entry to the scene.\n"
":arg sound: The sound this entry should play.\n"
":type sound: :class:`Sound`\n"
":arg begin: The start time.\n"
":type begin: float\n"
":arg end: The end time or a negative value if determined by the sound.\n"
":type end: float\n"
":arg skip: How much seconds should be skipped at the beginning.\n"
":type skip: float\n"
":return: The entry added.\n"
":rtype: :class:`SequenceEntry`");
static PyObject *
Sequence_add(Sequence* self, PyObject* args, PyObject* kwds)
{
PyObject* object;
float begin;
float end = -1.0f;
float skip = 0.0f;
static const char* kwlist[] = {"sound", "begin", "end", "skip", nullptr};
if(!PyArg_ParseTupleAndKeywords(args, kwds, "Of|ff:add", const_cast<char**>(kwlist), &object, &begin, &end, &skip))
return nullptr;
Sound* sound = checkSound(object);
if(!sound)
return nullptr;
SequenceEntry* entry;
entry = (SequenceEntry*)SequenceEntry_empty();
if(entry != nullptr)
{
try
{
entry->entry = new std::shared_ptr<aud::SequenceEntry>((*reinterpret_cast<std::shared_ptr<aud::Sequence>*>(self->sequence))->add(*reinterpret_cast<std::shared_ptr<ISound>*>(sound->sound), begin, end, skip));
}
catch(Exception& e)
{
Py_DECREF(entry);
PyErr_SetString(AUDError, e.what());
return nullptr;
}
}
return (PyObject *)entry;
}
PyDoc_STRVAR(M_aud_Sequence_remove_doc,
"reomve()\n\n"
"Adds a new entry to the scene.\n"
":arg entry: The entry to remove.\n"
":type entry: :class:`SequenceEntry`\n");
static PyObject *
Sequence_remove(Sequence* self, PyObject* args)
{
PyObject* object;
if(!PyArg_ParseTuple(args, "O:remove", &object))
return nullptr;
SequenceEntry* entry = checkSequenceEntry(object);
if(!entry)
return nullptr;
try
{
(*reinterpret_cast<std::shared_ptr<aud::Sequence>*>(self->sequence))->remove(*reinterpret_cast<std::shared_ptr<aud::SequenceEntry>*>(entry->entry));
Py_RETURN_NONE;
}
catch(Exception& e)
{
Py_DECREF(entry);
PyErr_SetString(AUDError, e.what());
return nullptr;
}
}
PyDoc_STRVAR(M_aud_Sequence_setAnimationData_doc,
"setAnimationData()\n\n"
"Writes animation data to a sequence.\n\n"
":arg type: The type of animation data.\n"
":type type: int\n"
":arg frame: The frame this data is for.\n"
":type frame: int\n"
":arg data: The data to write.\n"
":type data: sequence of float\n"
":arg animated: Whether the attribute is animated.\n"
":type animated: bool");
static PyObject *
Sequence_setAnimationData(Sequence* self, PyObject* args)
{
int type, frame;
PyObject* py_data;
Py_ssize_t py_data_len;
PyObject* animatedo;
bool animated;
if(!PyArg_ParseTuple(args, "iiOO:setAnimationData", &type, &frame, &py_data, &animatedo))
return nullptr;
if(!PySequence_Check(py_data))
{
PyErr_SetString(PyExc_TypeError, "Parameter is not a sequence!");
return nullptr;
}
py_data_len= PySequence_Size(py_data);
std::vector<float> data;
data.resize(py_data_len);
PyObject* py_value;
float value;
for(Py_ssize_t i = 0; i < py_data_len; i++)
{
py_value = PySequence_GetItem(py_data, i);
value= (float)PyFloat_AsDouble(py_value);
Py_DECREF(py_value);
if(value == -1.0f && PyErr_Occurred()) {
return nullptr;
}
data.push_back(value);
}
if(!PyBool_Check(animatedo))
{
PyErr_SetString(PyExc_TypeError, "animated is not a boolean!");
return nullptr;
}
animated = animatedo == Py_True;
try
{
AnimateableProperty* prop = (*reinterpret_cast<std::shared_ptr<aud::Sequence>*>(self->sequence))->getAnimProperty(static_cast<AnimateablePropertyType>(type));
if(prop->getCount() != py_data_len)
{
PyErr_SetString(PyExc_ValueError, "the amount of floats doesn't fit the animated property");
return nullptr;
}
if(animated)
{
if(frame >= 0)
prop->write(&data[0], frame, 1);
}
else
{
prop->write(&data[0]);
}
Py_RETURN_NONE;
}
catch(Exception& e)
{
PyErr_SetString(AUDError, e.what());
return nullptr;
}
}
static PyMethodDef Sequence_methods[] = {
{"add", (PyCFunction)Sequence_add, METH_VARARGS | METH_KEYWORDS,
M_aud_Sequence_add_doc
},
{"remove", (PyCFunction)Sequence_remove, METH_VARARGS,
M_aud_Sequence_remove_doc
},
{"setAnimationData", (PyCFunction)Sequence_setAnimationData, METH_VARARGS,
M_aud_Sequence_setAnimationData_doc
},
{nullptr} /* Sentinel */
};
PyDoc_STRVAR(M_aud_Sequence_channels_doc,
"The channel count of the sequence.");
static PyObject *
Sequence_get_channels(Sequence* self, void* nothing)
{
try
{
Specs specs = (*reinterpret_cast<std::shared_ptr<aud::Sequence>*>(self->sequence))->getSpecs();
return Py_BuildValue("i", specs.channels);
}
catch(Exception& e)
{
PyErr_SetString(AUDError, e.what());
return nullptr;
}
}
static int
Sequence_set_channels(Sequence* self, PyObject* args, void* nothing)
{
int channels;
if(!PyArg_Parse(args, "i:channels", &channels))
return -1;
try
{
std::shared_ptr<aud::Sequence> sequence = *reinterpret_cast<std::shared_ptr<aud::Sequence>*>(self->sequence);
Specs specs = sequence->getSpecs();
specs.channels = static_cast<Channels>(channels);
sequence->setSpecs(specs);
return 0;
}
catch(Exception& e)
{
PyErr_SetString(AUDError, e.what());
return -1;
}
}
PyDoc_STRVAR(M_aud_Sequence_distance_model_doc,
"The distance model of the sequence.\n\n"
".. seealso:: http://connect.creativelabs.com/openal/Documentation/OpenAL%201.1%20Specification.htm#_Toc199835864");
static PyObject *
Sequence_get_distance_model(Sequence* self, void* nothing)
{
try
{
return Py_BuildValue("i", (*reinterpret_cast<std::shared_ptr<aud::Sequence>*>(self->sequence))->getDistanceModel());
}
catch(Exception& e)
{
PyErr_SetString(AUDError, e.what());
return nullptr;
}
}
static int
Sequence_set_distance_model(Sequence* self, PyObject* args, void* nothing)
{
int distance_model;
if(!PyArg_Parse(args, "i:distance_model", &distance_model))
return -1;
try
{
(*reinterpret_cast<std::shared_ptr<aud::Sequence>*>(self->sequence))->setDistanceModel(static_cast<DistanceModel>(distance_model));
return 0;
}
catch(Exception& e)
{
PyErr_SetString(AUDError, e.what());
return -1;
}
}
PyDoc_STRVAR(M_aud_Sequence_doppler_factor_doc,
"The doppler factor of the sequence.\n"
"This factor is a scaling factor for the velocity vectors in "
"doppler calculation. So a value bigger than 1 will exaggerate "
"the effect as it raises the velocity.");
static PyObject *
Sequence_get_doppler_factor(Sequence* self, void* nothing)
{
try
{
return Py_BuildValue("f", (*reinterpret_cast<std::shared_ptr<aud::Sequence>*>(self->sequence))->getDopplerFactor());
}
catch(Exception& e)
{
PyErr_SetString(AUDError, e.what());
return nullptr;
}
}
static int
Sequence_set_doppler_factor(Sequence* self, PyObject* args, void* nothing)
{
float factor;
if(!PyArg_Parse(args, "f:doppler_factor", &factor))
return -1;
try
{
(*reinterpret_cast<std::shared_ptr<aud::Sequence>*>(self->sequence))->setDopplerFactor(factor);
return 0;
}
catch(Exception& e)
{
PyErr_SetString(AUDError, e.what());
return -1;
}
}
PyDoc_STRVAR(M_aud_Sequence_fps_doc,
"The listeners's location in 3D space, a 3D tuple of floats.");
static PyObject *
Sequence_get_fps(Sequence* self, void* nothing)
{
try
{
return Py_BuildValue("f", (*reinterpret_cast<std::shared_ptr<aud::Sequence>*>(self->sequence))->getFPS());
}
catch(Exception& e)
{
PyErr_SetString(AUDError, e.what());
return nullptr;
}
}
static int
Sequence_set_fps(Sequence* self, PyObject* args, void* nothing)
{
float fps;
if(!PyArg_Parse(args, "f:fps", &fps))
return -1;
try
{
(*reinterpret_cast<std::shared_ptr<aud::Sequence>*>(self->sequence))->setFPS(fps);
return 0;
}
catch(Exception& e)
{
PyErr_SetString(AUDError, e.what());
return -1;
}
}
PyDoc_STRVAR(M_aud_Sequence_muted_doc,
"Whether the whole sequence is muted.\n");
static PyObject *
Sequence_get_muted(Sequence* self, void* nothing)
{
try
{
std::shared_ptr<aud::Sequence>* sequence = reinterpret_cast<std::shared_ptr<aud::Sequence>*>(self->sequence);
return PyBool_FromLong((long)(*sequence)->isMuted());
}
catch(Exception& e)
{
PyErr_SetString(AUDError, e.what());
return nullptr;
}
}
static int
Sequence_set_muted(Sequence* self, PyObject* args, void* nothing)
{
if(!PyBool_Check(args))
{
PyErr_SetString(PyExc_TypeError, "muted is not a boolean!");
return -1;
}
bool muted = args == Py_True;
try
{
std::shared_ptr<aud::Sequence>* sequence = reinterpret_cast<std::shared_ptr<aud::Sequence>*>(self->sequence);
(*sequence)->mute(muted);
return 0;
}
catch(Exception& e)
{
PyErr_SetString(AUDError, e.what());
}
return -1;
}
PyDoc_STRVAR(M_aud_Sequence_rate_doc,
"The sampling rate of the sequence in Hz.");
static PyObject *
Sequence_get_rate(Sequence* self, void* nothing)
{
try
{
Specs specs = (*reinterpret_cast<std::shared_ptr<aud::Sequence>*>(self->sequence))->getSpecs();
return Py_BuildValue("d", specs.rate);
}
catch(Exception& e)
{
PyErr_SetString(AUDError, e.what());
return nullptr;
}
}
static int
Sequence_set_rate(Sequence* self, PyObject* args, void* nothing)
{
double rate;
if(!PyArg_Parse(args, "d:rate", &rate))
return -1;
try
{
std::shared_ptr<aud::Sequence> sequence = *reinterpret_cast<std::shared_ptr<aud::Sequence>*>(self->sequence);
Specs specs = sequence->getSpecs();
specs.rate = rate;
sequence->setSpecs(specs);
return 0;
}
catch(Exception& e)
{
PyErr_SetString(AUDError, e.what());
return -1;
}
}
PyDoc_STRVAR(M_aud_Sequence_speed_of_sound_doc,
"The speed of sound of the sequence.\n"
"The speed of sound in air is typically 343.3 m/s.");
static PyObject *
Sequence_get_speed_of_sound(Sequence* self, void* nothing)
{
try
{
return Py_BuildValue("f", (*reinterpret_cast<std::shared_ptr<aud::Sequence>*>(self->sequence))->getSpeedOfSound());
}
catch(Exception& e)
{
PyErr_SetString(AUDError, e.what());
return nullptr;
}
}
static int
Sequence_set_speed_of_sound(Sequence* self, PyObject* args, void* nothing)
{
float speed;
if(!PyArg_Parse(args, "f:speed_of_sound", &speed))
return -1;
try
{
(*reinterpret_cast<std::shared_ptr<aud::Sequence>*>(self->sequence))->setSpeedOfSound(speed);
return 0;
}
catch(Exception& e)
{
PyErr_SetString(AUDError, e.what());
return -1;
}
}
static PyGetSetDef Sequence_properties[] = {
{(char*)"channels", (getter)Sequence_get_channels, (setter)Sequence_set_channels,
M_aud_Sequence_channels_doc, nullptr },
{(char*)"distance_model", (getter)Sequence_get_distance_model, (setter)Sequence_set_distance_model,
M_aud_Sequence_distance_model_doc, nullptr },
{(char*)"doppler_factor", (getter)Sequence_get_doppler_factor, (setter)Sequence_set_doppler_factor,
M_aud_Sequence_doppler_factor_doc, nullptr },
{(char*)"fps", (getter)Sequence_get_fps, (setter)Sequence_set_fps,
M_aud_Sequence_fps_doc, nullptr },
{(char*)"muted", (getter)Sequence_get_muted, (setter)Sequence_set_muted,
M_aud_Sequence_muted_doc, nullptr },
{(char*)"rate", (getter)Sequence_get_rate, (setter)Sequence_set_rate,
M_aud_Sequence_rate_doc, nullptr },
{(char*)"speed_of_sound", (getter)Sequence_get_speed_of_sound, (setter)Sequence_set_speed_of_sound,
M_aud_Sequence_speed_of_sound_doc, nullptr },
{nullptr} /* Sentinel */
};
PyDoc_STRVAR(M_aud_Sequence_doc,
"This sound represents sequenced entries to play a sound scene.");
extern PyTypeObject SoundType;
static PyTypeObject SequenceType = {
PyVarObject_HEAD_INIT(nullptr, 0)
"aud.Sequence", /* tp_name */
sizeof(Sequence), /* tp_basicsize */
0, /* tp_itemsize */
(destructor)Sequence_dealloc,/* tp_dealloc */
0, /* tp_print */
0, /* tp_getattr */
0, /* tp_setattr */
0, /* tp_reserved */
0, /* tp_repr */
0, /* tp_as_number */
0, /* tp_as_sequence */
0, /* tp_as_mapping */
0, /* tp_hash */
0, /* tp_call */
0, /* tp_str */
0, /* tp_getattro */
0, /* tp_setattro */
0, /* tp_as_buffer */
Py_TPFLAGS_DEFAULT, /* tp_flags */
M_aud_Sequence_doc, /* tp_doc */
0, /* tp_traverse */
0, /* tp_clear */
0, /* tp_richcompare */
0, /* tp_weaklistoffset */
0, /* tp_iter */
0, /* tp_iternext */
Sequence_methods, /* tp_methods */
0, /* tp_members */
Sequence_properties, /* tp_getset */
&SoundType, /* tp_base */
0, /* tp_dict */
0, /* tp_descr_get */
0, /* tp_descr_set */
0, /* tp_dictoffset */
0, /* tp_init */
0, /* tp_alloc */
Sequence_new, /* tp_new */
};
AUD_API PyObject* Sequence_empty()
{
return SequenceType.tp_alloc(&SequenceType, 0);
}
AUD_API Sequence* checkSequence(PyObject* sequence)
{
if(!PyObject_TypeCheck(sequence, &SequenceType))
{
PyErr_SetString(PyExc_TypeError, "Object is not of type Sequence!");
return nullptr;
}
return (Sequence*)sequence;
}
bool initializeSequence()
{
return PyType_Ready(&SequenceType) >= 0;
}
void addSequenceToModule(PyObject* module)
{
Py_INCREF(&SequenceType);
PyModule_AddObject(module, "Sequence", (PyObject *)&SequenceType);
}

View File

@@ -0,0 +1,33 @@
/*******************************************************************************
* Copyright 2009-2016 Jörg Müller
*
* 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.
******************************************************************************/
#pragma once
#include <Python.h>
#include "Audaspace.h"
typedef void Reference_Sequence;
typedef struct {
PyObject_HEAD
Reference_Sequence* sequence;
} Sequence;
extern AUD_API PyObject* Sequence_empty();
extern AUD_API Sequence* checkSequence(PyObject* sequence);
bool initializeSequence();
void addSequenceToModule(PyObject* module);

View File

@@ -0,0 +1,740 @@
/*******************************************************************************
* Copyright 2009-2016 Jörg Müller
*
* 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 "PySequenceEntry.h"
#include "PySound.h"
#include "Exception.h"
#include "sequence/AnimateableProperty.h"
#include "sequence/SequenceEntry.h"
#include <structmember.h>
#include <vector>
using aud::Exception;
using aud::AnimateableProperty;
using aud::AnimateablePropertyType;
using aud::ISound;
extern PyObject* AUDError;
// ====================================================================
static void
SequenceEntry_dealloc(SequenceEntry* self)
{
if(self->entry)
delete reinterpret_cast<std::shared_ptr<aud::SequenceEntry>*>(self->entry);
Py_TYPE(self)->tp_free((PyObject *)self);
}
PyDoc_STRVAR(M_aud_SequenceEntry_move_doc,
"move()\n\n"
"Moves the entry.\n\n"
":arg begin: The new start time.\n"
":type begin: float\n"
":arg end: The new end time or a negative value if unknown.\n"
":type end: float\n"
":arg skip: How many seconds to skip at the beginning.\n"
":type skip: float\n");
static PyObject *
SequenceEntry_move(SequenceEntry* self, PyObject* args)
{
float begin, end, skip;
if(!PyArg_ParseTuple(args, "fff:move", &begin, &end, &skip))
return nullptr;
try
{
(*reinterpret_cast<std::shared_ptr<aud::SequenceEntry>*>(self->entry))->move(begin, end, skip);
Py_RETURN_NONE;
}
catch(Exception& e)
{
PyErr_SetString(AUDError, e.what());
return nullptr;
}
}
PyDoc_STRVAR(M_aud_SequenceEntry_setAnimationData_doc,
"setAnimationData()\n\n"
"Writes animation data to a sequenced entry.\n\n"
":arg type: The type of animation data.\n"
":type type: int\n"
":arg frame: The frame this data is for.\n"
":type frame: int\n"
":arg data: The data to write.\n"
":type data: sequence of float\n"
":arg animated: Whether the attribute is animated.\n"
":type animated: bool");
static PyObject *
SequenceEntry_setAnimationData(SequenceEntry* self, PyObject* args)
{
int type, frame;
PyObject* py_data;
Py_ssize_t py_data_len;
PyObject* animatedo;
bool animated;
if(!PyArg_ParseTuple(args, "iiOO:setAnimationData", &type, &frame, &py_data, &animatedo))
return nullptr;
if(!PySequence_Check(py_data))
{
PyErr_SetString(PyExc_TypeError, "Parameter is not a sequence!");
return nullptr;
}
py_data_len= PySequence_Size(py_data);
std::vector<float> data;
data.resize(py_data_len);
PyObject* py_value;
float value;
for(Py_ssize_t i = 0; i < py_data_len; i++)
{
py_value = PySequence_GetItem(py_data, i);
value= (float)PyFloat_AsDouble(py_value);
Py_DECREF(py_value);
if(value == -1.0f && PyErr_Occurred()) {
return nullptr;
}
data.push_back(value);
}
if(!PyBool_Check(animatedo))
{
PyErr_SetString(PyExc_TypeError, "animated is not a boolean!");
return nullptr;
}
animated = animatedo == Py_True;
try
{
AnimateableProperty* prop = (*reinterpret_cast<std::shared_ptr<aud::SequenceEntry>*>(self->entry))->getAnimProperty(static_cast<AnimateablePropertyType>(type));
if(prop->getCount() != py_data_len)
{
PyErr_SetString(PyExc_ValueError, "the amount of floats doesn't fit the animated property");
return nullptr;
}
if(animated)
{
if(frame >= 0)
prop->write(&data[0], frame, 1);
}
else
{
prop->write(&data[0]);
}
Py_RETURN_NONE;
}
catch(Exception& e)
{
PyErr_SetString(AUDError, e.what());
return nullptr;
}
}
static PyMethodDef SequenceEntry_methods[] = {
{"move", (PyCFunction)SequenceEntry_move, METH_VARARGS,
M_aud_SequenceEntry_move_doc
},
{"setAnimationData", (PyCFunction)SequenceEntry_setAnimationData, METH_VARARGS,
M_aud_SequenceEntry_setAnimationData_doc
},
{nullptr} /* Sentinel */
};
PyDoc_STRVAR(M_aud_SequenceEntry_attenuation_doc,
"This factor is used for distance based attenuation of the "
"source.\n\n"
".. seealso:: :attr:`Device.distance_model`");
static PyObject *
SequenceEntry_get_attenuation(SequenceEntry* self, void* nothing)
{
try
{
std::shared_ptr<aud::SequenceEntry>* entry = reinterpret_cast<std::shared_ptr<aud::SequenceEntry>*>(self->entry);
return Py_BuildValue("f", (*entry)->getAttenuation());
}
catch(Exception& e)
{
PyErr_SetString(AUDError, e.what());
return nullptr;
}
}
static int
SequenceEntry_set_attenuation(SequenceEntry* self, PyObject* args, void* nothing)
{
float factor;
if(!PyArg_Parse(args, "f:attenuation", &factor))
return -1;
try
{
std::shared_ptr<aud::SequenceEntry>* entry = reinterpret_cast<std::shared_ptr<aud::SequenceEntry>*>(self->entry);
(*entry)->setAttenuation(factor);
return 0;
}
catch(Exception& e)
{
PyErr_SetString(AUDError, e.what());
}
return -1;
}
PyDoc_STRVAR(M_aud_SequenceEntry_cone_angle_inner_doc,
"The opening angle of the inner cone of the source. If the cone "
"values of a source are set there are two (audible) cones with "
"the apex at the :attr:`location` of the source and with infinite "
"height, heading in the direction of the source's "
":attr:`orientation`.\n"
"In the inner cone the volume is normal. Outside the outer cone "
"the volume will be :attr:`cone_volume_outer` and in the area "
"between the volume will be interpolated linearly.");
static PyObject *
SequenceEntry_get_cone_angle_inner(SequenceEntry* self, void* nothing)
{
try
{
std::shared_ptr<aud::SequenceEntry>* entry = reinterpret_cast<std::shared_ptr<aud::SequenceEntry>*>(self->entry);
return Py_BuildValue("f", (*entry)->getConeAngleInner());
}
catch(Exception& e)
{
PyErr_SetString(AUDError, e.what());
return nullptr;
}
}
static int
SequenceEntry_set_cone_angle_inner(SequenceEntry* self, PyObject* args, void* nothing)
{
float angle;
if(!PyArg_Parse(args, "f:cone_angle_inner", &angle))
return -1;
try
{
std::shared_ptr<aud::SequenceEntry>* entry = reinterpret_cast<std::shared_ptr<aud::SequenceEntry>*>(self->entry);
(*entry)->setConeAngleInner(angle);
return 0;
}
catch(Exception& e)
{
PyErr_SetString(AUDError, e.what());
}
return -1;
}
PyDoc_STRVAR(M_aud_SequenceEntry_cone_angle_outer_doc,
"The opening angle of the outer cone of the source.\n\n"
".. seealso:: :attr:`cone_angle_inner`");
static PyObject *
SequenceEntry_get_cone_angle_outer(SequenceEntry* self, void* nothing)
{
try
{
std::shared_ptr<aud::SequenceEntry>* entry = reinterpret_cast<std::shared_ptr<aud::SequenceEntry>*>(self->entry);
return Py_BuildValue("f", (*entry)->getConeAngleOuter());
}
catch(Exception& e)
{
PyErr_SetString(AUDError, e.what());
return nullptr;
}
}
static int
SequenceEntry_set_cone_angle_outer(SequenceEntry* self, PyObject* args, void* nothing)
{
float angle;
if(!PyArg_Parse(args, "f:cone_angle_outer", &angle))
return -1;
try
{
std::shared_ptr<aud::SequenceEntry>* entry = reinterpret_cast<std::shared_ptr<aud::SequenceEntry>*>(self->entry);
(*entry)->setConeAngleOuter(angle);
return 0;
}
catch(Exception& e)
{
PyErr_SetString(AUDError, e.what());
}
return -1;
}
PyDoc_STRVAR(M_aud_SequenceEntry_cone_volume_outer_doc,
"The volume outside the outer cone of the source.\n\n"
".. seealso:: :attr:`cone_angle_inner`");
static PyObject *
SequenceEntry_get_cone_volume_outer(SequenceEntry* self, void* nothing)
{
try
{
std::shared_ptr<aud::SequenceEntry>* entry = reinterpret_cast<std::shared_ptr<aud::SequenceEntry>*>(self->entry);
return Py_BuildValue("f", (*entry)->getConeVolumeOuter());
}
catch(Exception& e)
{
PyErr_SetString(AUDError, e.what());
return nullptr;
}
}
static int
SequenceEntry_set_cone_volume_outer(SequenceEntry* self, PyObject* args, void* nothing)
{
float volume;
if(!PyArg_Parse(args, "f:cone_volume_outer", &volume))
return -1;
try
{
std::shared_ptr<aud::SequenceEntry>* entry = reinterpret_cast<std::shared_ptr<aud::SequenceEntry>*>(self->entry);
(*entry)->setConeVolumeOuter(volume);
return 0;
}
catch(Exception& e)
{
PyErr_SetString(AUDError, e.what());
}
return -1;
}
PyDoc_STRVAR(M_aud_SequenceEntry_distance_maximum_doc,
"The maximum distance of the source.\n"
"If the listener is further away the source volume will be 0.\n\n"
".. seealso:: :attr:`Device.distance_model`");
static PyObject *
SequenceEntry_get_distance_maximum(SequenceEntry* self, void* nothing)
{
try
{
std::shared_ptr<aud::SequenceEntry>* entry = reinterpret_cast<std::shared_ptr<aud::SequenceEntry>*>(self->entry);
return Py_BuildValue("f", (*entry)->getDistanceMaximum());
}
catch(Exception& e)
{
PyErr_SetString(AUDError, e.what());
return nullptr;
}
}
static int
SequenceEntry_set_distance_maximum(SequenceEntry* self, PyObject* args, void* nothing)
{
float distance;
if(!PyArg_Parse(args, "f:distance_maximum", &distance))
return -1;
try
{
std::shared_ptr<aud::SequenceEntry>* entry = reinterpret_cast<std::shared_ptr<aud::SequenceEntry>*>(self->entry);
(*entry)->setDistanceMaximum(distance);
return 0;
}
catch(Exception& e)
{
PyErr_SetString(AUDError, e.what());
}
return -1;
}
PyDoc_STRVAR(M_aud_SequenceEntry_distance_reference_doc,
"The reference distance of the source.\n"
"At this distance the volume will be exactly :attr:`volume`.\n\n"
".. seealso:: :attr:`Device.distance_model`");
static PyObject *
SequenceEntry_get_distance_reference(SequenceEntry* self, void* nothing)
{
try
{
std::shared_ptr<aud::SequenceEntry>* entry = reinterpret_cast<std::shared_ptr<aud::SequenceEntry>*>(self->entry);
return Py_BuildValue("f", (*entry)->getDistanceReference());
}
catch(Exception& e)
{
PyErr_SetString(AUDError, e.what());
return nullptr;
}
}
static int
SequenceEntry_set_distance_reference(SequenceEntry* self, PyObject* args, void* nothing)
{
float distance;
if(!PyArg_Parse(args, "f:distance_reference", &distance))
return -1;
try
{
std::shared_ptr<aud::SequenceEntry>* entry = reinterpret_cast<std::shared_ptr<aud::SequenceEntry>*>(self->entry);
(*entry)->setDistanceReference(distance);
return 0;
}
catch(Exception& e)
{
PyErr_SetString(AUDError, e.what());
}
return -1;
}
PyDoc_STRVAR(M_aud_SequenceEntry_muted_doc,
"Whether the entry is muted.\n");
static PyObject *
SequenceEntry_get_muted(SequenceEntry* self, void* nothing)
{
try
{
std::shared_ptr<aud::SequenceEntry>* entry = reinterpret_cast<std::shared_ptr<aud::SequenceEntry>*>(self->entry);
return PyBool_FromLong((long)(*entry)->isMuted());
}
catch(Exception& e)
{
PyErr_SetString(AUDError, e.what());
return nullptr;
}
}
static int
SequenceEntry_set_muted(SequenceEntry* self, PyObject* args, void* nothing)
{
if(!PyBool_Check(args))
{
PyErr_SetString(PyExc_TypeError, "muted is not a boolean!");
return -1;
}
bool muted = args == Py_True;
try
{
std::shared_ptr<aud::SequenceEntry>* entry = reinterpret_cast<std::shared_ptr<aud::SequenceEntry>*>(self->entry);
(*entry)->mute(muted);
return 0;
}
catch(Exception& e)
{
PyErr_SetString(AUDError, e.what());
}
return -1;
}
PyDoc_STRVAR(M_aud_SequenceEntry_relative_doc,
"Whether the source's location, velocity and orientation is relative or absolute to the listener.");
static PyObject *
SequenceEntry_get_relative(SequenceEntry* self, void* nothing)
{
try
{
std::shared_ptr<aud::SequenceEntry>* entry = reinterpret_cast<std::shared_ptr<aud::SequenceEntry>*>(self->entry);
return PyBool_FromLong((long)(*entry)->isRelative());
}
catch(Exception& e)
{
PyErr_SetString(AUDError, e.what());
}
return nullptr;
}
static int
SequenceEntry_set_relative(SequenceEntry* self, PyObject* args, void* nothing)
{
if(!PyBool_Check(args))
{
PyErr_SetString(PyExc_TypeError, "Value is not a boolean!");
return -1;
}
bool relative = (args == Py_True);
try
{
std::shared_ptr<aud::SequenceEntry>* entry = reinterpret_cast<std::shared_ptr<aud::SequenceEntry>*>(self->entry);
(*entry)->setRelative(relative);
return 0;
}
catch(Exception& e)
{
PyErr_SetString(AUDError, e.what());
}
return -1;
}
PyDoc_STRVAR(M_aud_SequenceEntry_sound_doc,
"The sound the entry is representing and will be played in the sequence.");
static PyObject *
SequenceEntry_get_sound(SequenceEntry* self, void* nothing)
{
try
{
std::shared_ptr<aud::SequenceEntry>* entry = reinterpret_cast<std::shared_ptr<aud::SequenceEntry>*>(self->entry);
Sound* object = (Sound*) Sound_empty();
if(object)
{
object->sound = new std::shared_ptr<ISound>((*entry)->getSound());
return (PyObject *) object;
}
}
catch(Exception& e)
{
PyErr_SetString(AUDError, e.what());
}
return nullptr;
}
static int
SequenceEntry_set_sound(SequenceEntry* self, PyObject* args, void* nothing)
{
Sound* sound = checkSound(args);
if(!sound)
return -1;
try
{
std::shared_ptr<aud::SequenceEntry>* entry = reinterpret_cast<std::shared_ptr<aud::SequenceEntry>*>(self->entry);
(*entry)->setSound(*reinterpret_cast<std::shared_ptr<ISound>*>(sound->sound));
return 0;
}
catch(Exception& e)
{
PyErr_SetString(AUDError, e.what());
}
return -1;
}
PyDoc_STRVAR(M_aud_SequenceEntry_volume_maximum_doc,
"The maximum volume of the source.\n\n"
".. seealso:: :attr:`Device.distance_model`");
static PyObject *
SequenceEntry_get_volume_maximum(SequenceEntry* self, void* nothing)
{
try
{
std::shared_ptr<aud::SequenceEntry>* entry = reinterpret_cast<std::shared_ptr<aud::SequenceEntry>*>(self->entry);
return Py_BuildValue("f", (*entry)->getVolumeMaximum());
}
catch(Exception& e)
{
PyErr_SetString(AUDError, e.what());
return nullptr;
}
}
static int
SequenceEntry_set_volume_maximum(SequenceEntry* self, PyObject* args, void* nothing)
{
float volume;
if(!PyArg_Parse(args, "f:volume_maximum", &volume))
return -1;
try
{
std::shared_ptr<aud::SequenceEntry>* entry = reinterpret_cast<std::shared_ptr<aud::SequenceEntry>*>(self->entry);
(*entry)->setVolumeMaximum(volume);
return 0;
}
catch(Exception& e)
{
PyErr_SetString(AUDError, e.what());
}
return -1;
}
PyDoc_STRVAR(M_aud_SequenceEntry_volume_minimum_doc,
"The minimum volume of the source.\n\n"
".. seealso:: :attr:`Device.distance_model`");
static PyObject *
SequenceEntry_get_volume_minimum(SequenceEntry* self, void* nothing)
{
try
{
std::shared_ptr<aud::SequenceEntry>* entry = reinterpret_cast<std::shared_ptr<aud::SequenceEntry>*>(self->entry);
return Py_BuildValue("f", (*entry)->getVolumeMinimum());
}
catch(Exception& e)
{
PyErr_SetString(AUDError, e.what());
return nullptr;
}
}
static int
SequenceEntry_set_volume_minimum(SequenceEntry* self, PyObject* args, void* nothing)
{
float volume;
if(!PyArg_Parse(args, "f:volume_minimum", &volume))
return -1;
try
{
std::shared_ptr<aud::SequenceEntry>* entry = reinterpret_cast<std::shared_ptr<aud::SequenceEntry>*>(self->entry);
(*entry)->setVolumeMinimum(volume);
return 0;
}
catch(Exception& e)
{
PyErr_SetString(AUDError, e.what());
}
return -1;
}
static PyGetSetDef SequenceEntry_properties[] = {
{(char*)"attenuation", (getter)SequenceEntry_get_attenuation, (setter)SequenceEntry_set_attenuation,
M_aud_SequenceEntry_attenuation_doc, nullptr },
{(char*)"cone_angle_inner", (getter)SequenceEntry_get_cone_angle_inner, (setter)SequenceEntry_set_cone_angle_inner,
M_aud_SequenceEntry_cone_angle_inner_doc, nullptr },
{(char*)"cone_angle_outer", (getter)SequenceEntry_get_cone_angle_outer, (setter)SequenceEntry_set_cone_angle_outer,
M_aud_SequenceEntry_cone_angle_outer_doc, nullptr },
{(char*)"cone_volume_outer", (getter)SequenceEntry_get_cone_volume_outer, (setter)SequenceEntry_set_cone_volume_outer,
M_aud_SequenceEntry_cone_volume_outer_doc, nullptr },
{(char*)"distance_maximum", (getter)SequenceEntry_get_distance_maximum, (setter)SequenceEntry_set_distance_maximum,
M_aud_SequenceEntry_distance_maximum_doc, nullptr },
{(char*)"distance_reference", (getter)SequenceEntry_get_distance_reference, (setter)SequenceEntry_set_distance_reference,
M_aud_SequenceEntry_distance_reference_doc, nullptr },
{(char*)"muted", (getter)SequenceEntry_get_muted, (setter)SequenceEntry_set_muted,
M_aud_SequenceEntry_muted_doc, nullptr },
{(char*)"relative", (getter)SequenceEntry_get_relative, (setter)SequenceEntry_set_relative,
M_aud_SequenceEntry_relative_doc, nullptr },
{(char*)"sound", (getter)SequenceEntry_get_sound, (setter)SequenceEntry_set_sound,
M_aud_SequenceEntry_sound_doc, nullptr },
{(char*)"volume_maximum", (getter)SequenceEntry_get_volume_maximum, (setter)SequenceEntry_set_volume_maximum,
M_aud_SequenceEntry_volume_maximum_doc, nullptr },
{(char*)"volume_minimum", (getter)SequenceEntry_get_volume_minimum, (setter)SequenceEntry_set_volume_minimum,
M_aud_SequenceEntry_volume_minimum_doc, nullptr },
{nullptr} /* Sentinel */
};
PyDoc_STRVAR(M_aud_SequenceEntry_doc,
"SequenceEntry objects represent an entry of a sequenced sound.");
static PyTypeObject SequenceEntryType = {
PyVarObject_HEAD_INIT(nullptr, 0)
"aud.SequenceEntry", /* tp_name */
sizeof(SequenceEntry), /* tp_basicsize */
0, /* tp_itemsize */
(destructor)SequenceEntry_dealloc, /* tp_dealloc */
0, /* tp_print */
0, /* tp_getattr */
0, /* tp_setattr */
0, /* tp_reserved */
0, /* tp_repr */
0, /* tp_as_number */
0, /* tp_as_sequence */
0, /* tp_as_mapping */
0, /* tp_hash */
0, /* tp_call */
0, /* tp_str */
0, /* tp_getattro */
0, /* tp_setattro */
0, /* tp_as_buffer */
Py_TPFLAGS_DEFAULT, /* tp_flags */
M_aud_SequenceEntry_doc, /* tp_doc */
0, /* tp_traverse */
0, /* tp_clear */
0, /* tp_richcompare */
0, /* tp_weaklistoffset */
0, /* tp_iter */
0, /* tp_iternext */
SequenceEntry_methods, /* tp_methods */
0, /* tp_members */
SequenceEntry_properties, /* tp_getset */
0, /* tp_base */
0, /* tp_dict */
0, /* tp_descr_get */
0, /* tp_descr_set */
0, /* tp_dictoffset */
0, /* tp_init */
0, /* tp_alloc */
0, /* tp_new */
};
AUD_API PyObject* SequenceEntry_empty()
{
return SequenceEntryType.tp_alloc(&SequenceEntryType, 0);
}
AUD_API SequenceEntry* checkSequenceEntry(PyObject* entry)
{
if(!PyObject_TypeCheck(entry, &SequenceEntryType))
{
PyErr_SetString(PyExc_TypeError, "Object is not of type SequenceEntry!");
return nullptr;
}
return (SequenceEntry*)entry;
}
bool initializeSequenceEntry()
{
return PyType_Ready(&SequenceEntryType) >= 0;
}
void addSequenceEntryToModule(PyObject* module)
{
Py_INCREF(&SequenceEntryType);
PyModule_AddObject(module, "SequenceEntry", (PyObject *)&SequenceEntryType);
}

View File

@@ -0,0 +1,33 @@
/*******************************************************************************
* Copyright 2009-2016 Jörg Müller
*
* 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.
******************************************************************************/
#pragma once
#include <Python.h>
#include "Audaspace.h"
typedef void Reference_SequenceEntry;
typedef struct {
PyObject_HEAD
Reference_SequenceEntry* entry;
} SequenceEntry;
extern AUD_API PyObject* SequenceEntry_empty();
extern AUD_API SequenceEntry* checkSequenceEntry(PyObject* entry);
bool initializeSequenceEntry();
void addSequenceEntryToModule(PyObject* module);

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,33 @@
/*******************************************************************************
* Copyright 2009-2016 Jörg Müller
*
* 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.
******************************************************************************/
#pragma once
#include <Python.h>
#include "Audaspace.h"
typedef void Reference_ISound;
typedef struct {
PyObject_HEAD
Reference_ISound* sound;
} Sound;
extern AUD_API PyObject* Sound_empty();
extern AUD_API Sound* checkSound(PyObject* sound);
bool initializeSound();
void addSoundToModule(PyObject* module);

View File

@@ -0,0 +1,260 @@
/*******************************************************************************
* Copyright 2009-2015 Juan Francisco Crespo Galán
*
* 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 "PySource.h"
#include "Exception.h"
#include "fx/Source.h"
#include <memory>
extern PyObject* AUDError;
static PyObject *
Source_new(PyTypeObject* type, PyObject* args, PyObject* kwds)
{
SourceP* self = (SourceP*)type->tp_alloc(type, 0);
if(self != nullptr)
{
float azimuth, elevation, distance;
if(!PyArg_ParseTuple(args, "fff:angles", &azimuth, &elevation, &distance))
return nullptr;
try
{
self->source = new std::shared_ptr<aud::Source>(new aud::Source(azimuth, elevation, distance));
}
catch(aud::Exception& e)
{
Py_DECREF(self);
PyErr_SetString(AUDError, e.what());
return nullptr;
}
}
return (PyObject *)self;
}
static void
Source_dealloc(SourceP* self)
{
if(self->source)
delete reinterpret_cast<std::shared_ptr<aud::Source>*>(self->source);
Py_TYPE(self)->tp_free((PyObject *)self);
}
static PyMethodDef Source_methods[] = {
{ nullptr } /* Sentinel */
};
PyDoc_STRVAR(M_aud_Source_azimuth_doc,
"The azimuth angle.");
static int
Source_set_azimuth(SourceP* self, PyObject* args, void* nothing)
{
float azimuth;
if(!PyArg_Parse(args, "f:azimuth", &azimuth))
return -1;
try
{
(*reinterpret_cast<std::shared_ptr<aud::Source>*>(self->source))->setAzimuth(azimuth);
return 0;
}
catch(aud::Exception& e)
{
PyErr_SetString(AUDError, e.what());
}
return -1;
}
static PyObject *
Source_get_azimuth(SourceP* self, void* nothing)
{
try
{
return Py_BuildValue("f", (*reinterpret_cast<std::shared_ptr<aud::Source>*>(self->source))->getAzimuth());
}
catch(aud::Exception& e)
{
PyErr_SetString(AUDError, e.what());
return nullptr;
}
}
PyDoc_STRVAR(M_aud_Source_elevation_doc,
"The elevation angle.");
static int
Source_set_elevation(SourceP* self, PyObject* args, void* nothing)
{
float elevation;
if(!PyArg_Parse(args, "f:elevation", &elevation))
return -1;
try
{
(*reinterpret_cast<std::shared_ptr<aud::Source>*>(self->source))->setElevation(elevation);
return 0;
}
catch(aud::Exception& e)
{
PyErr_SetString(AUDError, e.what());
}
return -1;
}
static PyObject *
Source_get_elevation(SourceP* self, void* nothing)
{
try
{
return Py_BuildValue("f", (*reinterpret_cast<std::shared_ptr<aud::Source>*>(self->source))->getElevation());
}
catch(aud::Exception& e)
{
PyErr_SetString(AUDError, e.what());
return nullptr;
}
}
PyDoc_STRVAR(M_aud_Source_distance_doc,
"The distance value. 0 is min, 1 is max.");
static int
Source_set_distance(SourceP* self, PyObject* args, void* nothing)
{
float distance;
if(!PyArg_Parse(args, "f:distance", &distance))
return -1;
try
{
(*reinterpret_cast<std::shared_ptr<aud::Source>*>(self->source))->setDistance(distance);
return 0;
}
catch(aud::Exception& e)
{
PyErr_SetString(AUDError, e.what());
}
return -1;
}
static PyObject *
Source_get_distance(SourceP* self, void* nothing)
{
try
{
return Py_BuildValue("f", (*reinterpret_cast<std::shared_ptr<aud::Source>*>(self->source))->getDistance());
}
catch(aud::Exception& e)
{
PyErr_SetString(AUDError, e.what());
return nullptr;
}
}
static PyGetSetDef Source_properties[] = {
{ (char*)"azimuth", (getter)Source_get_azimuth, (setter)Source_set_azimuth,
M_aud_Source_azimuth_doc, nullptr },
{ (char*)"elevation", (getter)Source_get_elevation, (setter)Source_set_elevation,
M_aud_Source_elevation_doc, nullptr },
{ (char*)"distance", (getter)Source_get_distance, (setter)Source_set_distance,
M_aud_Source_distance_doc, nullptr },
{ nullptr } /* Sentinel */
};
PyDoc_STRVAR(M_aud_Source_doc,
"The source object represents the source position of a binaural sound.");
PyTypeObject SourceType = {
PyVarObject_HEAD_INIT(nullptr, 0)
"aud.Source", /* tp_name */
sizeof(SourceP), /* tp_basicsize */
0, /* tp_itemsize */
(destructor)Source_dealloc, /* tp_dealloc */
0, /* tp_print */
0, /* tp_getattr */
0, /* tp_setattr */
0, /* tp_reserved */
0, /* tp_repr */
0, /* tp_as_number */
0, /* tp_as_sequence */
0, /* tp_as_mapping */
0, /* tp_hash */
0, /* tp_call */
0, /* tp_str */
0, /* tp_getattro */
0, /* tp_setattro */
0, /* tp_as_buffer */
Py_TPFLAGS_DEFAULT, /* tp_flags */
M_aud_Source_doc, /* tp_doc */
0, /* tp_traverse */
0, /* tp_clear */
0, /* tp_richcompare */
0, /* tp_weaklistoffset */
0, /* tp_iter */
0, /* tp_iternext */
Source_methods, /* tp_methods */
0, /* tp_members */
Source_properties, /* tp_getset */
0, /* tp_base */
0, /* tp_dict */
0, /* tp_descr_get */
0, /* tp_descr_set */
0, /* tp_dictoffset */
0, /* tp_init */
0, /* tp_alloc */
Source_new, /* tp_new */
};
AUD_API PyObject* Source_empty()
{
return SourceType.tp_alloc(&SourceType, 0);
}
AUD_API SourceP* checkSource(PyObject* source)
{
if(!PyObject_TypeCheck(source, &SourceType))
{
PyErr_SetString(PyExc_TypeError, "Object is not of type Source!");
return nullptr;
}
return (SourceP*)source;
}
bool initializeSource()
{
return PyType_Ready(&SourceType) >= 0;
}
void addSourceToModule(PyObject* module)
{
Py_INCREF(&SourceType);
PyModule_AddObject(module, "Source", (PyObject *)&SourceType);
}

View File

@@ -0,0 +1,33 @@
/*******************************************************************************
* Copyright 2009-2015 Juan Francisco Crespo Galán
*
* 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.
******************************************************************************/
#pragma once
#include <Python.h>
#include "Audaspace.h"
typedef void Reference_Source;
typedef struct {
PyObject_HEAD
Reference_Source* source;
} SourceP;
extern AUD_API PyObject* Source_empty();
extern AUD_API SourceP* checkSource(PyObject* source);
bool initializeSource();
void addSourceToModule(PyObject* module);

View File

@@ -0,0 +1,134 @@
/*******************************************************************************
* Copyright 2009-2015 Juan Francisco Crespo Galán
*
* 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 "PyThreadPool.h"
#include "Exception.h"
#include "util/ThreadPool.h"
extern PyObject* AUDError;
static PyObject *
ThreadPool_new(PyTypeObject* type, PyObject* args, PyObject* kwds)
{
ThreadPoolP* self = (ThreadPoolP*)type->tp_alloc(type, 0);
if(self != nullptr)
{
unsigned int nThreads;
if(!PyArg_ParseTuple(args, "I:nThreads", &nThreads))
return nullptr;
try
{
self->threadPool = new std::shared_ptr<aud::ThreadPool>(new aud::ThreadPool(nThreads));
}
catch(aud::Exception& e)
{
Py_DECREF(self);
PyErr_SetString(AUDError, e.what());
return nullptr;
}
}
return (PyObject *)self;
}
static void
ThreadPool_dealloc(ThreadPoolP* self)
{
if(self->threadPool)
delete reinterpret_cast<std::shared_ptr<aud::ThreadPool>*>(self->threadPool);
Py_TYPE(self)->tp_free((PyObject *)self);
}
static PyMethodDef ThreadPool_methods[] = {
{ nullptr } /* Sentinel */
};
PyDoc_STRVAR(M_aud_ThreadPool_doc,
"A ThreadPool is used to parallelize convolution efficiently.");
PyTypeObject ThreadPoolType = {
PyVarObject_HEAD_INIT(nullptr, 0)
"aud.ThreadPool", /* tp_name */
sizeof(ThreadPoolP), /* tp_basicsize */
0, /* tp_itemsize */
(destructor)ThreadPool_dealloc, /* tp_dealloc */
0, /* tp_print */
0, /* tp_getattr */
0, /* tp_setattr */
0, /* tp_reserved */
0, /* tp_repr */
0, /* tp_as_number */
0, /* tp_as_sequence */
0, /* tp_as_mapping */
0, /* tp_hash */
0, /* tp_call */
0, /* tp_str */
0, /* tp_getattro */
0, /* tp_setattro */
0, /* tp_as_buffer */
Py_TPFLAGS_DEFAULT, /* tp_flags */
M_aud_ThreadPool_doc, /* tp_doc */
0, /* tp_traverse */
0, /* tp_clear */
0, /* tp_richcompare */
0, /* tp_weaklistoffset */
0, /* tp_iter */
0, /* tp_iternext */
ThreadPool_methods, /* tp_methods */
0, /* tp_members */
0, /* tp_getset */
0, /* tp_base */
0, /* tp_dict */
0, /* tp_descr_get */
0, /* tp_descr_set */
0, /* tp_dictoffset */
0, /* tp_init */
0, /* tp_alloc */
ThreadPool_new, /* tp_new */
};
AUD_API PyObject* ThreadPool_empty()
{
return ThreadPoolType.tp_alloc(&ThreadPoolType, 0);
}
AUD_API ThreadPoolP* checkThreadPool(PyObject* threadPool)
{
if(!PyObject_TypeCheck(threadPool, &ThreadPoolType))
{
PyErr_SetString(PyExc_TypeError, "Object is not of type ThreadPool!");
return nullptr;
}
return (ThreadPoolP*)threadPool;
}
bool initializeThreadPool()
{
return PyType_Ready(&ThreadPoolType) >= 0;
}
void addThreadPoolToModule(PyObject* module)
{
Py_INCREF(&ThreadPoolType);
PyModule_AddObject(module, "ThreadPool", (PyObject *)&ThreadPoolType);
}

View File

@@ -0,0 +1,33 @@
/*******************************************************************************
* Copyright 2009-2015 Juan Francisco Crespo Galán
*
* 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.
******************************************************************************/
#pragma once
#include <Python.h>
#include "Audaspace.h"
typedef void Reference_ThreadPool;
typedef struct {
PyObject_HEAD
Reference_ThreadPool* threadPool;
} ThreadPoolP;
extern AUD_API PyObject* ThreadPool_empty();
extern AUD_API ThreadPoolP* checkThreadPool(PyObject* ThreadPool);
bool initializeThreadPool();
void addThreadPoolToModule(PyObject* module);

View File

@@ -0,0 +1,13 @@
#!/usr/bin/python
import aud, sys, time, multiprocessing
device = aud.Device()
hrtf = aud.HRTF().loadLeftHrtfSet(".wav", sys.argv[2])
threadPool = aud.ThreadPool(multiprocessing.cpu_count())
source = aud.Source(0, 0, 0)
sound = aud.Sound.file(sys.argv[1]).rechannel(1).binaural(hrtf, source, threadPool)
handle = device.play(sound)
while handle.status:
source.azimuth += 1
print("Azimuth: " + str(source.azimuth))
time.sleep(0.1)

View File

@@ -0,0 +1,10 @@
#!/usr/bin/python
import aud, sys, time, multiprocessing
device = aud.Device()
ir = aud.ImpulseResponse(aud.Sound.file(sys.argv[2]))
threadPool = aud.ThreadPool(multiprocessing.cpu_count())
sound = aud.Sound.file(sys.argv[1]).convolver(ir, threadPool)
handle = device.play(sound)
handle.volume = 0.1
while handle.status:
time.sleep(0.1)

View File

@@ -0,0 +1,20 @@
import aud, sys, time
device=aud.Device()
dMusic = aud.DynamicMusic(device)
sound1 = aud.Sound.file(sys.argv[1])
sound2 = aud.Sound.file(sys.argv[2])
effect = aud.Sound.file(sys.argv[3])
dMusic.addScene(sound1)
dMusic.addScene(sound2)
dMusic.addTransition(1,2,effect)
dMusic.fadeTime=3
dMusic.volume=0.5
dMusic.scene=1
time.sleep(5)
dMusic.scene=2
time.sleep(500)

View File

@@ -0,0 +1,27 @@
import aud, sys, time
device=aud.Device()
manager = aud.PlaybackManager(device)
sound1 = aud.Sound.file(sys.argv[1])
sound2 = aud.Sound.file(sys.argv[2])
sound3 = aud.Sound.file(sys.argv[3])
sound4 = aud.Sound.file(sys.argv[4])
manager.play(sound1, 0)
manager.play(sound2, 0)
manager.play(sound3, 1)
manager.play(sound4, 1)
manager.setVolume(0.2, 0)
time.sleep(5)
manager.setVolume(0.0, 1)
time.sleep(5)
manager.pause(0)
time.sleep(5)
manager.setVolume(0.5, 1)
manager.setVolume(1.0, 0)
time.sleep(5)
manager.stop(1)
manager.resume(0)
time.sleep(500)

View File

@@ -0,0 +1,7 @@
#!/usr/bin/python
import aud, sys, time
device = aud.Device()
sound = aud.Sound.file(sys.argv[1])
handle = device.play(sound)
while handle.status:
time.sleep(0.1)

View File

@@ -0,0 +1,21 @@
import aud, sys, time
device=aud.Device()
sound1 = aud.Sound.file(sys.argv[1])
sound2 = aud.Sound.file(sys.argv[2])
sound3 = aud.Sound.file(sys.argv[3])
sound4 = aud.Sound.file(sys.argv[4])
list=aud.Sound.list(True)
list.addSound(sound1)
list.addSound(sound2)
list.addSound(sound3)
list.addSound(sound4)
mutable=aud.Sound.mutable(list)
device.lock()
handle=device.play(mutable)
handle.loop_count=2
device.unlock()
time.sleep(500)

View File

@@ -0,0 +1,7 @@
#!/usr/bin/python
import aud, time
device = aud.Device()
sine = aud.Sound.sine(440)
square = sine.threshold()
handle = device.play(square)
time.sleep(3)

View File

@@ -0,0 +1,19 @@
#!/usr/bin/python
import aud, math, time
length = 0.5
fadelength = 0.05
device = aud.Device()
high = aud.Sound.sine(880).limit(0, length).fadein(0, fadelength).fadeout(length - fadelength, length)
low = aud.Sound.sine(700).limit(0, length).fadein(0, fadelength).fadeout(length - fadelength, length).volume(0.6)
sound = high.join(low)
handle = device.play(sound)
handle.loop_count = -1
start = time.time()
while time.time() - start < 10:
angle = time.time() - start
handle.location = [math.sin(angle), 0, -math.cos(angle)]

View File

@@ -0,0 +1,23 @@
#!/usr/bin/python
import aud, math, time
length = 0.5
fadelength = 0.05
runtime = 10
distance = 100
velocity = 2 * distance / runtime
device = aud.Device()
high = aud.Sound.sine(880).limit(0, length).fadein(0, fadelength).fadeout(length - fadelength, length)
low = aud.Sound.sine(700).limit(0, length).fadein(0, fadelength).fadeout(length - fadelength, length).volume(0.6)
sound = high.join(low)
handle = device.play(sound)
handle.loop_count = -1
handle.velocity = [velocity, 0, 0]
start = time.time()
while time.time() - start < runtime:
location = -distance + velocity * (time.time() - start)
handle.location = [location, 10, 0]

View File

@@ -0,0 +1,66 @@
#!/usr/bin/python
import aud, math, time
def parseNotes(notes, bpm, basefreq, rate = 44100,
notechars = "XXXCXDXEFXGXAXHcXdXefXgXaXhp"):
pos = 0
fadelength = 60/bpm/10
halfchars = "#b"
durationchars = "2345678"
sound = None
while pos < len(notes):
char = notes[pos]
mod = None
dur = 1
pos += 1
while pos < len(notes) and notes[pos] not in notechars:
if notes[pos] in halfchars:
mod = notes[pos]
elif notes[pos] in durationchars:
dur = notes[pos]
pos += 1
freq = notechars.find(char)
if mod == '#':
freq += 1
elif mod == 'b':
freq -= 1
freq = math.pow(2, freq/12)*basefreq
length = float(dur)*60/bpm
snd = aud.Sound.square(freq, rate)
if char == 'p':
snd = snd.volume(0)
snd = snd.limit(0, length)
snd = snd.fadein(0, fadelength)
snd = snd.fadeout(length - fadelength, fadelength)
if sound:
sound = sound.join(snd)
else:
sound = snd
return sound
def tetris(bpm = 300, freq = 220, rate = 44100):
notes = "e2Hcd2cH A2Ace2dc H3cd2e2 c2A2A4 pd2fa2gf e3ce2dc H2Hcd2e2 c2A2A2p2"
s11 = parseNotes(notes, bpm, freq, rate)
notes = "e4c4 d4H4 c4A4 G#4p4 e4c4 d4H4 A2c2a4 g#4p4"
s12 = parseNotes(notes, bpm, freq, rate)
notes = "EeEeEeEe AaAaAaAa AbabAbabAbabAbab AaAaAAHC DdDdDdDd CcCcCcCc HhHhHhHh AaAaA2p2"
s21 = parseNotes(notes, bpm, freq, rate, notechars = "AXHCXDXEFXGXaXhcXdXefXgXp")
notes = "aeaeaeae g#dg#dg#dg#d aeaeaeae g#dg#dg#2p2 aeaeaeae g#dg#dg#dg#d aeaeaeae g#dg#dg#2p2"
s22 = parseNotes(notes, bpm, freq/2, rate)
return s11.join(s12).join(s11).volume(0.5).mix(s21.join(s22).join(s21).volume(0.3))
if __name__ == "__main__":
dev = aud.Device()
handle = dev.play(tetris(300, 220, dev.rate))
while handle.status:
time.sleep(0.1)

View File

@@ -0,0 +1,64 @@
#!/usr/bin/python
import aud, math, time
def parseNotes(notes, bpm, basefreq, rate = 44100,
notechars = "XXXCXDXEFXGXAXHcXdXefXgXaXhp"):
pos = 0
fadelength = 60/bpm/10
halfchars = "#b"
durationchars = "2345678"
position = 0
sequence = aud.Sequence()
while pos < len(notes):
char = notes[pos]
mod = None
dur = 1
pos += 1
while pos < len(notes) and notes[pos] not in notechars:
if notes[pos] in halfchars:
mod = notes[pos]
elif notes[pos] in durationchars:
dur = notes[pos]
pos += 1
freq = notechars.find(char)
if mod == '#':
freq += 1
elif mod == 'b':
freq -= 1
freq = math.pow(2, freq/12)*basefreq
length = float(dur)*60/bpm
note = aud.Sound.square(freq, rate).fadein(0, fadelength).fadeout(length - fadelength, fadelength)
entry = sequence.add(note, position, position + length, 0)
if char == 'p':
entry.muted = True
position += length
return sequence.limit(0, position)
def tetris(bpm = 300, freq = 220, rate = 44100):
notes = "e2Hcd2cH A2Ace2dc H3cd2e2 c2A2A4 pd2fa2gf e3ce2dc H2Hcd2e2 c2A2A2p2"
s11 = parseNotes(notes, bpm, freq, rate)
notes = "e4c4 d4H4 c4A4 G#4p4 e4c4 d4H4 A2c2a4 g#4p4"
s12 = parseNotes(notes, bpm, freq, rate)
notes = "EeEeEeEe AaAaAaAa AbabAbabAbabAbab AaAaAAHC DdDdDdDd CcCcCcCc HhHhHhHh AaAaA2p2"
s21 = parseNotes(notes, bpm, freq, rate, notechars = "AXHCXDXEFXGXaXhcXdXefXgXp")
notes = "aeaeaeae g#dg#dg#dg#d aeaeaeae g#dg#dg#2p2 aeaeaeae g#dg#dg#dg#d aeaeaeae g#dg#dg#2p2"
s22 = parseNotes(notes, bpm, freq/2, rate)
return s11.join(s12).join(s11).volume(0.5).mix(s21.join(s22).join(s21).volume(0.3))
if __name__ == "__main__":
dev = aud.Device()
handle = dev.play(tetris(300, 220, dev.rate))
while handle.status:
time.sleep(0.1)

View File

@@ -0,0 +1,63 @@
#!/usr/bin/python
import aud, math, time
def parseNotes(notes, bpm, basefreq, rate = 44100,
notechars = "XXXCXDXEFXGXAXHcXdXefXgXaXhp"):
pos = 0
fadelength = 60/bpm/10
halfchars = "#b"
durationchars = "2345678"
position = 0
sequence = aud.Sequence()
while pos < len(notes):
char = notes[pos]
mod = None
dur = 1
pos += 1
while pos < len(notes) and notes[pos] not in notechars:
if notes[pos] in halfchars:
mod = notes[pos]
elif notes[pos] in durationchars:
dur = notes[pos]
pos += 1
freq = notechars.find(char)
if mod == '#':
freq += 1
elif mod == 'b':
freq -= 1
freq = math.pow(2, freq/12)*basefreq
length = float(dur)*60/bpm
if char != 'p':
note = aud.Sound.square(freq, rate).fadein(0, fadelength).fadeout(length - fadelength, fadelength)
sequence.add(note, position, position + length, 0)
position += length
return sequence.limit(0, position)
def tetris(bpm = 300, freq = 220, rate = 44100):
notes = "e2Hcd2cH A2Ace2dc H3cd2e2 c2A2A4 pd2fa2gf e3ce2dc H2Hcd2e2 c2A2A2p2"
s11 = parseNotes(notes, bpm, freq, rate)
notes = "e4c4 d4H4 c4A4 G#4p4 e4c4 d4H4 A2c2a4 g#4p4"
s12 = parseNotes(notes, bpm, freq, rate)
notes = "EeEeEeEe AaAaAaAa AbabAbabAbabAbab AaAaAAHC DdDdDdDd CcCcCcCc HhHhHhHh AaAaA2p2"
s21 = parseNotes(notes, bpm, freq, rate, notechars = "AXHCXDXEFXGXaXhcXdXefXgXp")
notes = "aeaeaeae g#dg#dg#dg#d aeaeaeae g#dg#dg#2p2 aeaeaeae g#dg#dg#dg#d aeaeaeae g#dg#dg#2p2"
s22 = parseNotes(notes, bpm, freq/2, rate)
return s11.join(s12).join(s11).volume(0.5).mix(s21.join(s22).join(s21).volume(0.3))
if __name__ == "__main__":
dev = aud.Device()
handle = dev.play(tetris(300, 220, dev.rate))
while handle.status:
time.sleep(0.1)

View File

@@ -0,0 +1,61 @@
# -*- coding: utf-8 -*-
import sys
import os
import codecs
import numpy
from distutils.core import setup, Extension
if len(sys.argv) > 2 and sys.argv[1] == '--build-docs':
import subprocess
from distutils.core import Distribution
from distutils.command.build import build
dist = Distribution()
cmd = build(dist)
cmd.finalize_options()
#print(cmd.build_platlib)
os.environ['PYTHONPATH'] = os.path.join(os.getcwd(), cmd.build_platlib)
os.environ['LD_LIBRARY_PATH'] = os.getcwd()
ret = subprocess.call(sys.argv[2:])
sys.exit(ret)
# the following line is not working due to https://bugs.python.org/issue9023
#source_directory = os.path.relpath('@PYTHON_SOURCE_DIRECTORY@')
source_directory = '@PYTHON_SOURCE_DIRECTORY@'
extra_args = []
if sys.platform == 'win32':
extra_args.append('/EHsc')
extra_args.append('/DAUD_BUILD_SHARED_LIBRARY')
else:
extra_args.append('-std=c++11')
audaspace = Extension(
'aud',
include_dirs = ['@CMAKE_CURRENT_BINARY_DIR@', '@FFTW_INCLUDE_DIR@', os.path.join(source_directory, '../../include'), numpy.get_include()],
libraries = ['audaspace'],
library_dirs = ['.', 'Release', 'Debug'],
language = 'c++',
extra_compile_args = extra_args,
sources = [os.path.join(source_directory, file) for file in ['PyAPI.cpp', 'PyDevice.cpp', 'PyHandle.cpp', 'PySound.cpp', 'PySequenceEntry.cpp', 'PySequence.cpp', 'PyPlaybackManager.cpp', 'PyDynamicMusic.cpp', 'PyThreadPool.cpp', 'PySource.cpp'] + (['PyImpulseResponse.cpp', 'PyHRTF.cpp'] if '@WITH_FFTW@' == 'ON' else [])]
)
setup(
name = 'audaspace',
version = '@AUDASPACE_LONG_VERSION@',
description = 'Audaspace is a high level audio library.',
author = 'Jörg Müller',
author_email = 'nexyon@gmail.com',
url = 'https://github.com/audaspace/audaspace',
license = 'Apache License 2.0',
long_description = codecs.open(os.path.join(source_directory, '../../README.md'), 'r', 'utf-8').read(),
ext_modules = [audaspace],
headers = [os.path.join(source_directory, file) for file in ['PyAPI.h', 'PyDevice.h', 'PyHandle.h', 'PySound.h', 'PySequenceEntry.h', 'PySequence.h', 'PyPlaybackManager.h', 'PyDynamicMusic.h', 'PyThreadPool.h', 'PySource.h'] + (['PyImpulseResponse.h', 'PyHRTF.h'] if '@WITH_FFTW@' == 'ON' else [])] + ['Audaspace.h']
)

26
extern/audaspace/blender_config.cmake vendored Normal file
View File

@@ -0,0 +1,26 @@
set(AUDASPACE_STANDALONE FALSE)
set(BUILD_DEMOS FALSE)
set(SHARED_LIBRARY FALSE)
set(WITH_C TRUE)
set(WITH_DOCS FALSE)
set(WITH_FFMPEG ${WITH_CODEC_FFMPEG})
set(WITH_FFTW FALSE)
set(WITH_LIBSNDFILE ${WITH_CODEC_SNDFILE})
set(SEPARATE_C FALSE)
set(PLUGIN_FFMPEG FALSE)
set(PLUGIN_JACK FALSE)
set(PLUGIN_LIBSNDFILE FALSE)
set(PLUGIN_OPENAL FALSE)
set(PLUGIN_SDL FALSE)
set(WITH_PYTHON_MODULE FALSE)
set(DYNLOAD_JACK ${WITH_JACK_DYNLOAD})
set(WITH_BINDING_DOCS FALSE)
set(BLENDER_AUDASPACE TRUE)
set(FFMPEG_FOUND ${WITH_CODEC_FFMPEG})
set(JACK_FOUND ${WITH_JACK})
set(LIBSNDFILE_FOUND ${WITH_CODEC_SNDFILE})
set(OPENAL_FOUND ${WITH_OPENAL})
set(PYTHONLIBS_FOUND TRUE)
set(NUMPY_FOUND TRUE)
set(NUMPY_INCLUDE_DIRS ${PYTHON_NUMPY_INCLUDE_DIRS})
set(SDL_FOUND ${WITH_SDL})

131
extern/audaspace/config/Audaspace.h.in vendored Normal file
View File

@@ -0,0 +1,131 @@
/*******************************************************************************
* Copyright 2009-2016 Jörg Müller
*
* 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.
******************************************************************************/
#pragma once
/**
* @file Audaspace.h
* @ingroup general
* The main header file of the library defining the namespace and basic data types.
*/
/**
* \def AUD_API
* Used for exporting symbols in the shared library.
*/
/**
* \def AUD_PLUGIN_API
* Used for exporting symbols in the shared library.
*/
/**
* \def AUD_EXPORT_API
* Used for using exporting symbols of the shared library.
*/
/**
* \def AUD_USE_API
* Used for using exporting symbols of the shared library.
*/
/**
* \def AUD_LOCAL
* Used for hiding symbols from export in the shared library.
*/
// the following two defines and undefines are a hack to silence an error by doxygen
/**
* \def AUD_SHARED_LIBRARY
* Defined when audaspace was built as a shared library.
*/
#define AUD_SHARED_LIBRARY
#undef AUD_SHARED_LIBRARY
/**
* \def AUD_STATIC_LIBRARY
* Defined when audaspace was built as a static library.
*/
#define AUD_STATIC_LIBRARY
#undef AUD_STATIC_LIBRARY
#define @AUD_LIBRARY_TYPE@
#ifdef _MSC_VER
#define AUD_EXPORT_API __declspec(dllexport)
#define AUD_USE_API __declspec(dllimport)
#define AUD_LOCAL
#else
#ifdef __GNUC__
#define AUD_EXPORT_API __attribute__((visibility ("default")))
#define AUD_USE_API AUD_EXPORT_API
#define AUD_LOCAL __attribute__((visibility ("hidden")))
#else
#define AUD_EXPORT_API
#define AUD_USE_API
#define AUD_LOCAL
#endif
#endif
#ifdef AUD_SHARED_LIBRARY
#ifdef AUD_BUILD_PLUGIN
#define AUD_API AUD_USE_API
#define AUD_PLUGIN_API AUD_EXPORT_API
#else
#ifdef AUD_BUILD_SHARED_LIBRARY
#define AUD_API AUD_EXPORT_API
#define AUD_PLUGIN_API AUD_EXPORT_API
#else
#define AUD_API AUD_USE_API
#define AUD_PLUGIN_API AUD_USE_API
#endif
#endif
#else
#define AUD_API
#define AUD_PLUGIN_API
#endif
/// The default playback buffer size of a device.
#define AUD_DEFAULT_BUFFER_SIZE 1024
#ifdef __cplusplus
/// Opens the audaspace namespace aud.
#define AUD_NAMESPACE_BEGIN namespace aud {
/// Closes the audaspace namespace aud.
#define AUD_NAMESPACE_END }
#else
/// Opens the audaspace namespace aud.
#define AUD_NAMESPACE_BEGIN
/// Closes the audaspace namespace aud.
#define AUD_NAMESPACE_END
#endif
AUD_NAMESPACE_BEGIN
/// Sample type.(float samples)
typedef float sample_t;
/// Sample data type (format samples)
typedef unsigned char data_t;
AUD_NAMESPACE_END

185
extern/audaspace/include/Exception.h vendored Normal file
View File

@@ -0,0 +1,185 @@
/*******************************************************************************
* Copyright 2009-2016 Jörg Müller
*
* 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.
******************************************************************************/
#pragma once
/**
* \def AUD_NOEXCEPT
* Compatibility macro for noexcept.
*/
#ifdef _MSC_VER
#define AUD_NOEXCEPT
#else
#define AUD_NOEXCEPT noexcept
#endif
/**
* @file Exception.h
* @ingroup general
* Defines the Exception class as well as the AUD_THROW macro for easy throwing.
*/
#include "Audaspace.h"
#include <exception>
#include <string>
/// Throws a Exception with the provided error code.
#define AUD_THROW(exception, message) { throw exception(message, __FILE__, __LINE__); }
AUD_NAMESPACE_BEGIN
/**
* The Exception class is the general exception base class.
*/
class AUD_API Exception : public std::exception
{
protected:
/// A message describing the problem.
const std::string m_message;
/// The source code file in which the exception was thrown.
const std::string m_file;
/// The source code line from which the exception was thrown.
const int m_line;
/**
* Copy constructor.
* @param exception The exception to be copied.
*/
Exception(const Exception& exception);
/**
* Creates a new Exception object.
* @param message A message describing the problem.
* @param file The source code file in which the exception was thrown.
* @param line The source code line from which the exception was thrown.
*/
Exception(std::string message, std::string file, int line);
public:
/**
* Destroys the object.
*/
virtual ~Exception() AUD_NOEXCEPT;
/**
* Returns the error message.
* @return A C string error message.
*/
virtual const char* what() const AUD_NOEXCEPT;
/**
* Returns the error message plus file and line number for debugging purposes.
* @return The error message including debug information.
*/
virtual std::string getDebugMessage() const;
/**
* Returns the error message.
* @return The error message as string.
*/
const std::string& getMessage() const;
/**
* Returns the file in which the exception was thrown.
* @return The name of the file in which the exception was thrown.
*/
const std::string& getFile() const;
/**
* Returns the line where the exception was originally thrown.
* @return The line of the source file where the exception was generated.
*/
int getLine() const;
};
/**
* The FileException class is used for error cases in which files cannot
* be read or written due to unknown containers or codecs.
*/
class AUD_API FileException : public Exception
{
public:
/**
* Creates a new FileException object.
* @param message A message describing the problem.
* @param file The source code file in which the exception was thrown.
* @param line The source code line from which the exception was thrown.
*/
FileException(std::string message, std::string file, int line);
/**
* Copy constructor.
* @param exception The exception to be copied.
*/
FileException(const FileException& exception);
~FileException() AUD_NOEXCEPT;
};
/**
* The DeviceException class is used for error cases in connection with
* devices, which usually happens when specific features or requests
* cannot be fulfilled by a device, for example when the device is opened.
*/
class AUD_API DeviceException : public Exception
{
public:
/**
* Creates a new DeviceException object.
* @param message A message describing the problem.
* @param file The source code file in which the exception was thrown.
* @param line The source code line from which the exception was thrown.
*/
DeviceException(std::string message, std::string file, int line);
/**
* Copy constructor.
* @param exception The exception to be copied.
*/
DeviceException(const DeviceException& exception);
~DeviceException() AUD_NOEXCEPT;
};
/**
* The StateException class is used for error cases of sounds or readers
* with illegal states or requirements for states of dependent classes.
* It is used for example when an effect reader needs a specific
* specification from its input.
*/
class AUD_API StateException : public Exception
{
public:
/**
* Creates a new StateException object.
* @param message A message describing the problem.
* @param file The source code file in which the exception was thrown.
* @param line The source code line from which the exception was thrown.
*/
StateException(std::string message, std::string file, int line);
/**
* Copy constructor.
* @param exception The exception to be copied.
*/
StateException(const StateException& exception);
~StateException() AUD_NOEXCEPT;
};
AUD_NAMESPACE_END

View File

@@ -1,48 +1,43 @@
/* /*******************************************************************************
* ***** BEGIN GPL LICENSE BLOCK ***** * Copyright 2009-2016 Jörg Müller
* *
* Copyright 2009-2011 Jörg Hermann Müller * 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
* *
* This file is part of AudaSpace. * http://www.apache.org/licenses/LICENSE-2.0
* *
* Audaspace is free software; you can redistribute it and/or modify * Unless required by applicable law or agreed to in writing, software
* it under the terms of the GNU General Public License as published by * distributed under the License is distributed on an "AS IS" BASIS,
* the Free Software Foundation; either version 2 of the License, or * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* (at your option) any later version. * See the License for the specific language governing permissions and
* * limitations under the License.
* AudaSpace is distributed in the hope that it will be useful, ******************************************************************************/
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with Audaspace; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
* ***** END GPL LICENSE BLOCK *****
*/
/** \file audaspace/intern/AUD_IReader.h #pragma once
* \ingroup audaspaceintern
*/
#ifndef __AUD_IREADER_H__
#define __AUD_IREADER_H__
#include "AUD_Space.h"
/** /**
* @file IReader.h
* @ingroup general
* The IReader interface.
*/
#include "respec/Specification.h"
AUD_NAMESPACE_BEGIN
/**
* @interface IReader
* This class represents a sound source as stream or as buffer which can be read * This class represents a sound source as stream or as buffer which can be read
* for example by another reader, a device or whatever. * for example by another reader, a device or whatever.
*/ */
class AUD_IReader class AUD_API IReader
{ {
public: public:
/** /**
* Destroys the reader. * Destroys the reader.
*/ */
virtual ~AUD_IReader() {} virtual ~IReader() {}
/** /**
* Tells whether the source provides seeking functionality or not. * Tells whether the source provides seeking functionality or not.
@@ -77,9 +72,9 @@ public:
/** /**
* Returns the specification of the reader. * Returns the specification of the reader.
* \return The AUD_Specs structure. * \return The Specs structure.
*/ */
virtual AUD_Specs getSpecs() const=0; virtual Specs getSpecs() const=0;
/** /**
* Request to read the next length samples out of the source. * Request to read the next length samples out of the source.
@@ -94,4 +89,4 @@ public:
virtual void read(int& length, bool& eos, sample_t* buffer)=0; virtual void read(int& length, bool& eos, sample_t* buffer)=0;
}; };
#endif //__AUD_IREADER_H__ AUD_NAMESPACE_END

57
extern/audaspace/include/ISound.h vendored Normal file
View File

@@ -0,0 +1,57 @@
/*******************************************************************************
* Copyright 2009-2016 Jörg Müller
*
* 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.
******************************************************************************/
#pragma once
/**
* @file ISound.h
* @ingroup general
* The ISound interface.
*/
#include "Audaspace.h"
#include <memory>
AUD_NAMESPACE_BEGIN
class IReader;
/**
* @interface ISound
* This class represents a type of sound source and saves the necessary values
* for it. It is able to create a reader that is actually usable for playback
* of the respective sound source through the factory method createReader.
*/
class AUD_API ISound
{
public:
/**
* Destroys the sound.
*/
virtual ~ISound() {}
/**
* Creates a reader for playback of the sound source.
* \return A pointer to an IReader object or nullptr if there has been an
* error.
* \exception Exception An exception may be thrown if there has been
* a more unexpected error during reader creation.
*/
virtual std::shared_ptr<IReader> createReader()=0;
};
AUD_NAMESPACE_END

View File

@@ -0,0 +1,44 @@
/*******************************************************************************
* Copyright 2009-2016 Jörg Müller
*
* 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.
******************************************************************************/
#pragma once
/**
* @file DefaultSynchronizer.h
* @ingroup devices
* The DefaultSynchronizer class.
*/
#include "ISynchronizer.h"
AUD_NAMESPACE_BEGIN
/**
* This class is a default ISynchronizer implementation that actually does no
* synchronization and is intended for devices that don't support it.
*/
class AUD_API DefaultSynchronizer : public ISynchronizer
{
public:
virtual void seek(std::shared_ptr<IHandle> handle, float time);
virtual float getPosition(std::shared_ptr<IHandle> handle);
virtual void play();
virtual void stop();
virtual void setSyncCallback(syncFunction function, void* data);
virtual int isPlaying();
};
AUD_NAMESPACE_END

View File

@@ -0,0 +1,129 @@
/*******************************************************************************
* Copyright 2009-2016 Jörg Müller
*
* 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.
******************************************************************************/
#pragma once
/**
* @file DeviceManager.h
* @ingroup devices
* The DeviceManager class.
*/
#include "Audaspace.h"
#include <memory>
#include <vector>
#include <unordered_map>
AUD_NAMESPACE_BEGIN
class IDevice;
class IDeviceFactory;
class I3DDevice;
/**
* This class manages all device plugins and maintains a device if asked to do so.
*
* This enables applications to access their output device without having to carry
* it through the whole application.
*/
class AUD_API DeviceManager
{
private:
static std::unordered_map<std::string, std::shared_ptr<IDeviceFactory>> m_factories;
static std::shared_ptr<IDevice> m_device;
// delete copy constructor and operator=
DeviceManager(const DeviceManager&) = delete;
DeviceManager& operator=(const DeviceManager&) = delete;
DeviceManager() = delete;
public:
/**
* Registers a device factory.
*
* This method is mostly used by plugin developers to add their device implementation
* for general use by the library end users.
* @param name A representative name for the device.
* @param factory The factory that creates the device.
*/
static void registerDevice(std::string name, std::shared_ptr<IDeviceFactory> factory);
/**
* Returns the factory for a specific device.
* @param name The representative name of the device.
* @return The factory if it was found, or nullptr otherwise.
*/
static std::shared_ptr<IDeviceFactory> getDeviceFactory(std::string name);
/**
* Returns the default device based on the priorities of the registered factories.
* @return The default device or nullptr if no factory has been registered.
*/
static std::shared_ptr<IDeviceFactory> getDefaultDeviceFactory();
/**
* Sets a device that should be handled by the manager.
*
* If a device is currently being handled it will be released.
* @param device The device the manager should take care of.
*/
static void setDevice(std::shared_ptr<IDevice> device);
/**
* Opens a device which will then be handled by the manager.
*
* If a device is currently being handled it will be released.
* @param name The representative name of the device.
*/
static void openDevice(std::string name);
/**
* Opens the default device which will then be handled by the manager.
*
* The device to open is selected based on the priority of the registered factories.
* If a device is currently being handled it will be released.
*/
static void openDefaultDevice();
/**
* Releases the currently handled device.
*/
static void releaseDevice();
/**
* Returns the currently handled device.
* @return The handled device or nullptr if no device has been registered.
*/
static std::shared_ptr<IDevice> getDevice();
/**
* Returns the currently handled 3D device.
* @return The handled device or nullptr if no device has been registered
* or the registered device is not an I3DDevice.
*/
static std::shared_ptr<I3DDevice> get3DDevice();
/**
* Returns a list of available devices.
* @return A list of strings with the names of available devices.
*/
static std::vector<std::string> getAvailableDeviceNames();
};
AUD_NAMESPACE_END

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