Compare commits

...

1050 Commits

Author SHA1 Message Date
Julian Eisel
792f0aaad5 Merge branch 'master' into HMD_viewport
Conflicts:
	source/blender/editors/gpencil/gpencil_paint.c
2017-04-18 13:18:49 +02:00
bc6f689448 Moved opening and closing the HMD drivers to the HMD window creation to solve issues with Windows 10 for some devices.
This solves i.e the DK2/CV1 screen being accessible when opening a window for configuration (since the DK2 needs rotation).
2017-04-18 12:50:46 +02:00
6814b392eb Implemented new Vive distortion coefficient values based on approximated lenswrap 2017-04-18 12:09:59 +02:00
Pascal Schoen
8825a8e951 Squashed commit of the following:
commit 90778901c9
Merge: 76eebd9 3bf0026
Author: Schoen <schoepas@deher1m1598.emea.adsint.biz>
Date:   Mon Apr 3 07:52:05 2017 +0200

    Merge branch 'master' into cycles_disney_brdf

commit 76eebd9379
Author: Schoen <schoepas@deher1m1598.emea.adsint.biz>
Date:   Thu Mar 30 15:34:20 2017 +0200

    Updated copyright for the new files.

commit 013f4a152a
Author: Schoen <schoepas@deher1m1598.emea.adsint.biz>
Date:   Thu Mar 30 15:32:55 2017 +0200

    Switched from multiplication of base and subsurface color to blending
    between them using the subsurface parameter.

commit 482ec5d1f2
Author: Schoen <schoepas@deher1m1598.emea.adsint.biz>
Date:   Mon Mar 13 15:47:12 2017 +0100

    Fixed a bug that caused an additional white diffuse closure call when using
    path tracing.

commit 26e906d162
Merge: 0593b8c 223aff9
Author: Pascal Schoen <pascal_schoen@gmx.net>
Date:   Mon Feb 6 11:32:31 2017 +0100

    Merge branch 'master' into cycles_disney_brdf

commit 0593b8c51b
Author: Pascal Schoen <pascal_schoen@gmx.net>
Date:   Mon Feb 6 11:30:36 2017 +0100

    Fixed the broken GLSL shader and implemented the Disney BRDF in the
    real-time view port.

commit 8c7e11423b
Author: Pascal Schoen <pascal_schoen@gmx.net>
Date:   Fri Feb 3 14:24:05 2017 +0100

    Fix to comply strict compiler flags and some code cleanup

commit 17724e9d2d
Merge: 379ba34 520afa2
Author: Pascal Schoen <pascal_schoen@gmx.net>
Date:   Tue Jan 24 09:59:58 2017 +0100

    Merge branch 'master' into cycles_disney_brdf

commit 379ba346b0
Author: Pascal Schoen <pascal_schoen@gmx.net>
Date:   Tue Jan 24 09:28:56 2017 +0100

    Renamed the Disney BSDF to Principled BSDF.

commit f80dcb4f34
Author: Pascal Schoen <pascal_schoen@gmx.net>
Date:   Fri Dec 2 13:55:12 2016 +0100

    Removed reflection call when roughness is low because of artifacts.

commit 732db8a57f
Author: Pascal Schoen <pascal_schoen@gmx.net>
Date:   Wed Nov 16 09:22:25 2016 +0100

    Indication if to use fresnel is now handled via the type of the BSDF.

commit 0103659f5e
Author: Pascal Schoen <pascal_schoen@gmx.net>
Date:   Fri Nov 11 13:04:11 2016 +0100

    Fixed an error in the clearcoat where it appeared too bright for default
    light sources (like directional lights)

commit 0aa68f5335
Author: Pascal Schoen <pascal_schoen@gmx.net>
Date:   Mon Nov 7 12:04:38 2016 +0100

    Resolved inconsistencies in using tabs and spaces

commit f5897a9494
Author: Pascal Schoen <pascal_schoen@gmx.net>
Date:   Mon Nov 7 08:13:41 2016 +0100

    Improved the clearcoat part by using GTR1 instead of GTR2

commit 3dfc240e61
Author: Pascal Schoen <pascal_schoen@gmx.net>
Date:   Mon Oct 31 11:31:36 2016 +0100

    Use reflection BSDF for glossy reflections when roughness is 0.0 to
    reduce computational expense and some code cleanup

    Code cleanup includes:
    - Code style cleanup and removed unused code
    - Consolidated code in the bsdf_microfacet_multi_impl.h to reduce
      some computational expense

commit a2dd0c5faf
Author: Pascal Schoen <pascal_schoen@gmx.net>
Date:   Wed Oct 26 08:51:10 2016 +0200

    Fixed glossy reflections and refractions for low roughness values and
    cleaned up the code.

    For low roughness values, the reflections had some strange behavior.

commit 9817375912
Author: Pascal Schoen <pascal_schoen@gmx.net>
Date:   Tue Oct 25 12:37:40 2016 +0200

    Removed default values in setup functions and added extra functions for
    GGX with fresnel.

commit bbc5d9d452
Author: Pascal Schoen <pascal_schoen@gmx.net>
Date:   Tue Oct 25 11:09:36 2016 +0200

    Switched from uniform to cosine hemisphere sampling for the diffuse and
    the sheen part.

commit d52d8f2813
Author: Pascal Schoen <pascal_schoen@gmx.net>
Date:   Mon Oct 24 16:17:13 2016 +0200

    Removed the color parameters from the diffuse and sheen shader and use
    them as closure weights instead.

commit 8f3d927385
Author: Pascal Schoen <pascal_schoen@gmx.net>
Date:   Mon Oct 24 09:57:06 2016 +0200

    Fixed the issue with artifacts when using anisotropy without linking the
    tangent input to a tangent node.

commit d93f680db9
Author: Pascal Schoen <pascal_schoen@gmx.net>
Date:   Mon Oct 24 09:14:51 2016 +0200

    Added subsurface radius parameter to control the per color channel
    effection radius of the subsurface scattering.

commit c708c3e53b
Author: Pascal Schoen <pascal_schoen@gmx.net>
Date:   Mon Oct 24 08:14:10 2016 +0200

    Rearranged the inputs of the shader.

commit dfbfff9c38
Author: Pascal Schoen <pascal_schoen@gmx.net>
Date:   Fri Oct 21 09:27:05 2016 +0200

    Put spaces in the parameter names of the shader node

commit e5a748ced1
Author: Pascal Schoen <pascal_schoen@gmx.net>
Date:   Fri Oct 21 08:51:20 2016 +0200

    Removed code that isn't in use anymore

commit 75992bebc1
Author: Pascal Schoen <pascal_schoen@gmx.net>
Date:   Fri Oct 21 08:50:07 2016 +0200

    Code style cleanup

commit 4dfcf455f7
Merge: 243a0e3 2cd6a89
Author: Pascal Schoen <pascal_schoen@gmx.net>
Date:   Thu Oct 20 10:41:50 2016 +0200

    Merge branch 'master' into cycles_disney_brdf

commit 243a0e3eb8
Author: Pascal Schoen <pascal_schoen@gmx.net>
Date:   Thu Oct 20 10:01:45 2016 +0200

    Switching between OSL and SVM is more consistant now when using Disney
    BSDF.

    There were some minor differences in the OSL implementation, e.g. the
    refraction roughness was missing.

commit 2a5ac50922
Author: Pascal Schoen <pascal_schoen@gmx.net>
Date:   Tue Sep 27 09:17:57 2016 +0200

    Fixed a bug that caused transparency to be always white when using OSL and
    selecting GGX as distribution of the Disney BSDF

commit e1fa862391
Merge: d0530a8 7f76f6f
Author: Pascal Schoen <pascal_schoen@gmx.net>
Date:   Tue Sep 27 08:59:32 2016 +0200

    Merge branch 'master' into cycles_disney_brdf

commit d0530a8af0
Author: Pascal Schoen <pascal_schoen@gmx.net>
Date:   Tue Sep 27 08:53:18 2016 +0200

    Cleanup the Disney BSDF implementation and removing unneeded files.

commit 3f4fc826bd
Author: Pascal Schoen <pascal_schoen@gmx.net>
Date:   Tue Sep 27 08:36:07 2016 +0200

    Unified the OSL implementation of the Disney clearcoat as a simple
    microfacet shader like it was previously done in SVM

commit 4d3a0032ec
Author: Pascal Schoen <pascal_schoen@gmx.net>
Date:   Mon Sep 26 12:35:36 2016 +0200

    Enhanced performance for Disney materials without subsurface scattering

commit 3cd5eb56cf
Author: Pascal Schoen <pascal_schoen@gmx.net>
Date:   Fri Sep 16 08:47:56 2016 +0200

    Fixed a bug in the Disney BSDF that caused specular reflections to be too
    bright and diffuse is now reacting to the roughness again

    - A normalization for the fresnel was missing which caused the specular
      reflections to become too bright for the single-scatter GGX
    - The roughness value for the diffuse BSSRDF part has always been
      overwritten and thus always 0
    - Also the performance for refractive materials with roughness=0.0 has
      been improved

commit 7cb37d7119
Author: Pascal Schoen <pascal_schoen@gmx.net>
Date:   Thu Sep 8 12:24:43 2016 +0200

    Added selection field to the Disney BSDF node for switching between
    "Multiscatter GGX" and "GGX"

    In the "GGX" mode there is an additional parameter for changing the
    refraction roughness for materials with smooth surfaces and rough interns
    (e.g. honey). With the "Multiscatter GGX" this effect can't be produced at
    the moment and so here will be no separation of the two roughness values.

commit cdd29d06bb
Merge: 02c315a b40d1c1
Author: Pascal Schoen <pascal_schoen@gmx.net>
Date:   Tue Sep 6 15:59:05 2016 +0200

    Merge branch 'master' into cycles_disney_brdf

commit 02c315aeb0
Author: Pascal Schoen <pascal_schoen@gmx.net>
Date:   Tue Sep 6 15:16:09 2016 +0200

    Implemented the OSL part of the Disney shader

commit 5f880293ae
Merge: 630b80e b399a6d
Author: Pascal Schoen <pascal_schoen@gmx.net>
Date:   Fri Sep 2 10:53:36 2016 +0200

    Merge branch 'master' into cycles_disney_brdf

commit 630b80e08b
Author: Pascal Schoen <pascal_schoen@gmx.net>
Date:   Fri Sep 2 10:52:13 2016 +0200

    Fresnel in the microfacet multiscatter implementation improved

commit 0d9f4d7acb
Author: Pascal Schoen <pascal_schoen@gmx.net>
Date:   Fri Aug 26 11:11:05 2016 +0200

    Fixed refraction roughness problem (refractions were always 100% rough)
    and set IOR of clearcoat to 1.5

commit 9eed34c7d9
Merge: ef29aae ae475e3
Author: Pascal Schoen <pascal_schoen@gmx.net>
Date:   Tue Aug 16 15:22:32 2016 +0200

    Merge branch 'master' into cycles_disney_brdf

commit ef29aaee1a
Author: Pascal Schoen <pascal_schoen@gmx.net>
Date:   Tue Aug 16 15:17:12 2016 +0200

    Implemented the fresnel in the multi-scatter GGX for the Disney BSDF

    - The specular/metallic part uses the multi-scatter GGX
    - The fresnel of the metallic part is controlled by the specular value
    - The color of the reflection part when using transparency can be
      controlled by the specularTint value

commit 88567af085
Merge: cc267e5 285e082
Author: Pascal Schoen <pascal_schoen@gmx.net>
Date:   Wed Aug 3 15:05:09 2016 +0200

    Merge branch 'master' into cycles_disney_brdf

commit cc267e52f2
Author: Pascal Schoen <pascal_schoen@gmx.net>
Date:   Wed Aug 3 15:00:25 2016 +0200

    Implemented the Disney clearcoat as a variation of the microfacet bsdf,
    removed the transparency roughness again and added an input for
    anisotropic rotations

commit 81f6c06b1f
Merge: ece5a08 7065022
Author: Pascal Schoen <pascal_schoen@gmx.net>
Date:   Wed Aug 3 11:42:02 2016 +0200

    Merge branch 'master' into cycles_disney_brdf

commit ece5a08e0d
Author: Pascal Schoen <pascal_schoen@gmx.net>
Date:   Tue Jul 26 16:29:21 2016 +0200

    Base color now applied again to the refraction of transparent Disney
    materials

commit e3aff6849e
Author: Pascal Schoen <pascal_schoen@gmx.net>
Date:   Tue Jul 26 16:05:19 2016 +0200

    Added subsurface color parameter to the Disney shader

commit b3ca6d8a2f
Author: Pascal Schoen <pascal_schoen@gmx.net>
Date:   Tue Jul 26 12:30:25 2016 +0200

    Improvement of the SSS in the Disney shader

     * Now the bump normal is correctly used for the SSS.
     * SSS in Disney uses the Disney diffuse shader

commit d68729300e
Author: Pascal Schoen <pascal_schoen@gmx.net>
Date:   Tue Jul 26 12:23:13 2016 +0200

    Better calculation of the Disney diffuse part

    Now the values for NdotL und NdotV are clamped to 0.0f for a better look
    when using normal maps

commit cb6e500b12
Author: Pascal Schoen <pascal_schoen@gmx.net>
Date:   Mon Jul 25 16:26:42 2016 +0200

    Now one can disable specular reflactions again by setting specular and
    metallic to 0 (cracked this in the previous commit)

commit bfb9cb11b5
Author: Pascal Schoen <pascal_schoen@gmx.net>
Date:   Mon Jul 25 16:11:07 2016 +0200

    fixed the Disney SSS and cleaned the initialization of the Disney shaders

commit 642c0fdad1
Author: Pascal Schoen <pascal_schoen@gmx.net>
Date:   Mon Jul 25 16:09:55 2016 +0200

    fixed an error that was caused by the missing LABEL_REFLECT in the Disney
    diffuse shader

commit c10b484dca
Author: Jens Verwiebe <info@jensverwiebe.de>
Date:   Fri Jul 22 01:15:21 2016 +0200

    Rollback attempt to fix sss crashing, it prevented crash by disabling sss completely, thus useless

commit 462bba3f97
Author: Jens Verwiebe <info@jensverwiebe.de>
Date:   Thu Jul 21 23:11:59 2016 +0200

    Add an undef for sc_next for safety

commit 32d348577d
Author: Jens Verwiebe <info@jensverwiebe.de>
Date:   Thu Jul 21 00:15:48 2016 +0200

    Attempt to fix Disney SSS

commit dbad91ca6d
Author: Pascal Schoen <pascal_schoen@gmx.net>
Date:   Wed Jul 20 11:13:00 2016 +0200

    Added a roughness parameter for refractions (for scattering of the rays
    within an object)

    With this, one can create a translucent material with a smooth surface and
    with a milky look.

    The final refraction roughness has to be calculated using the surface
    roughness and the refraction roughness because those two are correlated
    for refractions. If a ray hits a rough surface of a translucent material,
    it is scattered while entering the surface. Then it is scattered further
    within the object. The calculation I'm using is the following:

    RefrRoughnessFinal = 1.0 - (1.0 - Roughness) * (1.0 - RefrRoughness)

commit 50ea5e3e34
Author: Pascal Schoen <pascal_schoen@gmx.net>
Date:   Tue Jun 7 10:24:50 2016 +0200

    Disney BSDF is now supporting CUDA

commit 10974cc826
Author: Pascal Schoen <pascal_schoen@gmx.net>
Date:   Tue May 31 11:18:07 2016 +0200

    Added parameters IOR and Transparency for refractions

    With this, the Disney BRDF/BSSRDF is extended by the BTDF part.

commit 218202c090
Author: Pascal Schoen <pascal_schoen@gmx.net>
Date:   Mon May 30 15:08:18 2016 +0200

    Added an additional normal for the clearcoat

    With this normal one can simulate a thin layer of clearcoat by applying a
    smoother normal map than the original to this input

commit dd139ead7e
Author: Pascal Schoen <pascal_schoen@gmx.net>
Date:   Mon May 30 12:40:56 2016 +0200

    Switched to the improved subsurface scattering from Christensen and
    Burley

commit 11160fa4e1
Author: Pascal Schoen <pascal_schoen@gmx.net>
Date:   Mon May 30 10:16:30 2016 +0200

    Added Disney Sheen shader as a preparation to get to a BSSRDF

commit cee4fe0cc9
Merge: 4f955d0 6b5bab6
Author: Pascal Schoen <pascal_schoen@gmx.net>
Date:   Mon May 30 09:08:09 2016 +0200

    Merge branch 'cycles_disney_brdf' of git.blender.org:blender into cycles_disney_brdf

    Conflicts:
    	intern/cycles/kernel/closure/bsdf_disney_clearcoat.h
    	intern/cycles/kernel/closure/bsdf_disney_diffuse.h
    	intern/cycles/kernel/closure/bsdf_disney_specular.h
    	intern/cycles/kernel/closure/bsdf_util.h
    	intern/cycles/kernel/osl/CMakeLists.txt
    	intern/cycles/kernel/osl/bsdf_disney_clearcoat.cpp
    	intern/cycles/kernel/osl/bsdf_disney_diffuse.cpp
    	intern/cycles/kernel/osl/bsdf_disney_specular.cpp
    	intern/cycles/kernel/osl/osl_closures.h
    	intern/cycles/kernel/shaders/node_disney_bsdf.osl
    	intern/cycles/render/nodes.cpp
    	intern/cycles/render/nodes.h

commit 4f955d0523
Author: Pascal Schoen <pascal_schoen@gmx.net>
Date:   Tue May 24 16:38:23 2016 +0200

    SVM and OSL are both working for the simple version of the Disney BRDF

commit 1f5c41874b
Author: Pascal Schoen <pascal_schoen@gmx.net>
Date:   Tue May 24 09:58:50 2016 +0200

    Disney node can be used without SVM and started to cleanup the OSL implementation

    There is still some wrong behavior for SVM for the Schlick Fresnel part at the
    specular and clearcoat

commit d4b814e930
Author: Pascal Schoen <pascal_schoen@gmx.net>
Date:   Wed May 18 10:22:29 2016 +0200

    Switched from a parameter struct for Disney parameters to ShaderClosure params

commit b86a1f5ba5
Author: Pascal Schoen <pascal_schoen@gmx.net>
Date:   Wed May 18 10:19:57 2016 +0200

    Added additional variables for storing parameters in the ShaderClosure struct

commit 585b886236
Author: Pascal Schoen <pascal_schoen@gmx.net>
Date:   Tue May 17 12:03:17 2016 +0200

    added output parameter to the DisneyBsdfNode

    That has been forgotten after removing the inheritance of BsdfNode

commit f91a286398
Author: Pascal Schoen <pascal_schoen@gmx.net>
Date:   Tue May 17 10:40:48 2016 +0200

    removed BsdfNode class inheritance for DisneyBsdfNode

    That's due to a naming difference. The Disney BSDF uses the name 'Base Color'
    while the BsdfNode had a 'Color' input. That caused a text message to be
    printed while rendering.

commit 30da91c9c5
Author: Pascal Schoen <pascal_schoen@gmx.net>
Date:   Wed May 4 16:08:10 2016 +0200

    disney implementation cleaned

commit 30d41da0f0
Author: Pascal Schoen <pascal_schoen@gmx.net>
Date:   Wed May 4 13:23:07 2016 +0200

    added the disney brdf as a shader node

commit 1f099fce24
Author: Pascal Schoen <pascal_schoen@gmx.net>
Date:   Tue May 3 16:54:49 2016 +0200

    added clearcoat implementation

commit 00a1378b98
Author: Pascal Schoen <pascal_schoen@gmx.net>
Date:   Fri Apr 29 22:56:49 2016 +0200

    disney diffuse und specular implemented

commit 6baa7a7eb7
Author: Pascal Schoen <pascal_schoen@gmx.net>
Date:   Mon Apr 18 15:21:32 2016 +0200

    disney diffuse is working correctly

commit d8fa169bf3
Author: Pascal Schoen <pascal_schoen@gmx.net>
Date:   Mon Apr 18 08:41:53 2016 +0200

    added vessel for disney diffuse shader

commit 6b5bab6cec
Author: Pascal Schoen <pascal_schoen@gmx.net>
Date:   Wed May 18 10:22:29 2016 +0200

    Switched from a parameter struct for Disney parameters to ShaderClosure params

commit f6499c2676
Author: Pascal Schoen <pascal_schoen@gmx.net>
Date:   Wed May 18 10:19:57 2016 +0200

    Added additional variables for storing parameters in the ShaderClosure struct

commit 7100640b65
Author: Pascal Schoen <pascal_schoen@gmx.net>
Date:   Tue May 17 12:03:17 2016 +0200

    added output parameter to the DisneyBsdfNode

    That has been forgotten after removing the inheritance of BsdfNode

commit 419ee54411
Author: Pascal Schoen <pascal_schoen@gmx.net>
Date:   Tue May 17 10:40:48 2016 +0200

    removed BsdfNode class inheritance for DisneyBsdfNode

    That's due to a naming difference. The Disney BSDF uses the name 'Base Color'
    while the BsdfNode had a 'Color' input. That caused a text message to be
    printed while rendering.

commit 6006f91e87
Author: Pascal Schoen <pascal_schoen@gmx.net>
Date:   Wed May 4 16:08:10 2016 +0200

    disney implementation cleaned

commit 0ed0895914
Author: Pascal Schoen <pascal_schoen@gmx.net>
Date:   Wed May 4 13:23:07 2016 +0200

    added the disney brdf as a shader node

commit 0630b742d7
Author: Pascal Schoen <pascal_schoen@gmx.net>
Date:   Tue May 3 16:54:49 2016 +0200

    added clearcoat implementation

commit 9f3d39744b
Author: Pascal Schoen <pascal_schoen@gmx.net>
Date:   Fri Apr 29 22:56:49 2016 +0200

    disney diffuse und specular implemented

commit 9b26206376
Author: Pascal Schoen <pascal_schoen@gmx.net>
Date:   Mon Apr 18 15:21:32 2016 +0200

    disney diffuse is working correctly

commit 4711a3927d
Author: Pascal Schoen <pascal_schoen@gmx.net>
Date:   Mon Apr 18 08:41:53 2016 +0200

    added vessel for disney diffuse shader

Differential Revision: https://developer.blender.org/D2313
2017-04-18 11:43:09 +02:00
f970e859cf Cycles: Cleanup, style 2017-04-18 11:39:21 +02:00
968d86afc3 Depsgraph: Use proper scene to get frame from for pose constraints evaluaiton
Spotted by Luca, thanks!
2017-04-18 11:31:45 +02:00
dd356ec08d Cycles: Remove meaningless volume shaders
This is possible to use surface-only nodes and connect them to volume output.
If there was something connected to surface output those extra connections
will not change anything visually but will force volume features to be included
into feature-adaptive kernels.

In fact, this exact reason seems to be causing slowdown of Barcelone file
comparing AMD OpenCL to NVidia CUDA.

Currently only supported by the final F12 renders because of the current design
of what gets optimized out when and how feature-adaptive kernel accesses
list of required features.

Reviewers: dingto, nirved, maiself, lukasstockner97, brecht

Reviewed By: brecht

Subscribers: bliblubli

Differential Revision: https://developer.blender.org/D2569
2017-04-18 11:20:39 +02:00
bb8f7784ce Fix strict compiler compilation 2017-04-18 09:41:15 +02:00
8d78df315c Fix UI: double separator in Movie Clip Editor's view menu 2017-04-17 23:54:19 -04:00
157a8727b5 Fix brush menu broken before adding uv and texture data
To reproduce: 1) go to texture paint mode 2) go into the brush menu

Pointed out by @lijenstina on IRC also fix is authored by him.
2017-04-17 23:42:17 -04:00
4d0d1b5936 Fix T51150: user_remap on itself changes users to 0.
Remapping to itself is nonsense here (was triggering an assert in
BKE_library code actually), just make it a bail out early in RNA
callback in that case.
2017-04-17 22:33:07 +02:00
4621392353 Fix T51176: Cache file location can be blank and prevent fluid simulation from reading baked data
Sanitize a bit how cache path is handled by fluidsim (there is much more
to be done here though :( ), and forbid empty path (we reset to default
path relative to current .blend file in case it's empty).

If people really, really want to use current OS-wise directory, they can at
least use '.' as path. ;)
2017-04-17 17:35:53 +02:00
819064154c BLI: make BLI_make_existing_file() return true on success, and false on failure... 2017-04-17 17:35:53 +02:00
c89ed72048 Fluidsim cleanup: get rid of magic numbers! 2017-04-17 17:35:53 +02:00
11f4b407d4 Fix build error on Windows introduced in D2425 2017-04-17 13:41:05 +03:00
57d31171d0 Object.raycast: more minor improvements ...
- if it is to check a bool, let it be local;
- removes gotos;
2017-04-16 18:50:06 -03:00
15215652e1 Fix T49617: Grease Pencil Stroke Placement regression
When moved the options to toolsetting, this part was missing. The problem was not the pointer as suggested in D2629.

Thanks Arvīds Kokins for his help fixing this bug
2017-04-16 17:52:39 +02:00
Julian Eisel
9e17c831eb Move HMD operators to wm_hmd.c 2017-04-16 00:04:11 +02:00
Julian Eisel
2d9f41b1bd Replace wm_device.c with wm_hmd.c, rename functions appropriately 2017-04-15 23:48:12 +02:00
Julian Eisel
1a0b5c3a99 Merge branch 'master' into HMD_viewport 2017-04-15 23:14:15 +02:00
Julian Eisel
dd2bdd2ca0 Fix closing HMD window not exiting HMD session correctly 2017-04-15 17:30:09 +02:00
Julian Eisel
d4dd0184a8 Fix virtual cursor not being removed correctly when stopping hmd session 2017-04-15 16:26:07 +02:00
97c9c6a3f3 Fix T51149: Joining curves allows 2D curves in 3D 2017-04-15 16:55:08 +10:00
00ad259939 Object.raycast: error in previous commit
This is taking longer than I expected.
2017-04-15 02:31:33 -03:00
34ea8058b9 Fix: Object.raycast: error to free treedata 2017-04-15 02:24:04 -03:00
97d2f63bfe Object.raycast: Also test distance from BoundBox
If `isect_ray_aabb_v3_simple` provides this information, why not take advantage of it?
2017-04-15 01:31:24 -03:00
480473f1f1 Object.raycast: Test the hit on the BoundBox first
This avoids the unnecessary creation of bvhtree, which can be highly inefficient in some cases
(for example: in the `operator_modal_view3d_raycast.py` template)
2017-04-15 00:44:05 -03:00
718fb3167d Fix Player stubs (tm) 2017-04-15 01:09:44 +02:00
e280c70aa9 Fix T51216: SSAO attenuation not being scale invariant.
Unfortunately this does break compatibility in that the viewport will look a
bit different depending on the settings, but the old behavior was simply not
usable for higher distances.
2017-04-15 00:43:22 +02:00
5fa4f397c2 Alembic import: fixed dupligroup export when the dupli-empty has a parent 2017-04-14 18:20:28 +02:00
4d117f2fd2 Alembic export: fixed flattened dupligroup import 2017-04-14 18:20:28 +02:00
78b5d66af8 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-14 18:15:57 +03:00
6fc7521ade Fix T49429: incorrect Blender internal viewport border render with DrawPixels method. 2017-04-14 16:26:10 +02:00
e12c311002 Alembic import: greatly improved curve/hair import performance
The U-resolution of the imported curves was kept at the default value
of 12, which is way too high for imported hair. We export hair at a
fairly high resolution already, so it's not needed to subdivide even
further when importing.

Of course this may have an impact on other curves that do require this
U-resolution to be higher. In that case the resolution can be
increased after importing.

I removed the default nu->orderu = num_verts, as that allowed every
point to influence the entire spline, which was more expensive for the
CPU, and unlikely to be needed. The orderu computations had off-by-one
errors in the curve importer, which are now also fixed. The correct
values are:

    - Linear: orderu = 2
    - Quadratic: orderu = 3
    - Cubic: orderu = 4

These values are also what is stored in the Alembic file for curves of
type kVariableOrder, according to the reference Maya exporter
maya/AbcExport/MayaNurbsCurveWriter.cpp, function
MayaNurbsCurveWriter::write(), in the Alembic source code.

The result is a frame rate increase of roughly 100x (tested with one
100-hair test on one machine, so take with grain of salt).
2017-04-14 15:26:45 +02:00
6af131fa5c Added simple unittests for Alembic exporter
This test checks that a set of cubes are exported with the correct
transform, both with flatten=True and flatten=False.

This commit also adds an easy to use superclass for upcoming Alembic
unit tests.
2017-04-14 12:54:20 +02:00
0b55b8cc6a Cleanup: triple quotes for docstrings 2017-04-14 20:01:43 +10:00
6a8a679037 BLF: avoid glyph cache use-after free
Causes crash if the font size isn't set after clearing (see T51200)
2017-04-14 19:54:09 +10:00
7cfabcef5c Buildbot: Fix typos 2017-04-14 10:03:51 +02:00
b354c15805 Buildbot: Attempt to fix CUDA compilation on OSX
Stupid toolkit is really fragile about CLang version.
2017-04-14 10:01:28 +02:00
ac880b67c3 UI: Add/Improve a few tooltips
See T51061
2017-04-13 18:07:50 -04:00
Julian Eisel
a61b751972 Avoid view setup function prototypes, move them to top of file 2017-04-13 19:47:42 +02:00
Julian Eisel
01acc0d59f Move drawing matrix setup into own function 2017-04-13 19:26:35 +02:00
3906e5939a Alembic export: unified code of exploreTransform and exploreObject. 2017-04-13 16:34:37 +02:00
ebb3045114 Alembic export: added support for writing dupli-groups
This supports our common character animation workflow, where a character,
its rig, and the custom bone shapes are all part of a group. This group
is then linked into the scene, the rig is proxified and animated. Such
a group can now be exported. Use "Renderable objects only" to prevent
writing the custom bone shapes to the Alembic file.
2017-04-13 16:34:37 +02:00
0a032ce83b Fix Surface Deform crash with missing or freed DM 2017-04-13 15:40:50 +02:00
360cf8393a Cycles: Make vectorized types constructor from register explicit
This is not a cheap operation which we dont' want to happen silently.
2017-04-13 15:08:00 +02:00
e6392458d3 Cycles: Remove unused function
It was quite wrong actually by doing some __m128 to flaot4 round trips.
2017-04-13 15:08:00 +02:00
0706b908db Alembic import: fixed off-by-one error in start/end frame
static_cast<int> truncates, so a computed end frame of 99.999999999998
would result in 99, instead of the correct 100.
2017-04-13 14:50:02 +02:00
575d6415fb Task scheduler: Fix typo in TLS for pools created from non-main thread
Did a mistake which started to use same TLS for all threads for such pools.

Also added some extra asserts to help catching the bugs.
2017-04-13 13:34:07 +02:00
544df54f3c Fix Blenderplayer (c) 2017-04-13 12:36:19 +02:00
f5bc8ad4ce Add red alert in UI controls for datablock pointer properties 2017-04-13 12:59:04 +03:00
a7b3047cef Datablock ID Properties
The absence of datablock properties "will certainly be resolved soon as the need for them is becoming obvious" said the [[http://wiki.blender.org/index.php/Dev:Ref/Release_Notes/2.67/Python_Nodes|Python Nodes release notes]]. So this patch allows Python scripts to create ID Properties which reference datablocks.
This functionality is implemented for `PointerProperty` and now such properties can be created with Python.

In addition to the standard update callback, `PointerProperty` can have a `poll` callback (standard RNA) which is useful for search menus. For details see the test included in this patch.

Original author: @artfunkel

Alexander (Blend4Web Team)

Reviewers: brecht, artfunkel, mont29, campbellbarton

Reviewed By: mont29, campbellbarton

Subscribers: jta, sergey, campbellbarton, wisaac, poseidon4o, mont29, homyachetser, Evgeny_Rodygin, AlexKowel, yurikovelenov, fjuhec, sharlybg, cardboard, duarteframos, blueprintrandom, a.romanov, BYOB, disnel, aditiapratama, bliblubli, dfelinto, lukastoenne

Maniphest Tasks: T37754

Differential Revision: https://developer.blender.org/D113
2017-04-13 12:33:05 +03:00
f90a243d9c Cycles: Header cleanup in BVH: move self header to be the first one
This makes us more sure that header files are more self-sufficient.
2017-04-13 11:28:02 +02:00
0097f9b298 Cycles: Split BVH implementations into separate files 2017-04-13 10:55:46 +02:00
c8548871ac Cycles: Use more explicit and commonly used names for BVH structures
This renames BinaryBVH to BVH2 and QBVH to BVH8. There is no user measurable
difference, but allows us to add more types of BVH trees such as BVH8.
2017-04-13 10:29:14 +02:00
Julian Eisel
3113329f79 Fix manipulator interaction not using correct projection matrix
Moved matrix setup for interaction into own util function now. Also did
cleanup in related code.
2017-04-13 01:25:42 +02:00
Julian Eisel
a07ca22a99 Force using HMD parameters instead of camera ones in camera perspective 2017-04-13 00:09:27 +02:00
Julian Eisel
8437c6e28e Fix lens separation applied wrongly onto projection matrix 2017-04-12 23:56:51 +02:00
Julian Eisel
a993466b22 Fix projection matrices not taking focal length of HMD into account 2017-04-12 19:55:42 +02:00
ed5c3121f5 Task scheduler: Prevent race condition for the pools created from non-main thread
We can not re-use anything for such pools, because we will know nothing about whether
the main thread is sleeping or not. So we identify such threads as 0, but we don't
use main thread's TLS.

This fixes dead-locks and crashes reported by Luca when doing playblasts.
2017-04-12 18:20:17 +02:00
a21130f737 Re calibrated the vertical position for the Vive lens distortion shader 2017-04-12 18:18:14 +02:00
699a3e2498 Fix T50227: Alembic uv export/load issue
Previously only a CD_MLOOPUV custom data layer was created. Now we also
create the accompanying CD_MTEXPOLY layer too.
2017-04-12 16:33:47 +02:00
6b815ae55d Fix T51184: Crash of Blender when I try to join an object with one that has booleans modifiers 2017-04-12 16:12:50 +02:00
Julian Eisel
0b4e2631d2 Fix crash when closing HMD window during running session 2017-04-12 12:27:36 +02:00
642728b339 Alembic export: fixed exporting as "flat"
This exports all objects in world coordinates without parenting.
2017-04-12 12:21:08 +02:00
de3c98d62b Alembic export: removed superfluous export_object() check.
The exploreTransform() function already does this check, and the check
isn't necessary when the object type isn't exported anyway.
2017-04-12 12:21:00 +02:00
4560f0b007 Cleanup: use lowercase gpu prefix for static funcs
This was mostly followed already.
2017-04-12 20:19:55 +10:00
c29bc61829 Color management: Avoid memory copy into same buffer 2017-04-12 10:23:38 +02:00
0ebe08af34 Docs: minor improvement to code example 2017-04-12 14:21:59 +10:00
Julian Eisel
623841e7df Fix HMD view drawing black if device is set to 'None' 2017-04-12 01:09:18 +02:00
Julian Eisel
b3cdca4a0a Cleanup: Naming, use util function 2017-04-12 00:04:11 +02:00
Julian Eisel
511347ff30 Remove unnecessary check
Avoids having to pass around window-manager
2017-04-11 23:41:48 +02:00
Julian Eisel
8e4b4881c8 Fix Multi-view drawing interfering with HMD view drawing
Don't do any multi-view drawing in HMD view, it doesn't make any sense.
2017-04-11 23:19:11 +02:00
Julian Eisel
3c51b670c5 Make interactions in HMD view work nicely
This should make any interactions in HMD views work like users would
expect. Talking about things like selecting, using tools, placing 3D
cursor, ...
Same goes for HMD mirror views, their interactions should work fine
now.

I'm not so happy how we pass info about HMD state to
ED_view3d_draw_depth and ED_view3d_draw_depth_gpencil, would like to
figure out a nicer way to do that. Also continuous grab works a bit
glitchy.
2017-04-11 21:25:22 +02:00
Julian Eisel
c87925469b Add WM level utility check for active HMD view 2017-04-11 21:13:20 +02:00
Julian Eisel
2fa9fceba0 Special Blender-managed cursor drawing for HMD view
Since OSes only draw one cursor, we need to draw our own cursor for both
eyes.
Note that the interaction coordinates are still incorrect as they ignore
the split screen. Will fix that separately.
2017-04-11 21:13:20 +02:00
31bdb31ecf Fix: width of UILayout.prop_enum() buttons 2017-04-11 13:25:46 +03:00
d097c72f81 Cycles: Only calculate global size of split kernel once to avoid changes
Global size depends on memory usage which might change during rendering.
Havent seen it happen but seems possible that this could cause the global
size to be different than what was used for allocating buffers.
2017-04-11 03:26:18 -04:00
1e6038a426 Cycles: Implement automatic global size for CUDA split kernel
Not sure this is the best way to do things for CUDA but its much better than
being unimplemented.
2017-04-11 03:11:18 -04:00
3722da3b4e Cleanup: quiet harmless but annoying overflow
Caused asan to print warnings generating RNA
2017-04-11 11:49:21 +10:00
532b2786e2 Remove redundant glColor call 2017-04-11 10:47:00 +10:00
ef816f9cff Cycles: Fix the AO replacement option in the split kernel
Currently the code for it was inside the hair-specific part, so it wouldn't be enabled in hairless renders.
2017-04-11 01:07:49 +02:00
8b0fbb909b UI: Add missing UV tools in the UV/Image Editor Window > Tools tab
Original Author: @xrg
Changes By @blendify

Image of patch: {F284237}
2017-04-10 18:37:03 -04:00
8ac7510a4d UI: Do not put walk navigation settings inside an if statement
The issue here is that the preferences are still used because both can be accessed from the 3D View, view menu. In the future, it is likely that the old mode will be removed (maybe 2.8?) but for now we want to keep both operational.

Differential revision: https://developer.blender.org/D2320
2017-04-10 17:44:03 -04:00
2ad1124372 Fix stereoscopic camera volume drawing.
Not sure how we got to that point, but code was drawing twice one side
of the camera volume, and not at all another side!
2017-04-10 17:31:39 +02:00
c8e764ccbf Cycles: Fix race condition in shader attribute for real now
Ended up moving lock in the more centralized space since multiple shaders
can access this map.
2017-04-10 16:53:01 +02:00
fd203a0933 GPencil 2D drawing code: minor optimization.
Do not recompute both points's 2D coordinates for each segments, we can
copy over from previous one... Does not gives any measurable speedup off
hands, though.
2017-04-10 16:30:05 +02:00
a40f15d04f Fix T51158: Motion Tracking Movie clip editor graph 2017-04-10 16:16:12 +02:00
58f3b3c6d1 Tracking: Fix use-after-free bug 2017-04-10 16:02:14 +02:00
358def15a3 Install deps: Fix compilation error of Alembic
Couple of things here:

- Boost is not necesserily compiled into your /opt/lib and system-wide
  version might have been used. The recent change in Alembic did not
  take this into account.

- Alembic needs some extra component of Boost.
  This part might be missing now for other distros than DEB.
2017-04-10 15:55:25 +02:00
9539cfacca Cycles: Apparently board name could be an empty string 2017-04-10 15:31:21 +02:00
3b4cc5dfed Cycles: Workaround cubic volume filtering crashing on Linux
The issue was caused by recent change in inline policy.

There is some sort of memory corruption happening here, ASAN suggests
it's stack overflow issue. Not quite sure why it is happening tho and
was not able to solve anything here yet in the past hours.

Committing fix which works with a big TODO note.

The issue is visible on AVX2 machine when rendering cycles_reports_test.
2017-04-10 14:44:07 +02:00
90d85c7975 Cycles: Fix compilation error of AVX2 kernels with SSE optimization disabled 2017-04-10 14:44:04 +02:00
c3d393c1df Cycles: Cleanup, indentation and trailing whitespace 2017-04-10 14:44:04 +02:00
73a9ff0d2d PyAPI: Fast buffer access to id property arrays
Support Python's buffer protocol for ID-properties.
2017-04-10 21:12:02 +10:00
5b873c8c24 Cleanup: use doxy code block 2017-04-09 16:26:04 +10:00
162e184ffd ListBase: Add insert-replace function
Handy to replace an existing link
(without having to store before/after links)

Use for id-props
2017-04-09 16:07:09 +10:00
b60d4800c6 Cycles: Fix building of CUDA kernels with compilers where C++11 is disabled 2017-04-08 07:12:04 -04:00
1cd54ec225 Add helpers in bpy_extras.keyconfig_utils for addons to (un)register their keymaps.
Doing this in a fully 'clean' way is far from obvious, especially
unregister, you often end up leaving nasty 'orphanned' keymap items
referring to unregistered operators...
2017-04-08 11:09:11 +02:00
867d311307 Cycles: Fix warning with MSVC 2017-04-07 18:28:38 +02:00
7d77b3e813 Cycles: Fix compilation error with certain CUDA and host compiler configuration
This seems to happen on Windows only, happened to Thomas and Nathan already.

Similar patch Thomas was showing, but i do not see it committted. So comitting
now in order to get more developers and users happy.
2017-04-07 18:28:38 +02:00
8c22a974d6 Tests: Compare vectors with epsilon
SOlves the test false-positively failing in 32 bit environment.
2017-04-07 18:28:38 +02:00
b332fc8f23 [Cycles/msvc] Get cycles_kernel compile time under control.
Ever since we merged the extra texture types (half etc) and spit kernel the compile time for cycles_kernel has been going out of control.

It's currently sitting at a cool 1295.762 seconds with our standard compiler (2013/x64/release)

I'm not entirely sure why msvc gets upset with it, but the inlining of matrix near the bottom of the tri-cubic 3d interpolator is the source of the issue, this patch excludes it from being inlined.

This patch bring it back down to a manageable 186 seconds. (7x faster!!)

with the attached bzzt.blend that @sergey  kindly provided i got the following results with builds with identical hashes

58:51.73 buildbot
58:04.23 Patched

it's really close, the slight speedup could be explained by the switch instead of having multiple if's (switches do generate more optimal code than a chain of if/else/if/else statements) but in all honesty it might just have been pure luck (dev box,very polluted, bad for benchmarks) regardless, this patch doesn't seem to slow down anything with my limited testing.

{F532336}

{F532337}

Reviewers: brecht, lukasstockner97, juicyfruit, dingto, sergey

Reviewed By: brecht, dingto, sergey

Subscribers: InsigMathK, sergey

Tags: #cycles

Differential Revision: https://developer.blender.org/D2595
2017-04-07 10:26:55 -06:00
8e0cdfd0c9 Libmv: Correction to previous commit
We do need to make a copy of the values.
2017-04-07 17:57:48 +02:00
a1f8755d32 Libmv: Fix crash of keyframe selection on 32bit linux 2017-04-07 17:10:44 +02:00
eae691f89e Buildbot: List freetype for OIIO libraries
OIIO in release environment is compiled with Freetype support.

This fixes compilation error of static unit tests.
2017-04-07 17:01:07 +02:00
07708b85b4 Buildbot: Link statically against freetype 2017-04-07 17:00:43 +02:00
4360a74715 CMake: Fix detection of idiff program 2017-04-07 17:00:06 +02:00
c637e749b2 Tests: Fix compilation error with static OpenMP 2017-04-07 16:06:28 +02:00
43a910abce Alembic import: prevent crash when cancelling import.
It's possible that cancellation occured between the creation of the reader
and the creation of the Blender object, in which case reader->object()
returns a NULL pointer.
2017-04-07 16:03:29 +02:00
3748ca432d Alembic import: prevent double user decrement when cancelling import.
BKE_libblock_free_us() was called on the object data, which decrements
its user count, after which the same function was called on the object,
which decrements the user count of the object data again. This double
decrement was too much.
2017-04-07 16:03:29 +02:00
fd08570665 Cycles: Fix access of NULL pointer as array
Was confusing guarded allocator for some reason.
2017-04-07 15:08:00 +02:00
ddb42076c9 Alembic: synced gather_objects_paths with visit_objects
This was necessary, but was only mentioned at gather_object_paths (which
I didn't see earlier). That's now also fixed.
2017-04-07 13:41:34 +02:00
1d9f369824 Cleanup: Unused function 2017-04-07 12:55:04 +02:00
9706bfd25d Cycles: Fix corrupted mesh render when topology differs at the next frame 2017-04-07 12:49:10 +02:00
91b9db0724 Cycles: Change work pool and global size of split CPU for easier debugging 2017-04-07 06:06:08 -04:00
8f85ee2fc9 Cycles: Fix indentation 2017-04-07 06:06:08 -04:00
5b45fff136 Cycles: Add missing flush 2017-04-07 06:06:08 -04:00
d66ffaebef Cycles: Check ray state properly to avoid endless loop
The state mask wasnt applied before comparison giving false results. It
shouldnt really happen that a ray state contains any flags that need to
be masked away, but if it does happen its better to not get stuck.
2017-04-07 06:06:08 -04:00
e8e341b585 Alembic: documented use of CacheReader struct 2017-04-07 11:06:50 +02:00
df7d5382d3 Alembic: just pass NULL when we know mcmd->reader is NULL.
More explicit, easier to read & understand.
2017-04-07 11:03:26 +02:00
102966b12e Fix building alembic gtest with buildinfo... 2017-04-07 10:44:13 +02:00
a0799ce336 Fix T51137: Edge Rip Hangs 2017-04-07 11:47:28 +10:00
d426c335c5 Fix T51135: Cylinder primitive generated bad UVs 2017-04-06 12:20:22 -03:00
c684fab8a6 Alembic: rewrapped some lines to fit within 80 chars. 2017-04-06 16:47:01 +02:00
98329a5760 Alembic import: compatibility with pre-C++11 compilers. 2017-04-06 16:47:01 +02:00
8e3676d533 Alembic import: restructured the importer w.g.t. parenthood
Previously, a GHash was used to store a flattened mapping of parent
information based on the Alembic hierarchy, and then that hash was used to
set parent pointers on Blender objects. This resulted in errors and
some duplicate objects. The new approach stores parent pointers while
traversing the Alembic hierarchy, which means that there is much more
information about the actual context of the Alembic object itself,
producing a more stable import.
2017-04-06 16:47:01 +02:00
fa827374a7 Alembic: rotation mode issue in copy_m44_axis_swap, and added unit tests. 2017-04-06 16:47:01 +02:00
b6775cd684 Added float[][] comparison macros to testing.h
I've moved EXPECT_M3_NEAR from abc_matrix_test.cc to testing.h, as that's
a more suitable location.
2017-04-06 16:47:01 +02:00
c2fec0f1b0 Alembic: Renamed create_rotation_matrix to create_swapped_rotation_matrix and more:
Also replaced the bool param "to_yup" with "AbcAxisSwapMode mode", so that
it's more explicit that axes are swapped.

Also added unittests for create_swapped_rotation_matrix.
2017-04-06 16:47:01 +02:00
8ae656bf22 CMake: Fixed order of bf_alembic in SETUP_BLENDER_SORTED_LIBS
bf_alembic depends on bf_bmesh, and should therefore be above it.
2017-04-06 16:47:00 +02:00
bc55c19807 Alembic import: fixed crash on more complex model
There was a problem with parent-child relations not getting set up
correctly when an Alembic object was both the transform for a mesh object
and the parent of other mesh objects.
2017-04-06 16:47:00 +02:00
42cd2719ec Alembic: comment typo/error fixes 2017-04-06 16:47:00 +02:00
6c37a53a2e Alembic import: prevented unnecessary vector scaling 2017-04-06 16:47:00 +02:00
5e86144cd3 Alembic import: moved import-time scaling to different function
convert_matrix() now only converts from Imath::M44d to float[4][4] (taking
different camera orientations into account). Import-time scaling is now
performed by the caller.
2017-04-06 16:47:00 +02:00
4cb5114e13 Alembic: removed unnecessary matrix copy 2017-04-06 16:47:00 +02:00
aaa88fac76 Alembic: simplified AbcEmptyReader::readObjectData 2017-04-06 16:47:00 +02:00
8b2555e798 Alembic: added some r_ prefixes for return parameters 2017-04-06 16:47:00 +02:00
f226b808ff Alembic: code style 2017-04-06 16:47:00 +02:00
3735065d22 Alembic: don't use m_shapes_type 2017-04-06 16:46:51 +02:00
8fe3f47596 Alembic: more lenient check on absence of sheer & homogeneous scaling
Checking precise values of floats is not a good idea.
2017-04-06 16:04:31 +02:00
a9504580b3 Alembic: simplified conditional statements 2017-04-06 16:04:31 +02:00
997ff4bdc4 Alembic import: nicer progress updates 2017-04-06 16:04:31 +02:00
d1696622b7 Alembic import: fixed bug where local matrix from Alembic was used as object matrix
Also renamed AbcObjectReader::readObjectMatrix to
setupObjectTransform, as it does more than just reading the object
matrix; it also sets up an object constraint if the Alembic Xform is
animated.
2017-04-06 16:04:31 +02:00
818ee188e7 Alembic import: separated reading matrix and getting the appropriate Xform object
Also added a bit better error reporting, instead of silently ignoring
invalid Alembic data.
2017-04-06 16:04:31 +02:00
e4367ccb78 Alembic import: be more lenient towards unknown object types.
Alembic is an interchange and caching format, that can contain custom
object schemas. Blender shouldn't crash (because of failing asserts) just
because it doesn't know such an object type.
2017-04-06 16:04:31 +02:00
aba7759992 Alembic: don't call object.getFullName() multiple times. 2017-04-06 16:04:31 +02:00
2c688bac19 Alembic: Renamed parent_map to reader_map
It's a mapping from full path of an Alembic object to an AbcObjectReader*.
The fact that at some point it is used to construct parent-child relations
doesn't matter.
2017-04-06 16:04:31 +02:00
152ec791ad Alembic: use typedefs to make it easier to handle maps/vectors 2017-04-06 16:04:31 +02:00
85672d29f2 Alembic: more const-ness 2017-04-06 16:04:31 +02:00
02d6df80aa Alembic: fixed importer
The importer was guessing whether an Alembic IXform object was part of a
child object, or should be represented as an Empty in Blender. By reversing
the order in which objects are visited, the children can now claim their
parent as part of the same object (so IPolyMesh claims its parent IXform
as part of the same Blender object). This results in much less guesswork.

I've also removed similar guesswork from the code that sets parent pointers,
by simply searching for the parent in a hierarchical way, instead of trying
to predict (again) which IXforms were turned into empties.

Also, visit_object() now actually visits the object -- previously it only
visited its children, and assumed the object it was called on was already
handled by a previous call.
2017-04-06 16:04:31 +02:00
76ca6ed26e Alembic: prevent a couple of unnecessary multiplications 2017-04-06 16:04:31 +02:00
e0bf97d8b4 Alembic: be more explicit in y-up versus z-up variables. 2017-04-06 16:04:31 +02:00
06c25ace7b Alembic: removed a lot of unnecessary & duplicate code from abc_util.cc
create_transform_matrix(float[4][4]) did mostly the same as
create_transform_matrix(Object *, float[4][4]), but more elegant.
However, the former has some inconsistencies with the latter (which
are now merged and made explicit, turned out one was for z-up→y-up
while the other was for y-up→z-up), and was renamed to
copy_m44_axis_swap(...) to convey its purpose more clearly.

Furthermore, "loc" has been renamed to "trans", as matrices don't
store locations but translations; and more variables now have a src_
or dst_ prefix to denote whether they contain a matrix/vector in the
source or destination axis orientation.
2017-04-06 16:04:31 +02:00
1c3b6e042a Alembic: added note 2017-04-06 16:04:31 +02:00
b0967e9d42 Alembic: allow copy_{z,y}up_from_{y,z}up() to be called with yup=zup
This allows in-place conversion between z-up and y-up, by passing the
same variable to both arguments.
2017-04-06 16:04:31 +02:00
00e0a94b3c Alembic: import empties under their own name in Alembic, not their parent's
Before this commit something strange happened, as the m_data_name of
an inherit data-less object was used.
2017-04-06 16:04:31 +02:00
cbe0709db2 Alembic: Don't compute world matrix when it's not necessary. 2017-04-06 16:04:31 +02:00
62a47f9660 Alembic: cleaned up hack in AbcObjectReader::read_matrix() 2017-04-06 16:04:31 +02:00
347a4956a0 Alembic: added some clarification 2017-04-06 16:04:31 +02:00
c0ec0a19da Alembic: added some getter functions to help debug prints etc. 2017-04-06 16:04:31 +02:00
5f23f5b516 Alembic: do not presume to predict the parent name
AbcExporter::createTransformWriter() tries to predict the parent Xform
name, but if it cannot be found has multiple ways of creating it, possibly
under a different name than originally searched for.
2017-04-06 16:04:31 +02:00
56cfd3d5a7 Alembic: Removed AbcTransformWriter::m_parent
It was set, but never read anywhere.
2017-04-06 16:03:59 +02:00
ae76a90593 Buildbot: Correct previous release
Seems CMake is not happy about changing compiler from script.
2017-04-06 11:39:06 +02:00
97300a3beb Buildbot: Force build environment to use latest GCC 2017-04-06 11:21:07 +02:00
f74b4a010d Cleanup: function naming for manipulator
Rename 'stats_*' to 'protectflag_to_drawflags_*' (was too vague).
Also remove NULL check from gimbal_axis
2017-04-06 12:26:07 +10:00
5e3b6e951b Cleanup: minor changes to transform-manipulator
Match stats_editbone & stats_pchan behavior to avoid confusion.
2017-04-06 12:02:32 +10:00
7ae9d092d0 Fix alembic build error with MSVC 2017-04-05 10:59:29 -06:00
f921442a44 Depsghraph: Remove unused function 2017-04-05 15:36:17 +02:00
52029e689c Cycles: Fix race condition in attributes creation during SVM compilation 2017-04-05 14:57:54 +02:00
3ce30823ff Cycles: Add utility class to simplify scoped spin locks 2017-04-05 14:57:34 +02:00
424901ad7b Cycles: Guard global write access in SVM compilation code 2017-04-05 14:21:49 +02:00
e4c5441286 Locales: Some optimization work
Mainly visible for MSVC debug builds and gives about 2x speedup.
2017-04-05 11:25:58 +02:00
8647d5af90 InstallDeps: Raise minimal & official version of OIIO to 1.7.13.
As requested by @sergey.
2017-04-05 09:26:41 +02:00
6d55dcf4dd Alembic: addition of a simple logging class.
The idea is to have a system where we properly log error messages and
let the users know that errors occured redirecting them to the console
for explanations. This is only implemented for the exporter since the
importer already has similar functionalities; however they shall
ultimately be unified in some way.

Reviewers: sybren, dfelinto

Differential Revision: https://developer.blender.org/D2541
2017-04-05 04:56:38 +02:00
411e7abe94 Cleanup: redundant casts 2017-04-05 01:08:19 +10:00
9170e49250 Fix missing protection of RNA_pointer_as_string() against NULL pointers.
Odd that issue was never reached before? Looks like it hit in
datablock_idprops branch though...
2017-04-04 16:04:13 +02:00
92aeb84fde Cycles: Tag shaders for update after the threading part is over
This avoids write access happening in non-atomic manner in
Shader::tag_update which modifies the global managers. Even
for 1 byte data types it's quite dangerous.
2017-04-04 15:43:12 +02:00
7b149bfde6 Depsgraph: Use atomic operation to tag the changed ID 2017-04-04 15:43:12 +02:00
5ce95df2c6 Cycles: Fix uninitialized memory access when comparing curve mapping nodes
The issue is coming from the fact that float3 is actually 16 bytes aligned
data type and the "padding" was not initialized. This caused memcmp() to
access non-initialized memory.
2017-04-04 15:43:12 +02:00
a63a31dd12 install_deps: removed leftover compile_HDF5 command
It was a leftover from when Alembic with HDF5 was still officially
supported.
2017-04-04 14:50:58 +02:00
8a60d84327 Bumped Alembic library version to 1.7.1
This provides us with a clearer API (so I don't have to use const_cast<>
in upcoming code). It also allows layering of different Alembic files,
so you can have a base file and load a separate file containing overrides.

Verbally approved by Dr. Sergey.
2017-04-04 12:55:38 +02:00
ffac92e385 Buildbot: Update master config 2017-04-04 12:52:54 +02:00
b93ddfd8ac Alembic: force ALEMBIC_LIB_USES_BOOST=ON when not using C++11
Alembic requires one of ALEMBIC_LIB_USES_BOOST, ALEMBIC_LIB_USES_TR1, or
C++11, and silently defaults to the latter if the former two are OFF.

Before this change, Alembic was only built without C++11 of OpenEXR
was built at the same time. This dependency was both unnecessary and
undocumented.
2017-04-04 12:41:44 +02:00
ca5ccf5cd4 Task: Remove non-atomic pool suspended flag assignment
This was done some lines above by atomic fetch and and.
2017-04-04 12:32:15 +02:00
4f7eb3ad12 Buildbot: Update master config 2017-04-04 12:15:35 +02:00
728f75c6a7 Buildbot: Some more twqeaks to master config 2017-04-03 15:51:31 +02:00
e741804ce3 Buildbot: Update bundled vetrsion of server configuration 2017-04-03 15:36:52 +02:00
cc93a66e71 Buildbot: SPecial branch trickery for linux slaves 2017-04-03 15:04:16 +02:00
2aa0215ec5 Point all submodules to master branch
This way it should be safe to use `git submodule update --remote`.
2017-04-03 14:54:51 +02:00
d27ef3913a Buildbot: Some special tricks for Blender 2.8 slave 2017-04-03 14:49:07 +02:00
2cd6dfe86e Cleanup: tabs 2017-04-03 22:19:47 +10:00
f38dc5c06b Merge branch 'master' into HMD_viewport 2017-04-03 22:14:12 +10:00
54a60eff24 Fix blender player 2017-04-03 12:31:33 +02:00
ab347c8380 Fix T51115: Bump node is broken when the displacement socket is used 2017-04-03 10:51:00 +02:00
368b74315a Collada - add flag to limit precision of exported data, mainly to simplify debugging 2017-04-03 10:48:00 +02:00
f65d6ea954 fix: collada - do proper conversion from int to bool (as with other nearby parameters) 2017-04-03 10:45:24 +02:00
66a20c9ad7 Clear hmd window when no loaded
Without this, the window could be saved in an invalid state.
2017-04-03 03:12:16 +10:00
c68fabee47 Remove ifdef check for file versioning
File patching shouldn't depend on build options
2017-04-03 02:54:59 +10:00
e53d432787 Sync with master and minor formatting 2017-04-03 02:50:56 +10:00
355bbb1d49 use 'use_' as an RNA prefix 2017-04-03 02:24:11 +10:00
1b81d776d7 Correct last commit, also quiet warnings 2017-04-03 02:05:44 +10:00
ea85e2fad3 Use max_ff 2017-04-03 02:03:20 +10:00
52e007dbb2 Fix for building without HMD 2017-04-03 01:43:54 +10:00
9327880109 Merge branch 'master' into HMD_viewport 2017-04-03 01:20:08 +10:00
3bf0026bec fix: T50412 - collada: Replaced precision local limit function by blender's own implementation 2017-04-01 15:29:50 +02:00
7e4a96f0ab Fixes for Windows compile, fixes crashes when trying to open locked devices 2017-04-01 12:59:29 +02:00
e1fb080743 Cleanup: style 2017-04-01 12:09:17 +11:00
06e9f3304c Numeral small fixes from upstream 0.3rc 2017-03-31 17:29:17 +02:00
9d1b98d383 Updated Vive lens correction values, is a decent approximation, needs extra sample points when looking down
Fixed lens seperation
2017-03-31 17:29:17 +02:00
6c42079b78 Depsgraph: Correction for the previous local view commit
Need to flush layers from components back to ID node.
2017-03-31 17:08:18 +02:00
25ab3aac9d Fix threading conflicts in multitex_ext_safe()
This function was modifying texture datablock, which makes the call
unsafe for call from multiple threads. Now we pass the argument that
we don't need nodes to the underlying functions.

There will be still race condition in noise texture, but that should
at least be free from crashes. Doesn't mean we shouldn't fix it tho.
2017-03-31 17:08:18 +02:00
90df1142a3 Cycles: Solve threading conflict in shader synchronization
Update tag might access links (when checking for attributes) and
the links might be in the middle of rebuild in simplification
logic.
2017-03-31 17:08:18 +02:00
27d20a04b5 Fix unreported bug in Blender Render: using unnormalized normal in normal map node in the same way as in baking 2017-03-31 17:53:55 +03:00
ff693959d8 WM: Previous commit broke common-case loading new file
Handle this in the operator
2017-03-31 23:48:10 +11:00
7f7c807a92 Keep current app-template when selecting 'New File' 2017-03-31 22:06:36 +11:00
e5fa738ce9 UI cleanup: simplify Icon handling of uiDefAutoButR for PROP_POINTER.
Comes from D113, but really not related to the patch's topic!
2017-03-31 12:14:27 +02:00
4b7d95290f Cycles: More fixes after include changes 2017-03-31 10:12:13 +02:00
d097c2a1b3 Fix T51072: The reference of a pyobject may be being overwritten in bm_mesh_remap_cd_update
In this case the Pyobject gets lost from pybm, and bm.free() does not invalidate the PyElem.
This will cause the destructor of python to read invalid memory and crash.

The solution is to make a copy of the pyobjects pointers before overwriting.
2017-03-31 01:01:16 -03:00
8bd61ea54d Correct string formatting (error in recent change) 2017-03-31 09:48:57 +11:00
14c2083460 Cleanup: warnings 2017-03-31 09:48:57 +11:00
4cfac9edab Cleanup/fix bad code in IDP_SetIndexArray()
Mainly, using index before checking for its validity...
2017-03-30 22:52:53 +02:00
5b3b0b4778 Redraw parent popup when the child popup is closed 2017-03-30 16:48:18 +03:00
843be91002 Depsgraph: Fix missing updates when in local view
This area is a subject of reconsideration, so for now used simplest
way possible -- ensure depsgraph's nodes have proper layer flags
when going in and out of local mode.
2017-03-30 14:42:55 +02:00
a88801b99b Cycles: Fix missing kernel re-compilation after recent changes
Reported by Mai in IRC, thanks!
2017-03-30 11:45:30 +02:00
ced8fff5de Fix T51051: Incorrect render on 32bit Linux
The issue was apparently caused by -fno-finite-math-only added to kernel.cpp
CFLAGS. For now just removed this flag from the kernel (we don't really want
it there at this point, and we don't have it for SSE/AVX optimized kernels).

But surely more investigation is needed here.
2017-03-30 11:37:31 +02:00
9b1564a862 Cycles: Cleanup, rename RegularBVH to BinaryBVH
Makes it more explicit what the structure is from it's name.
2017-03-30 09:47:27 +02:00
31e6249256 Mirror Modifier: Add offsets for mirrored UVs
The mirror modifier now has two fields that specify a -1 to 1 offset for
the U and V axes when mirroring their coordinates.

D1844 by @circuitfox
2017-03-30 13:15:02 +11:00
66ef0b8834 Cycles: Fix compilation error of app after the include directories change 2017-03-29 16:54:41 +02:00
48fa2c83eb Cycles: Attempt to work around compilation errors of CUDA on sm_2x 2017-03-29 16:22:51 +02:00
be17445714 Cycles: Cleanup, indentation 2017-03-29 15:41:56 +02:00
cc7386ec6b Cycles: Remove toolkit-specific workaround from kernel 2017-03-29 15:07:53 +02:00
5af4e1ca15 Cycles: Only use CUDA 8.0 as officially supported one
This deprecates CUDA 7.5.
2017-03-29 15:06:47 +02:00
270df9a60f Cycles: Cleanup, don't use m_ prefix for public properties 2017-03-29 14:45:49 +02:00
30bed91b78 Cycles: Fix compilation error with visibility flag disabled 2017-03-29 14:28:45 +02:00
0579eaae1f Cycles: Make all #include statements relative to cycles source directory
The idea is to make include statements more explicit and obvious where the
file is coming from, additionally reducing chance of wrong header being
picked up.

For example, it was not obvious whether bvh.h was refferring to builder
or traversal, whenter node.h is a generic graph node or a shader node
and cases like that.

Surely this might look obvious for the active developers, but after some
time of not touching the code it becomes less obvious where file is coming
from.

This was briefly mentioned in T50824 and seems @brecht is fine with such
explicitness, but need to agree with all active developers before committing
this.

Please note that this patch is lacking changes related on GPU/OpenCL
support. This will be solved if/when we all agree this is a good idea to move
forward.

Reviewers: brecht, lukasstockner97, maiself, nirved, dingto, juicyfruit, swerner

Reviewed By: lukasstockner97, maiself, nirved, dingto

Subscribers: brecht

Differential Revision: https://developer.blender.org/D2586
2017-03-29 13:41:11 +02:00
61db9ee27a Cycles: Attempt to workaround compilation error on new CUDA toolkit and sm_2x 2017-03-29 11:50:17 +02:00
c2d3bb7090 Remove non-bmesh case from test 2017-03-29 20:11:54 +11:00
dd662c74ae Fix skin mark operator
Accessed custom-data layer offset before creating.
2017-03-29 20:11:54 +11:00
a7ca991841 Fix crash closing window in background mode 2017-03-29 20:11:54 +11:00
cb6ec44fc7 Fix missing NULL check in gpencil poll
Also de-duplicate poll functions
2017-03-29 20:11:54 +11:00
6332e0e1f7 Use 'empty' option for clearing factory settings 2017-03-29 20:11:54 +11:00
df7f6a3e2e Option to load startup file with empty-data
Useful for batch conversion and tests.
2017-03-29 20:11:54 +11:00
b3f9ae0125 Buildbot: Revert previous change, older toolkit has same exact behavior 2017-03-29 10:48:10 +02:00
15ff75d06b Buildbot: Use older NVCC on 32bit linux
Newer toolkit has some weird issue with cross0-compiling 32bit kernels
from 64bit environment.
2017-03-29 10:21:17 +02:00
ac43e5cc87 Buildbot: Remove global hardcoded NVCC path
This was initially needed for heterogeneous setup of two toolkits which
we no longer need.
2017-03-29 10:16:41 +02:00
286adfde38 Cycles: Bring back preview AA samples when using BPT
This was removed in 93426cb. Please be more accurate when
changing interface.
2017-03-29 09:12:26 +02:00
4c7f4e4662 PyAPI: minor path init simplification 2017-03-29 15:07:41 +11:00
4f69dca547 Fix 'bl_app_override' wrapping multiple times.
Calling `SomeClass.draw(self, context)` instead of `self.draw()`
would try to wrap the argument `self` multiple times, causing an error.
2017-03-29 14:31:14 +11:00
d808557d15 Fix memory leak re-registering operators
Re-registering an operator used by the keymap would lead memory.
Reload scripts for eg leaked over ~1600 blocks.
2017-03-29 13:35:15 +11:00
02b2094847 PyAPI: check modules are registered before unregister
Needed since templates may unregister classes.

Also replace old modules on reloading.
2017-03-29 12:38:02 +11:00
93426cb295 Fix T51068: Place props in their own row
This allows the props to extend into the blank space that is to the right.
2017-03-28 16:33:05 -04:00
6ea54fe9ff Cycles: Switch to reformulated Pluecker ray/triangle intersection
The intention of this commit it to address issues mentioned in the
reports T43865,T50164 and T50452.

The code is based on Embree code with some extra vectorization
to speed up single ray to single triangle intersection.

Unfortunately, such a fix is not coming for free. There is some
slowdown for AVX2 processors, mainly due to different vectorization
code, which caused different number of instructions to be executed
and different instructions-per-cycle counters. But on another hand
this commit makes pre-AVX2 platforms such as AVX and SSE4.1 a bit
faster. The prerformance goes as following:

              2.78c AVX2   2.78c AVX   Patch AVX2         Patch AVX
BMW            05:21.09     06:05.34    05:32.97 (+3.5%)   05:34.97 (-8.5%)
Classroom      16:55.36     18:24.51    17:10.41 (+1.4%)   17:15.87 (-6.3%)
Fishy Cat      08:08.49     08:36.26    08:09.19 (+0.2%)   08:12.25 (-4.7%
Koro           11:22.54     11:45.24    11:13.25 (-1.5%)   11:43.81 (-0.3%)
Barcelone      14:18.32     16:09.46    14:15.20 (-0.4%)   14:25.15 (-10.8%)

On GPU the performance is about 1.5-2% slower in my tests on GTX1080
but afraid we can't do much as a part of this chaneg here and
consider it a price to pay for more proper intersection check.

Made in collaboration with Maxym Dmytrychenko, big thanks to him!

Reviewers: brecht, juicyfruit, lukasstockner97, dingto

Differential Revision: https://developer.blender.org/D1574
2017-03-28 17:26:47 +02:00
69aa6577b3 Forgot those IDP_LibLinkProperty call on node sockets IDProps in previous commit... 2017-03-28 14:38:00 +02:00
59bb4ca1b0 Fix: Icon offset for pie buttons 2017-03-28 13:44:02 +03:00
3f61280327 Cycles: Pass m128 vectors by const reference 2017-03-28 11:01:11 +02:00
e1909958d9 Fix lib_link_cachefile.
That one was:
* Resetting non-ID pointers (lib_link_xxx funcs should only affect ID
  pointers, everything else shall be done in direct_link_xxx func).
* Even worse, always calling lib_link_animdata, even when
  LIB_TAG_NEED_LINK tag was unset...
2017-03-28 10:15:52 +02:00
bed327f1ce Bring back lib_link_mesh() in 'order' with other libdata liblink functions.
We do not need any special handling anymore for usercount of images used
by faces/polygons (tpage stuff), since we have the 'real_user' handling,
which will gracefully cope with all possible situations.

So better not keep that ugly confusing useless special case.
2017-03-28 10:10:15 +02:00
39172c6f34 readfile.c: Cleanup lib_link code a bit.
Mainly:
* Add missing `IDP_LibLinkProperty()` calls for many ID types
  (harmless currently, but better be consistent here!).
* Bring lib_link_xxx functions more in line with each other.
* Replace some long if/else by switch.
2017-03-28 10:03:59 +02:00
1b5acbb329 Correct splash size check 2017-03-28 17:07:37 +11:00
5ce120b865 Fix columns with fixed width 2017-03-28 00:07:31 +03:00
6a5e92c022 Cleanup: Use upper case consistently in adaptive feature compile logging. 2017-03-27 22:52:33 +02:00
7a65f9b171 Cleanup: Resolve todo in CUDA voxel image code. 2017-03-27 22:36:26 +02:00
0df33cc52d Cycles UI: Avoid abreviation for Hair Extension.
Since 2.5x we should try to avoid such abreviations in the UI, except for common terms like Min / Max as much as possible.
2017-03-27 21:59:29 +02:00
0cfc557c5d Cycles: Move Shadow Catcher UI option next to Ray Visibility.
Previously it was beneath the Performance UI label, which was incorrect. It's better suited next to Ray Visibility.
2017-03-27 21:51:56 +02:00
bd053ac7ba Cycles: Correct ifdef around float3 intrinsics 2017-03-27 16:13:07 +02:00
2a05292efa Correct for Py3.5 2017-03-27 21:34:21 +11:00
8d48ea0233 Cycles: Make shadow catcher an optional feature for OpenCL
Solves majority of speed regression on AMD OpenCL.
2017-03-27 10:47:14 +02:00
Hristo Gueorguiev
e07ffcbd1c Cycles: Add OpenCL support for shadow catcher feature
The title says it all actually.
2017-03-27 10:46:59 +02:00
Hristo Gueorguiev
8ada7f7397 Cycles: Remove ccl_addr_space from RNG passed to functions
Simplifies code quite a bit, making it shorter and easier to extend.
Currently no functional changes for users, but is required for the
upcoming work of shadow catcher support with OpenCL.
2017-03-27 10:46:28 +02:00
d14e39622a Cycles: First implementation of shadow catcher
It uses an idea of accumulating all possible light reachable across the
light path (without taking shadow blocked into account) and accumulating
total shaded light across the path. Dividing second figure by first one
seems to be giving good estimate of the shadow.

In fact, to my knowledge, it's something really similar to what is
happening in the denoising branch, so we are aligned here which is good.

The workflow is following:

- Create an object which matches real-life object on which shadow is
  to be catched.

- Create approximate similar material on that object.

  This is needed to make indirect light properly affecting CG objects
  in the scene.

- Mark object as Shadow Catcher in the Object properties.

Ideally, after doing that it will be possible to render the image and
simply alpha-over it on top of real footage.
2017-03-27 10:46:03 +02:00
5aaa643947 Cycles: Optimize shaders earlier to skip unneccessary attributes for noninteractive rendering
Before, Cycles would first sync the shader exactly as shown in the UI, then determine and sync the used attributes and later optimize the shader.
Therefore, even completely unconnected nodes would cause unneccessary attributes to be synced.

The reason for this is to avoid frequent resyncs when editing shaders interactively, but it can still be avoided for noninteractive renders - which is what this commit does.

Reviewed by: sergey

Differential Revision: https://developer.blender.org/D2285
2017-03-27 05:36:49 +02:00
086320a62e CMake: WITH_PYTHON_SECURITY=OFF was ignored
Allow auto-execution to be enabled,
also move this to user-prefs versioning code.
2017-03-27 13:02:41 +11:00
356aacab6b Add back missing include 2017-03-27 09:14:40 +11:00
505b3b7328 Fix padding and align calculation for box layouts 2017-03-26 18:02:11 +03:00
2830f687aa Cleanup: line length, assignment 2017-03-26 21:52:25 +11:00
4bdb2d4885 Fix: Ignore min flag for rows that require all available width 2017-03-26 12:19:01 +03:00
fa63515c37 Fix: Use "round" instead of "floor" in snapping UI to pixels 2017-03-26 12:16:04 +03:00
001fce167a Fix: Button's label can be NULL 2017-03-26 12:04:16 +03:00
ed072e1dcd re-adds the include "BLI_math.h" to custondata
It was removed here rBd52191616b5f
2017-03-26 04:08:16 -03:00
Julian Eisel
3d7ca99c89 Disable zooming/pannig of HMD view while in camera perspective
Applying zoom to projection matrix wouldn't be correct, applying it to
the view matrix would work, but not easy to do it nicely. We'd also
still miss vertical/horizontal offset since it's realized using lens
shifting (= modifiying projection matrix), so that had to be applyied
onto view matrix as well.
Decided to just disallow paning and zooming completely for now, I don't
think it would make much sense in camera perspective.
2017-03-26 01:47:21 +01:00
15143a7464 Cleanup: simplify script path assignment 2017-03-26 11:31:39 +11:00
8c0682a93c PyAPI: add missing class registration 2017-03-26 11:28:16 +11:00
f8e02c75ba PyAPI: debug-python check for missing class register
Moving to manual class registration means its easier to accidentally
miss registering classes.

Now detect missing class registration
and warn when running with `--debug-python`
2017-03-26 11:28:10 +11:00
Julian Eisel
66952dabe8 Fix HMD panel not visible after recent changes in master 2017-03-25 23:03:37 +01:00
Julian Eisel
8081480a86 Merge branch 'master' into HMD_viewport
Conflicts:
	source/blender/blenloader/intern/writefile.c
	source/blender/windowmanager/intern/wm_window.c
2017-03-25 22:15:29 +01:00
393efccb19 Fix GHOST crash on X11 with recent DPI changes on some systems. 2017-03-25 19:32:50 +01:00
Wouter
fe3fb23697 Automatic DPI for all platforms, per monitor DPI for Windows.
For Windows 8.1 and X11 (Linux, BSD) now use the DPI specified by the operating
system, which previously only worked on macOS. For Windows this is handled per
monitor, for X11 this is based on Xft.dpi or xrandr --dpi. This should result
in appropriate font and button sizes by default in most cases.

The UI has been simplified to a single UI Scale factor relative to the automatic
DPI, instead of two DPI and Virtual Pixel Size settings. There is forward and
backwards compatibility for existing user preferences.

Reviewed By: brecht, LazyDodo

Differential Revision: https://developer.blender.org/D2539
2017-03-25 11:22:16 +01:00
86730f1f35 Remove support for py app-templates
Only zip-files make sense here.
2017-03-25 18:14:00 +11:00
7cb2974182 Cleanup: imports, indentation, long lines 2017-03-25 11:07:48 +11:00
a6f74453b6 Fix unreported: inaccuracy of interpolation of custom color layers due to float truncation
Same solution from rBd23459f51640 but now in `layerInterp_mcol`
Also a cleaning was done in the includes
2017-03-24 20:06:43 -03:00
f68145011f WM: Application Templates
This adds the ability to switch between different application-configurations
without interfering with Blender's normal operation.

This commit doesn't include any templates,
so its mostly to allow collaboration for the Blender 101 project
and other custom configurations.

Application templates can be installed & selected from the file menu.

Other details:

- The `bl_app_template_utils` module handles template activation
  (similar to `addon_utils`).
- The `bl_app_override` module is a general module
  to assist scripts overriding parts of Blender in reversible way.

See docs:
https://docs.blender.org/manual/en/dev/advanced/app_templates.html

See patch: D2565
2017-03-25 10:04:04 +11:00
4deff6951d msvc fix in packet.c in PSVR driver 2017-03-24 23:24:30 +01:00
a7f16c17c2 Fix various i18n ambiguous issues reported in T43295. 2017-03-24 20:02:15 +01:00
dab3865c0b Fix UI message issue, and style cleanup (!) 2017-03-24 20:02:15 +01:00
e9770adf63 Cycles: Remove obsolete variable from the TileManager 2017-03-24 19:44:05 +01:00
8e58e197fd Ашч T50995: Wrong freestyle render with new depgraph
The iossue was caused by 0371ef1/
2017-03-24 16:33:26 +01:00
5b45715f8a Cycles: Correct isfinite check used in integrator
Use fast-math friendly version of this function.

We should probably avoid unsafe fast math, but this is to be done with
real care with all the benchmarks properly done.

For now comitting much safer fix.
2017-03-24 15:39:33 +01:00
6aa972ebd4 Fix/workaround T51007: Material viewport mode crash on node with more than 64 outputs
Ideally we need to find a way to remove such a static limit here, but it's not so
trivial to implement for texture nodes. Requires some bigger system redesign there.

Just raising limit for now, which is fine for modern systems.
2017-03-24 14:36:00 +01:00
467d824f80 Fix T50238: Cycles: difference in texture position between OpenGL and Cycles render 2017-03-24 12:24:14 +01:00
e32710d2d7 Buildbot: Use proper NVCC path
In fact, we could probably remove this option all together.
2017-03-24 10:27:41 +01:00
85a5fbf2ce Cycles: Workaround incorrect SSS with CUDA toolkit 8.0.61 2017-03-24 10:08:18 +01:00
a14fb77fee Update CLERW to the latest version 2017-03-24 09:43:03 +01:00
d52191616b Fix for last fix of fix: (unsigned)char is limited to 255
setting char as value outside its range will wrap
2017-03-24 04:35:17 -03:00
178708f142 Fix of last commit. Clamp values that will be used! 2017-03-24 04:13:16 -03:00
d23459f516 Fix T51038: layerInterp_mloopcol was casting instead of rounding the interpolated RGBA channels
Casting to int truncates a floating-point number, that is, it loose the fractional part.
2017-03-24 04:06:30 -03:00
bc0b5d611c Cleanup: minor edits to path test
No need for redundant ID's and correct arg order
2017-03-24 17:48:22 +11:00
50f9fc7a53 BLI_path_util: Add BLI_path_join
There weren't any convenient ways to join multiple paths in C
that accounted for corner cases.
2017-03-24 17:40:35 +11:00
43a1310508 Fixes Oculus CV1 Lens Correction 2017-03-24 05:57:03 +01:00
634067f442 OpenHMD update, disables OVRService upon starting the device, only when run with administrator.
Requires custom build of hidapi for now (github TheOnlyJoey/hidapi)
2017-03-24 02:07:07 +01:00
0453c807e0 Add: BKE_appdir_folder_id_ex
Allows getting the path without using a static string.
2017-03-24 10:35:58 +11:00
6a6566a7fc Cleanup: line-length 2017-03-24 10:11:01 +11:00
096602d3a8 bpy.path.display_name: strip spaces
Useful for Python module paths that can't start with numbers.
2017-03-24 06:55:44 +11:00
05b7591c62 BLI_path_util: Add string versions of SEP, ALTSEP
This allows for adding separators in string literals.
2017-03-24 05:23:03 +11:00
9af6f40e4d addon_utils: add disable_all function 2017-03-24 05:20:26 +11:00
a96110e710 Cycles: Remove old non-optimized triangle intersection function
It is unused now and if we want similar function we should use
Pluecker intersection which is same performance with SSE optimization
but which is more watertight.
2017-03-23 17:59:34 +01:00
27248c8636 Cycles: Remove unused macro 2017-03-23 17:59:02 +01:00
ba8c7d2ba1 Cycles: Use SSE-optimized version of triangle intersection for motion triangles
The title says it all actually. Gives up to 10% speedup on test scenes here
on i7-6800K.

Render times on GPU are unreliable here, but there might be some slowdown
caused by watertight nature of intersections.
2017-03-23 17:58:03 +01:00
a1348dde2e Cycles: Fix speed regression on GPU
Avoid construction of temporary array and make utility function force-inlined.
Additionally avoid calling float4_to_float3 twice.

This brings render times to the same values as before current patch series.
2017-03-23 17:45:19 +01:00
2a5d7b5b1e Cycles: Use utility function for SSS triangle intersection
This effectively de-duplicates triangle intersection logic implemented
for both regular triangle and SSS triangle.
2017-03-23 17:45:19 +01:00
a5b6742ed2 Cycles: Move watertight triangle intersection to an utility file
This way the code can be reused more easily.
2017-03-23 17:45:19 +01:00
f8a999c965 Cycles: Move triangle intersection precalc to an util file
This is a preparation work for the followup commit which wil l move
remaining parts of Woop intersection logic to an utility file.

Doing it as a separate commit to keep changes more atomic and easier
to bisect when/if needed.
2017-03-23 17:45:19 +01:00
b797a5ff78 Cycles: Cleanup, move utility function to utility file
Was an old TODO, this function is handy for some math utilities as well.
2017-03-23 17:45:19 +01:00
aa0602130b Cycles: Cleanup, code style and comments 2017-03-23 17:45:19 +01:00
1c5cceb7af Cycles: Move intersection math to own header file
There are following benefits:

- Modifying intersection algorithm will not cause so much re-compilation.
- It works around header dependency hell and allows us to use vectorization
  types much easier in there.
2017-03-23 17:45:19 +01:00
e8ff06186e Cycles: Cleanup, inline AVX register construction from kernel global data
Currently should be no functional changes, preparing for some upcoming refactor.
2017-03-23 17:45:19 +01:00
5c06ff8bb9 Cycles: Cleanup, remove unused function 2017-03-23 17:45:19 +01:00
e04970b392 Fix player stubs (tm) 2017-03-23 15:47:23 +01:00
2c78b0c71f Collada - Export: now use bind_mat and rest_mat custom properties (when the use_bind_info option is enabled and the properties exist) 2017-03-23 14:14:23 +01:00
b48ba0909a Collada - Import: now add bind_mat and rest_mat as custom properties (when the use_bind_info option is enabled) 2017-03-23 14:14:23 +01:00
476f5c473a Collada - remove no longer used functions (moved to collada_utils) 2017-03-23 14:14:23 +01:00
51d4743033 Collada - Added support for custom bind matrix (using new bind_mat custom property) 2017-03-23 14:14:22 +01:00
6cfa962986 Collada - removed TransformBase baseclass (not needed for anything) 2017-03-23 14:14:22 +01:00
7c094f6079 Collada - Added some helper functions into collada_utils, for common usage in the collada module 2017-03-23 14:14:22 +01:00
092d673689 Added new option for storing bindpose matrix, see T50412 2017-03-23 14:14:22 +01:00
339d0170d1 collada: Simplify reading Node Matrix 2017-03-23 14:14:22 +01:00
1729dd9998 collada: Make sure that bone use_conncet is set to false when connect type is not defined in Import 2017-03-23 14:14:22 +01:00
33e32c341a collada: add extern 'C' for c header includes 2017-03-23 14:14:22 +01:00
ec3989441f fix: collada - Connected bones get their tails set to wrong location when fix leaf nodes option is enabled 2017-03-23 14:14:22 +01:00
1978ac65c4 collada: use local variable to avoid repeated call of bone chain_length_calculator 2017-03-23 14:14:22 +01:00
89631485cc collada: use vector copy function instead of direct assigning 2017-03-23 14:14:22 +01:00
1600b93fb8 UI: allow to extend camera as a menu
Needed for T46853
2017-03-23 20:45:02 +11:00
4f4a484b9b Cloth refactor: Remove goal springs and some other cleanup
This removes the goal springs, in favor of simply calculating the goal forces on the vertices directly. The vertices already store all the necessary data for the goal forces, thus the springs were redundant, and just defined both ends as being the same vertex.

The main advantage of removing the goal springs, is an increase in flexibility, allowing us to much more nicely do some neat dynamic stuff with the goals/pins, such as animated vertex weights. But this also has the advantage of simpler code, and a slightly reduced memory footprint.

This also removes the `f`, `dfdx` and `dfdv` fields from the `ClothSpring` struct, as that data is only used by the solver, and is re-computed on each step, and thus does not need to be stored throughout the simulation.

Reviewers: sergey

Reviewed By: sergey

Tags: #physics

Differential Revision: https://developer.blender.org/D2514
2017-03-23 03:52:46 -03:00
4d82d525f8 Cycles: Fix building for some compilers 2017-03-23 00:14:48 -04:00
a63ba2739e Cleanup: remove redundant temp dir init
This is already called by wm_init_userdef, in old code
different initialization methods were used but now it's not needed.

Confusing since prefs are loaded in this function that don't initialize temp.
2017-03-23 15:05:42 +11:00
12b62b58e1 Cleanup: minor wm_homefile_read simplification
Logic in this function is a bit scattered,
minor changes to avoid confusion.

Also rename 'from_memory' to 'use_factory_settings'.
2017-03-23 10:42:09 +11:00
762319e911 fix redundant assignment
Thanks clang for the warning.
2017-03-22 16:26:53 -04:00
d8b34a17ac Cleanup: remove BLI_getlastdir
Replace with BLI_path_name_at_index
2017-03-23 06:33:30 +11:00
c7a4f96f88 Pydoc: Change Wikipedia links and grammar in mathutils matrix code 2017-03-22 14:54:22 -04:00
2ba1868c3f Cleanup/optimization: Simplify some usages of uiItemFullO/_ptr, avoid multiple search of same op. 2017-03-22 19:42:19 +01:00
387ba87ad3 Cleanup: ignore open-blend as startup/prefs basis
No reason startup/prefs would ever be blend-file relative.
2017-03-23 05:24:05 +11:00
dc5007648c Depsgraph: Fix missing relations update tag when typing #frame
New depsgraph requires relations to be updated after drivers changes.
2017-03-22 14:44:45 +01:00
Stefan Werner
412220c8d3 Cycles: fixed warnings 2017-03-22 12:28:01 +01:00
797b1d5053 Fix T51024: Switch install_deps to set OSL_ROOT_DIR instead of CYCLES_OSL.
Path by @alekulyn, thanks.

Differential Revision: https://developer.blender.org/D2571
2017-03-22 12:05:43 +01:00
2b44db4cfc Fix/workaround T50533: Transparency shader doesn't cast shadows with curve segments
There seems to be a compiler bug of MSVC2013. The issue does not happen on Linux and
does not happen on Windows when building with MSVC2015.

Since it's reallly a pain to debug release builds with MSVC2013 the AVX2 optimization
is disabled for curve sergemnts for this compiler.
2017-03-22 11:37:23 +01:00
8563d3b254 Create correct node after image file drag&drop for Blender Render 2017-03-22 12:00:33 +03:00
d0253b2ea4 BLI_path_util: add BLI_path_name_at_index
Utility to get a file/dir in the path by index,
supporting negative indices to start from the end of the path.

Without this it wasn't straightforward to get
the a files parent directory name from a filepath.
2017-03-22 19:34:43 +11:00
253281f9d6 Fix for splash not opening centered
When the new window didn't end up using the size stored in the preferences
the splash would not be centered (even outside the screen in some cases).

Now centered popups listen for window resizing.
2017-03-22 13:53:54 +11:00
a0f16e12a0 Cycles: Use more friendly GPU device name for AMD cards
For example, for RX480 you'll no longer see "Ellesmere" but will see
"AMD Radeon RX 480 Graphics" which makes more sense and allows to easily
distinguish which exact card it is when having multiple different cards
of Ellesmere codenames (i.e. RX480 and WX7100) in the same machine.
2017-03-21 12:01:11 +01:00
7780a108b3 Cycles: Simplify some extra OpenCL query code 2017-03-21 12:01:03 +01:00
a41240439b Update CLEW to latest version
Needed to get access to some AMD extensions.
2017-03-21 12:01:03 +01:00
fceb1d0781 Cycles: Cleanup, add some utility functions to shorten access to low level API
Should be no functional changes.
2017-03-21 12:01:03 +01:00
eb1a57b12c Cycles: Fix wrong vector allocation in the mesh sync code 2017-03-21 04:30:08 +01:00
8fff6cc2f5 Cycles: Fix building of OpenCL kernels
Theres no overloading of functions in OpenCL so we can't make use of
`safe_normalize` with `float2`.
2017-03-20 22:55:52 -04:00
13d8661503 Fix T51012: Surface modifier was not working with curves
This prevented the Force Field Curve Shape of working
2017-03-20 18:51:32 -03:00
3c4df13924 Fix T50268: Cycles allows to select un supported GPUs for OpenCL 2017-03-20 15:37:27 +01:00
d544a61e8a Cycles: Update remaining time once per second without waiting for a tile change
Previously, the code would only update the status string if the main status changed.
However, the main status did not include the remaining time, and therefore it wasn't updated until the amount of rendered tiles (which is part of the main status) changed.

This commit therefore makes the BlenderSession remember the time of the last status update and forces a status update if the last one was more than a second ago.

Reviewers: sergey

Differential Revision: https://developer.blender.org/D2465
2017-03-20 15:28:36 +01:00
a201b99c5a Fix T50975: Cycles: Light sampling threshold inadvertently clamps negative lamps 2017-03-20 14:48:55 +01:00
6b86b446d3 Cleanup: useless call to glRasterPos before view3d_cached_text_draw_add()
Probably some leftover from much older code?
2017-03-20 14:36:06 +01:00
18bf900b31 Fix T50990: Random black pixels in Cycles when rendering material with Multiscatter GGX 2017-03-20 12:07:41 +01:00
06159e6a58 Correct unintended splash on loading startup 2017-03-20 12:46:20 +11:00
dbc8b81ecf User Preferences: Split out addon and keymap free 2017-03-20 12:42:19 +11:00
eaf88f564c Remove register_module use in Cycles 2017-03-20 12:16:51 +11:00
fa11d41113 Cleanup: especially non pep8 parts of Py UI 2017-03-20 09:49:35 +11:00
df76616d74 Usual UI/i18n message fixes.
Please provide valid description for SurfaceDeform modifier tooltip.
Such place-holders should not pass final checks before merging in master!
2017-03-19 17:31:07 +01:00
19d493ee10 Moving classes to separate listing broke panel order
Although this wasn't so obvious since it
only showed up for factory settings and in the preferences window.

Panel display order depends on registration order,
Sorry for the noise. On the bright side we no longer need to move
classes around to re-arrange panels.
2017-03-20 02:37:55 +11:00
84935998a7 Add missing classes from recent commit 2017-03-20 02:07:24 +11:00
56d3cc9341 PyAPI: ID Property tests 2017-03-19 03:57:40 +11:00
9bdda427e6 PyAPI: remove bpy.utils.register_module()
In preparation for it being removed, see: T47811
2017-03-18 20:03:24 +11:00
2fbc50e4c1 Alternate fix for T50899
object_get_derived_final shouldn't have been assuming mesh objects.

It's even valid to use a curve as a target for a shrink-wrap modifier.
2017-03-18 18:33:01 +11:00
3ceb68c833 Missing from recent commit 2017-03-18 12:33:59 +11:00
e392bb4937 PyAPI: add BPY_execute_string_as_string
Utility to execute a string and get the resulting string,
matching BPY_execute_string_as_number.

Not used just yet but generally useful function.
2017-03-18 12:19:03 +11:00
d863b5182e Cleanup: use return args last and 'r_' prefix. 2017-03-18 09:39:36 +11:00
9d873fc3de Various icon adjustments 2017-03-17 16:57:53 +03:00
ea3d7a7f58 Fix T50968: Cycles crashes when image datablock points to a directory
See more details about root of the cause there:

  https://github.com/OpenImageIO/oiio/pull/1640
2017-03-17 14:47:12 +01:00
d6b4fb6429 Cycles: Fix mistake in previous split kernel commits
Own stupid mistake. Reported by nirved in IRC, thanks!
2017-03-17 11:55:59 +01:00
502c4be56e fix: redraw dope sheet / action editor when pose bone selection changes 2017-03-17 11:04:13 +01:00
a58350b07f Cycles: Cleanup, indentation 2017-03-17 10:25:37 +01:00
98b81493f3 Refactor writefile handling of data-blocks.
Instead of calling a function looping over whole list of a given ID
type, make whole loop over Main in parent function, and call functions
writing a single datablock at a time.

This design is more in line with all other places in Blender where we
handle whole content of Main (including readfile.c), and much more easy
to extend and add e.g. some generic processing of IDs before/after
writing, etc.

From user point, there should be no change at all, only difference is
that data-block types won't be saved in same order as before (.blend
file specs enforces no order here, so this is not an issue, but it could
bug some third party users using other, simplified .blend file reader maybe).

Reviewers: sergey, campbellbarton

Differential Revision: https://developer.blender.org/D2510
2017-03-17 10:02:08 +01:00
e361adbca2 Cycles: Fix compilation error of LCG RNG 2017-03-17 09:58:08 +01:00
439a277aa5 Cycles: Silence strict compiler warning 2017-03-17 09:56:44 +01:00
2cae58524c Cycles: Improve memory usage of CPU split kernel by using smaller global size 2017-03-17 01:54:10 -04:00
60a344b43d Cycles: Fix handling of barriers 2017-03-17 01:54:04 -04:00
b27e224276 Mesh Convert: remove meaningless modifier check
Meshes w/o modifiers wouldn't have their derived mesh applied.
Check was to avoid crash but its in fact meaningless,
since the modifier might be disabled, or there may be virtual modifiers.
2017-03-17 10:10:55 +11:00
750c0dd4de Fix T50950: Converting meshes fails w/ boolean 2017-03-17 09:58:05 +11:00
d4d8da28fc Add BKE_blendfile_userdef_read_from_memory
Needed to read user-preferences from in-memory startup.blend

Also skip data-blocks when reading preferences.
2017-03-17 07:01:48 +11:00
b2d3956e7b Add support for loading preference struct
Previously it would always load into 'U' global.
Needed for loading & merging template preferences.
2017-03-17 05:20:50 +11:00
db04980678 PyAPI: Menu.path_menu: Add path filter callback
Needed if we want to filter based on filenames (not just extension).
2017-03-17 05:20:50 +11:00
f7793bd53c Correct reading missing property 2017-03-17 05:20:50 +11:00
1f65ab606b Fix missing undo pushes in outliner's new datablock management operations.
Not sure why I did not put those from start... Actually *not* having an
undo point here can be problematic, since undoing some previous action
was trying to restore from bad pointer (I think) in UI, generating
asserts.

Note however that it's not a 'pure' undo, in that you may not find your
linked data in exact same state as before deleting it, after an undo,
since it actually implies *reloading* the deleted libraries (and not
restoring from a previously stored memory dump).

Reported by @sergey, thanks.
2017-03-16 17:05:48 +01:00
fa9bd04483 Fix outliner contextual menu allowing to delete indirect libraries.
There is no way currently to prevent the option from showing in menu, so
instead report a warning to user (and curse again current nightmarish
system of operation in outliner...).

Reported by @sergey, thanks.
2017-03-16 17:05:48 +01:00
0434053f13 Depsgraph: Fixed crash with curve bevel indirect dupligroups
Need to expand all object's dupli-groups, not only the dupli-groups
of objects directly linked to the scene.
2017-03-16 15:35:21 +01:00
68e58f1991 Depsgraph: Use string and vector in the DEG namespace only 2017-03-16 15:35:21 +01:00
6d8875bd61 Depsgraph: Don't use explicit values in runtime only enum
Lower risk of forgetting to update some values here.
2017-03-16 15:35:21 +01:00
c4e07dd29b Cleanup: differentiate startup/prefs in home-file reading 2017-03-17 00:42:13 +11:00
aad9dd2f1b Support passing in UserDef for free function
Needed so we can load and free non-global user preferences.
2017-03-17 00:18:20 +11:00
1cad64900e Cycles: Define ccl_local variables in kernel functions
Declaring ccl_local in a device function is not supported
by certain compilers.
2017-03-16 11:27:17 +01:00
1ff753baa4 Cycles: Workaround for compilation error caused by passing KernelGlobals
Pass globals as a bare pointer, same as it sued to be prior to split kernel rework.

AMD CPU platform and Intel OpenCL were complaining about this.

Perhaps we shouldn't pass globals as pointer at all, this isn't something what is
really portable and can cause issues on 32 bit perhaps.
2017-03-16 11:27:17 +01:00
26620f3f87 Cycles: Avoid some ccl_local in various kernels 2017-03-16 11:27:17 +01:00
4833a71621 Cycles: Adjust global size for OpenCL CPU devices to make them faster 2017-03-16 06:11:42 -04:00
d68a84d1d2 Fix BGE building.
When you use typedef'ed enum, you need to define all supported values
explicitely in enum, else compiler goes grumpy...
2017-03-16 10:30:02 +01:00
375ede0f3f Comments: wmOperator.cancel & modal 2017-03-16 06:39:09 +11:00
68496c0b38 Missed BGE in recent commit 2017-03-16 06:28:20 +11:00
c832354e33 Load user-preferences before startup file
Internal change needed for template support.
Loading the user preferences first so it's possible
for preferences to control startup behavior.

In general it's useful to load preferences before data-files,
so we know security settings for eg.
2017-03-16 04:02:24 +11:00
c44cdd5905 Cycles: Allow rendering a range of resumable chunks
The range is controlled using the following command line arguments:

  --cycles-resumable-start-chunk
  --cycles-resumable-end-chunk

Those are 1-based index of range for rendering.
2017-03-15 16:00:01 +01:00
c5dba540d7 Cycles: Use argument parser for resumable render feature
Currently there is no functional changes, but we will be adding
couple more of options here soon.
2017-03-15 16:00:01 +01:00
Dalai Felinto
81dc8dd42a Fix bug on Blender version string
Reported by Pablo Vazquez (venomgfx) over irc.
2017-03-15 15:42:01 +01:00
Dalai Felinto
c6c85a8c6b Move Blender version string handling to its own function
Planning to use this util function in 2.8 for doversioning (to communicate converted layers)
2017-03-15 14:10:20 +01:00
af1d9ecd40 Fix strict compiler warning in the previous commit 2017-03-15 12:48:07 +01:00
9ad252d157 Fix T50938: Cache not being reset when changing simulation settings with new depsgraph
The thing i'm really starting to hate is the requirement to specify both
operation code and node type. Seems to be duplicated enums without real
need for that.
2017-03-15 11:10:42 +01:00
6a5487e021 BGE: Fix blenderplayer stub.
Add dummy definition of WM_operator_is_repeat.
2017-03-14 21:17:40 +00:00
f13c729b26 WM: free operators when repeating
Needed since the active operator isn't ensured to be the last.
2017-03-15 05:37:42 +11:00
647fb6ef1e fix D2552: Collada - Follow up change to complete the fix in rBda6cd7762810 (use unique id for bones with same name in different armatures) 2017-03-14 19:31:25 +01:00
4877c9362a Collada simplify: avoid duplicate negation in boolean 2017-03-14 19:31:25 +01:00
76ec329dd1 WM: add Operator.is_repeat() check for C & Py
This addresses an issue raised by D2453 -
that there was no way to check if operators are run
multiple times in a row.

Actions are still ignored that don't cause an UNDO event.
2017-03-15 03:57:01 +11:00
1208792adb WM: store operators with undo flag
This is needed so we can tell if operators are executed repeatedly.
2017-03-15 03:57:01 +11:00
582f9ddeb7 Update path_menu for recent API change 2017-03-15 03:57:01 +11:00
5ba51de84a Cycles: Cleanup, indentation 2017-03-14 16:54:16 +01:00
43f7d5643f Fix T50926: python crashes with path containing utf8 characters.
Default text encoding is platform-dependent in python, and windows
usually do not use utf-8 as default...
2017-03-14 16:04:45 +01:00
Jon Allee
da6cd77628 fix D2552: Collada - use unique id for bones with same name but in different armatures. Co-authored-by: Gaia <gaia.clary@machiniamtrix.org> 2017-03-14 14:35:51 +01:00
f3ff03b3c1 CLNor: rework threaded computation.
Was using some threaded queue on top of task pool, tssk...

Now using properly task pool directly to crunch chunks of smooth fans.

No noticable changes in speed.

Tried to completely get rid of the 'no threading with few loops' code,
but even just creating/freeing the task pool, without actually pushing
any task, is enough to make code 50% slower in worst case scenario (i.e.
few thousands of simple cube objects).
2017-03-14 12:54:57 +01:00
284701e371 CLNor code: use averaged debug timing. 2017-03-14 12:54:57 +01:00
1410ea0478 Fix T50876: Cycles Crash - Cycles crashes before sampling when certain meshes have autosmooth enabled.
The root of the issue was in custom normal code, so far it assumed that
we could only have one cyclic smooth fan around each vertex, which is...
blatantly wrong (again, the two cones sharing same vertex tip e.g.).

This required a rather deep change in how smooth fans/clnor spaces are processed,
took me some time to find a 'good' solution.

Note that new code is slightly slower than previous one (maybe about 5%),
not much to be done here, am afraid.

Tested against all older report files I could find, seems OK.
2017-03-14 12:54:57 +01:00
521133682c Fix own mistake in recent 'edge split' refactor.
We do can have some vertices to split, while not having any edge (think
about two cones sharing the same tip vertex e.g.).
2017-03-14 12:54:57 +01:00
8dd0355c21 Cycles: Try to avoid infinite loops by catching invalid ray states 2017-03-14 06:22:57 -04:00
0ee1cdab7e WM: Option to load startup w/o closing the splash
Not user visible, needed for switching templates.
2017-03-14 21:05:00 +11:00
4c5374d46a PyAPI: extend Menu.path_menu
- Add optional 'display_name' callback
  so callers can construct own names.
- Add optional 'prop_filepath' argument
  (for operators that don't use "filepath").
- Add doc-string.
- Use keyword only arguments.
2017-03-14 21:00:55 +11:00
810982a95c Fix T50932: depth picking w/ pose-bone constraints 2017-03-14 18:02:27 +11:00
76acaefdd7 Cycles: Cleanup, wipe obviously outdated parts of split kernel comments 2017-03-13 17:16:16 +01:00
0c72008592 fix msvc warnings about unknown opencl pragmas 2017-03-13 10:08:14 -06:00
aa36c73c33 Cycles: Add missing header in the file 2017-03-13 16:59:09 +01:00
2b3cc24388 Fix T50920: Adds missing edges on return of bisect operator 2017-03-13 09:22:11 -03:00
Hristo Gueorguiev
f169ff8b88 Fix T50925: Add AO approximation to split kernel 2017-03-13 11:15:58 +01:00
8794a43b68 Cycles: Make MESA compiler more happy
While this compiler is not officially supported yet, getting it to work is
a nice thing because more and more AMD cards will fall under MESA driver.

It's also nice to use explicit comparison with NULL, which makes it more
clear whether variable is a boolean or pointer. Even Rust enforces this!

Patch by Ian Bruce with own modifications.
2017-03-13 09:57:25 +01:00
e8021f5e3b UI: expose mesh conversion in apply menu
The mesh convert operator can 'freeze' a mesh
(WYSIWYG, modifiers, shape keys etc).
However its not very obvious that the way to perform this
operation is to convert a mesh to a mesh.

Expose this as 'Visual Geometry to Mesh' in the 'Apply' menu,
since this is where users might expect to see it.
2017-03-13 07:33:24 +11:00
10404e3e56 Comments: minor clarification 2017-03-13 07:18:28 +11:00
b759d3c9c5 fix T50923: Inconsistent default values and wrong order of parameters in api call 2017-03-12 20:31:51 +01:00
18ed060bc3 Fix T50930 Typo in 'jpeg2k_codec' description 2017-03-12 13:56:25 -04:00
6521307dcd BMesh: rename cryptic functions
Use expanded names for bmesh primitive operations
(urmv jvke semv jfke).

Use 'bmesh_kernel_' prefix,
these functions aren't intended for wide use so favor readability.

Remove BM_face_vert_separate,
it wasn't used and only skipped step of finding correct loop of face.
2017-03-13 04:39:20 +11:00
f28376d8d9 Cleanup: style 2017-03-13 04:39:20 +11:00
Julian Eisel
8ca11f5b72 UI: Always open enum-search popups with empty search string
It might be useful to keep the search string stored in some cases, but
in most it's not useful but confusing. Especially if the string is taken
from a menu showing a different enum.
2017-03-12 18:14:43 +01:00
3f94836922 Fix T50788: blender startup crash on macOS with some types of volumes available. 2017-03-12 18:03:15 +01:00
68ca973f7f Fix T50628: gray out cycles device menu when no device configured only for GPU Compute. 2017-03-12 18:00:17 +01:00
76015f98ae Fix icon alignment for pie buttons 2017-03-11 22:34:09 +03:00
bcc8c04db4 Cleanup: code style & cmake 2017-03-12 02:47:53 +11:00
98045648ab Add support for Objects in Drive variable Rotational Difference
Thus it is according to the Manual
https://docs.blender.org/manual/en/dev/animation/drivers/drivers_panel.html#driver-variables
2017-03-11 10:43:23 -03:00
304315d181 BMesh: Fix BM_face_loop_separate_multi
When the loop region passed in had no loops to edge-split from,
it was assumed nothing needed to be done.

This ignored the case where loops share a vertex
without any shared edges.

Now BM_face_loop_separate_multi behaves like BM_face_loop_separate.

Fixed error where faces remained connected by verts in BM_mesh_separate_faces.
2017-03-11 23:26:44 +11:00
ce155ad2f6 Correct recent bmesh separate addition
- Was setting flag incorrectly to avoid re-use.
- Check edge has loops before accessing.
2017-03-11 23:26:13 +11:00
96868a3941 Fix T50888: Numeric overflow in split kernel state buffer size calculation
Overflow led to the state buffer being too small and the split kernel to
get stuck doing nothing forever.
2017-03-11 05:39:28 -05:00
5afe4c787f BMesh: add BM_mesh_separate_faces
Fast-path for bmesh split operator which duplicates and deletes.
Use when only separating faces, currently used by the intersect tool.
2017-03-11 20:50:32 +11:00
5be8adf8c0 Makefile: set tab width=4 2017-03-11 20:48:12 +11:00
f667593b6a Fix text and icon positioning issue on high DPI, after recent changes in 32c5f3d. 2017-03-11 04:47:22 +01:00
2d3c44389a Fix OpenCL warnings about doubles on some platforms. 2017-03-11 00:55:23 +01:00
c374e9f1f5 Breakdowner - Constrain Transform and Axis
This commit adds new features to the breakdowner, giving animators more
control over what gets interpolated by the breakdowner. Specifically:

   "Just as G R S let you move rotate scale, and then X Y Z let you do that
   in one desired axis, when using the Breakdower it would be great to be
   able to add GRS and XYZ to constrain what transform / axis is being
   breakdowned."

As requested here:
https://rightclickselect.com/p/animation/csbbbc/breakdowner-constrain-transform-and-axis


Notes:
* In addition to G/R/S, there's also B (Bendy Bone settings and C (custom properties)
* Pressing G/R/S/B/C or X/Y/Z again will turn these constraints off again
2017-03-11 11:53:45 +13:00
b6713dcbe5 rBa81ea408367abe2f33b351ff6dcc6b09170fd088 "object" -> "target" 2017-03-10 13:54:06 -03:00
a81ea40836 fix T50899: Even though the Shrinkwrap options hide the possibility of using a non-mesh target, you can still circumvent this... Causing Crash 2017-03-10 13:51:04 -03:00
103ae04fbc Correct glPixelTransfer function 2017-03-11 03:03:47 +11:00
15eb83c8b3 Fix T50900: Text-Blocks created from "Edit Source" have zero users. 2017-03-10 15:43:33 +01:00
9d6acc34a1 Fix useless allocation of edge_vectors in threaded case of loop split generation. 2017-03-10 15:43:33 +01:00
59fd21296a Cycles: Cleanup, extra semicolon and space 2017-03-10 15:38:30 +01:00
17b3097205 Adjust kmi header 2017-03-10 15:10:40 +03:00
6038583909 Cleanup: struct flags for select picking 2017-03-10 21:47:43 +11:00
3dbb560331 Cleanup: rename drawObjectSelect
After adding draw_object_select, noticed a similar name.
Rename drawObjectSelect to draw_object_selected_outline.
2017-03-10 21:27:33 +11:00
12e681909f Fix T47690: Connected PET w/ individual origins
- Connectivity length was overwritten by distance to closest selected.
- Vertices used the 'island' center of the closest vertex,
  even if it wasn't connected.

Now optionally keep track of the original index of used as the closest
connected distance.

To support this needed to add optional support for islands of 1 vertex.
2017-03-10 20:27:23 +11:00
4a2cde3f0e Cycles: Enable SSS and volumes for CUDA and Nvidia OpenCL split kernel 2017-03-10 02:09:41 -05:00
17689f8bb6 Fix T50904: Imprecise timeline frame selection using mouse
The changes introduced in rB3e628eefa9f55fac7b0faaec4fd4392c2de6b20e
made the non-subframe frame change behaviour less intuitive, by always
truncating downwards, instead of rounding to the nearest frame instead.
This made the UI a lot less forgiving of pointing precision errors
(for example, as a result of hand shake, or using a tablet on a highres scren)

This commit restores the old behaviour in this case only (subframe inspection
isn't affected by these changes)
2017-03-10 15:07:17 +13:00
62cc226101 3D View: x-ray support for depth picking
Selection loop would draw the selection ignoring xray.
Now draw in a separate pass after clearing the depth buffer,
as with regular drawing.

Also disable depth sorting,
caller can sort the hit-list by depth if needed.
2017-03-10 05:00:49 +11:00
Hristo Gueorguiev
9de9f25b24 Cycles: add single program debug option for split kernel
Single program generally compiles kernels faster (2-3 times), loads faster,
takes less drive space (2-3 times), and reduces the number of cached kernels.
2017-03-09 17:09:37 +01:00
Hristo Gueorguiev
06c051363b Cycles: split kernel_shadow_blocked to AO & DL parts
Reduces memory allocation for split kernel.

This allows for faster rendering due to bigger global size,
specially when GPU memory is limited.

Perfromance results:

                         R9 290 total render time
                        Before    After   Change
BMW                      4:37      4:34   -1.1 %
Classroom               14:43     14:30   -1.5 %
Fishy Cat               11:20     11:04   -2.4 %
Koro                    12:11     12:04   -1.0 %
Pabellon Barcelona      22:01     20:44   -5.8 %
Pabellon Barcelona(*)   15:32     15:09   -2.5 %

(*) without glossy connected to volume
2017-03-09 17:09:37 +01:00
Hristo Gueorguiev
e8b5a5bf5b Cycles: Speedup transparent shadows in split kernel
This commit enables record-all transparent shadows rays.

Perfromance results:

               R9 290 render time (without synchronization), seconds
                        Before    After   Change
BMW                      261.5    262.5   +0.4 %
Classroom                869.6    867.3   -0.3 %
Fishy Cat                657.4    639.8   -2.7 %
Koro                    1909.8    692.8  -63.7 %
Pabellon Barcelona      1633.3   1238.0  -24.2 %
Pabellon Barcelona(*)   1158.1    903.8  -22.0 %

(*) without glossy connected to volume
2017-03-09 17:09:37 +01:00
Hristo Gueorguiev
57e26627c4 Cycles: SSS and Volume rendering in split kernel
Decoupled ray marching is not supported yet.

Transparent shadows are always enabled for volume rendering.

Changes in kernel/bvh and kernel/geom are from Sergey.
This simiplifies code significantly, and prepares it for
record-all transparent shadow function in split kernel.
2017-03-09 17:09:37 +01:00
Dalai Felinto
6c942db30d Remove (ifdef) draw_documentation from text_draw.c
This was no longer supported.
2017-03-09 17:02:35 +01:00
88e8e7a074 3D View: wrap GPU_select cache calls
Avoids including GPU_select and makes it more clear that the cache is
needed for view3d_opengl_select calls.

Also use typed enum for select mode.
2017-03-09 20:47:37 +11:00
4ab322fdd2 3D View: use cache for armature select 2017-03-09 09:25:33 +11:00
c837bd5ea5 Cycles: Fix CUDA build error for some compilers
Needed to include `util_types.h` before using `uint`.
2017-03-08 16:44:43 -05:00
45b764e95b 3D View: new nethod of opengl selection
Intended to replace legacy GL_SELECT, without the limitations of
sample queries which can't access depth information.

This commit adds VIEW3D_SELECT_PICK_NEAREST and VIEW3D_SELECT_PICK_ALL
which access the depth buffers to detect whats under the pointer,
so initial selection is always the closest item.

The performance of this method depends a lot on the OpenGL
implementations glReadPixels.

Since reading depth can be slow, buffers are cached for object picking
so selecting re-uses depth data, performing 1 draw instead of 3
(for 24, 18, 10 px regions, picking with many items under the pointer).

Occlusion queries draw twice when picking nearest,
so worst case 6x draw calls per selection.

Even with these improvements occlusion queries is faster on AMD hardware.

Depth selection is disabled by default, toggle option under select method.
May enable by default if this works well on different hardware.

Reviewed as D2543
2017-03-09 06:22:02 +11:00
817e975dee Fix T50849: Transparent background produces artifacts in this compositing setup
The issue was caused by sometimes negative color returned by the filter node.

Seems to be caused by precision issues. Don't see any reason why we would want
negative colors in output. Those only causing issues later on.
2017-03-08 15:56:50 +01:00
97c4c2689f Cycles: Make it more obvious message which initialization failed 2017-03-08 13:57:21 +01:00
05dfe9c318 Fix T49603: Blender/Cycles 2.78 CUDA error on Jetson-TX1~
Patch by Bruno d'Arcangeli (@arcangeli), thanks!
2017-03-08 13:38:01 +01:00
c24d045a23 OpenGL Select: integer rect for passing region 2017-03-08 23:23:39 +11:00
9af0c8b00a Cleanup: replace short -> int for selection hits 2017-03-08 23:23:39 +11:00
6f3f891c58 Rename BLI_rct*_init_pt_size -> radius 2017-03-08 23:23:39 +11:00
75cb4850f0 Cycles: Use 1-based line number for #line directives
AMD CPU platform was complaining about #line 0 directives in the code.
2017-03-08 12:45:18 +01:00
ecfbfe478b Cycles: Log which device kernels are being loaded for 2017-03-08 12:33:51 +01:00
712f7c3640 Cycles: Make it possible to access KernelGlobals from split data initialization function 2017-03-08 11:02:54 +01:00
ef7c36f5ed Cycles: Cleanup, remove residue of previous split kernel data
This is all in split data state array.
2017-03-08 10:26:29 +01:00
a095611eb8 Fix T50886: Blender crashes on render
Was a mistake in one of the previous TLS commits.

See comment in the pool_create to see some details why it was crashing.
2017-03-08 09:41:38 +01:00
3505be8361 update theme back to black re: T50869 2017-03-08 18:31:24 +11:00
64751552f7 Cycles: Fix indentation 2017-03-08 01:31:32 -05:00
fe7cc94dfa Cycles: Fix strict warning about unused variable 2017-03-08 01:31:32 -05:00
306034790f Cycles: Calculate size of split state buffer kernel side
By calculating the size of the state buffer in the kernel rather than the host
less code is needed and the size actually reflects the requested features.

Will also be a little faster in some cases because of larger global work size.
2017-03-08 01:31:30 -05:00
997e345bd2 Cycles: Fix crash after failed kernel build
Pointers to kernels were uninitialized leading to freeing of random memory
addresses. Another reason it would be good to use smart pointers.
2017-03-08 01:31:09 -05:00
18e50927f7 Cycles: Faster building of split kernel
Simple change to make it so that only kernels that have been modified are
rebuilt. Might only be useful during development.
2017-03-08 01:31:09 -05:00
223f45818e Cycles: Initialize rng_state for split kernel
Because the split kernel can render multiple samples in parallel it is
necessary to have everything initialized before rendering of any samples
begins. The code that normally handles initialization of
`rng_state` (`kernel_path_trace_setup()`) only does so for the first sample,
which was causing artifacts in the split kernel due to uninitialized
`rng_state` for some samples.

Note that because the split kernel can render samples in parallel this
means that the split kernel is incompatible with the LCG.
2017-03-08 01:31:09 -05:00
cd7d5669d1 Cycles: Remove sum_all_radiance kernel
This was only needed for the previous implementation of parallel samples. As
we don't have that any more it can be removed.

Real reason for removal tho is this: `per_sample_output_buffers` was being
calculated too small and artifacts resulted. The tile buffer is already
the correct size and calculating the size for `per_sample_output_buffers`
is a bit difficult with the current layout of the code. As
`per_sample_output_buffers` was only needed for `sum_all_radiance`,
removing that kernel and writing output to the tile buffer directly
fixes the artifacts.
2017-03-08 01:31:07 -05:00
4cf501b835 Cycles: Split path initialization into own kernel
This makes it easier to initialize things correctly in the data_init kernel
before they are needed by path tracing.
2017-03-08 01:30:43 -05:00
5b8f1c8d34 Cycles: Seperate kernel loading time from render time 2017-03-08 01:24:55 -05:00
b78e543af9 Cycles: Add names to buffer allocations
This is to help debug and track memory usage for generic buffers. We
have similar for textures already since those require a name, but for
buffers the name is only for debugging proposes.
2017-03-08 01:24:55 -05:00
817873cc83 Cycles: CUDA implementation of split kernel 2017-03-08 01:24:53 -05:00
0892352bfe Cycles: CPU implementation of split kernel 2017-03-08 00:52:41 -05:00
352ee7c3ef Cycles: Remove ccl_fetch and SOA 2017-03-08 00:52:41 -05:00
a87766416f Cycles: Report device maximum allocation and detected global size 2017-03-08 00:52:41 -05:00
365a4239c5 Cycles: Workaround for driver hangs
Simple workaround for some issues we've been having with AMD drivers hanging
and rendering systems unresponsive. Unfortunately this makes things a bit
slower, but its better than having to do hard reboots. Will be removed when
drivers have been fixed.

Define CYCLES_DISABLE_DRIVER_WORKAROUNDS to disable for testing purposes.
2017-03-08 00:52:41 -05:00
230c00d872 Cycles: OpenCL split kernel refactor
This does a few things at once:

- Refactors host side split kernel logic into a new device
  agnostic class `DeviceSplitKernel`.
- Removes tile splitting, a new work pool implementation takes its place and
  allows as many threads as will fit in memory regardless of tile size, which
  can give performance gains.
- Refactors split state buffers into one buffer, as well as reduces the
  number of arguments passed to kernels. Means there's less code to deal
  with overall.
- Moves kernel logic out of OpenCL kernel files so they can later be used by
  other device types.
- Replaced OpenCL specific APIs with new generic versions
- Tiles can now be seen updating during rendering
2017-03-08 00:52:41 -05:00
520b53364c Cycles: Add OpenCL kernel for zeroing memory buffers
Transferring memory to the device was very slow and there's really no
need when only zeroing a buffer.
2017-03-08 00:52:41 -05:00
dfd6055eb0 Cycles: Add more atomic operations 2017-03-08 00:52:41 -05:00
bc652766e8 Cycles: Expose passes size to device tasks
This is needed so devices can know the size of a tile buffer before any
tiles are acquired.
2017-03-08 00:52:41 -05:00
0f56f7a811 Cycles: Allow device_memory to be used directly
This is useful for when theres no host side memory attched to the buffer
2017-03-08 00:52:41 -05:00
9e566b06e3 Task scheduler: Add concept of suspended pools
Suspended pools allows to push huge amount of initial tasks
without any threading synchronization and hence overhead.

This gives ~50% speedup of cached rigid body with file from
T50027 and seems to have no negative affect in other scenes
here.
2017-03-07 17:32:01 +01:00
347410a322 Depsgraph: Remove workarounds from depsgraph for keeping threads alive
This is something what should be done in the task scheduler instead
with local thread queues so we handle this in a single place.
2017-03-07 17:32:01 +01:00
55c2cd85f0 Task scheduler: Initial implementation of local tasks queues
The idea is to allow some amount of tasks to be pushed from working
thread to it's local queue, so we can acquire some work without doing
whole mutex lock.

This should allow us to remove some hacks from depsgraph which was
added there to keep threads alive.
2017-03-07 17:32:01 +01:00
2f722f1a49 Task scheduler: Use real pthread's TLS to access active thread's data
This allows us to avoid TLS stored in pool which gives us advantage of
using pre-allocated tasks pool for the pools created from non-main thread.

Even on systems with slow pthread TLS it should not be a problem because
we access it once at a pool construction time. If we want to use this more
often (for example, to get rid of push_from_thread) we'll have to do much
more accurate benchmark.
2017-03-07 17:32:01 +01:00
a07ad02156 Task scheduler: Refactor the way we store thread-spedific data
Basically move all thread-specific data (currently it's only task
memory pool) from a dedicated array of taskScheduler to TaskThread.
This way we can add more thread-specific data in the future with
less of a hassle.
2017-03-07 17:32:01 +01:00
9522f8acf0 Task scheduler: Remove per-pool threads limit
This feature was adding extra complexity to task scheduling
which required yet extra variables to be worried about to be
modified in atomic manner, which resulted in following issues:

- More complex code to maintain, which increases risks of
  something going wrong when we modify the code.

- Extra barriers and/or locks during task scheduling, which
  causes extra threading overhead.

- Unable to use some other implementation (such as TBB) even for
  the comparison tests.

Notes about other changes.

There are two places where we really had to use that limit.

One of them is the single threaded dependency graph. This will
now construct a single-threaded scheduler at evaluation time.
This shouldn't be a problem because it only happens when using
debugging command line arguments and the code simply don't
run in regular Blender operation.

The code seems a bit duplicated here across old and new
depsgraph, but think it's OK since the old depsgraph is already
gone in 2.8 branch and i don't see where else we might want
to use such a single-threaded scheduler.

When/if we'll want to do so, we can move it to a centralized
single-threaded scheduler in threads.c.

OpenGL render was a bit more tricky to port, but basically we
are using conditional variables to wait background thread to
do all the job.
2017-03-07 17:32:01 +01:00
Julian Eisel
abe2669720 Use projection matrix from OpenHMD even if "Rotation from HMD" is disabled
Was actually applying IPD wrongly, should be correct now.
2017-03-07 17:26:36 +01:00
35d78121f0 Fix typo in command line arg list 2017-03-07 09:07:58 -05:00
Julian Eisel
cecbb727ac Merge branch 'master' into HMD_viewport 2017-03-07 12:41:10 +01:00
Julian Eisel
af076031d6 Update keymap presets for recent transform manipulator changes
Part of T50565.
2017-03-07 11:54:40 +01:00
Julian Eisel
ca796f872e Once more T50565: Allow using planar constraints for scale manipulator 2017-03-07 11:23:07 +01:00
Julian Eisel
08870e72bc Draw additional viewport info in HMD view again (3D-cursor, mini-axis, etc)
On most (if not all) devices the stuff close to view borders won't be
visible because it's out of the field of view. Ideally we'd calculate their
positions based on the FOV, but that's for later.
2017-03-06 22:34:05 +01:00
Julian Eisel
66026afd69 Correction to previous commit, unset shader after session end
Also two other minor correcions.
2017-03-06 22:28:08 +01:00
Julian Eisel
fc0fb35df5 Don't draw HMD view lens shader if session is not running 2017-03-06 21:15:13 +01:00
Julian Eisel
96ef1beb58 Fixup Python UI definition after lens shader removal 2017-03-06 21:03:58 +01:00
Julian Eisel
af3917049b Refactor split-view drawing to make popups readable 2017-03-06 20:58:43 +01:00
Julian Eisel
982c41b549 Fix fragment shader compile error on Intel GPUs 2017-03-06 20:58:43 +01:00
15fa806160 Rigid body: fix viewport not updating on properties change. 2017-03-06 16:25:47 +01:00
f1c764fd8f Fix width calculation for split layouts 2017-03-06 16:35:56 +03:00
0e995e0bfe Cycles: Fix strict -Wpedantic warnings with GCC
Patch by Stefan Werner, thanks!
2017-03-06 14:18:26 +01:00
b498db06eb Task scheduler: Cleanup, use BLI_assert() instead of assert() 2017-03-06 11:33:27 +01:00
3623f32b48 FFmpeg: Update for the deprecated API in 3.2.x
Should be no functional changes.
2017-03-06 10:34:57 +01:00
355ad008a2 Surface Deform Modifier: Respect object transforms at bind time
This slightly changes SDef behavior, by now respecting object transforms
at bind time, thus not requiring the objects to be aligned in their
respective local spaces, but instead using world space.
2017-03-06 03:43:26 -03:00
bed9bf1907 Bunch of small HMD fixes, removed old now unused preferences 2017-03-06 02:18:16 +01:00
Julian Eisel
5605db8611 Merge branch 'master' into HMD_viewport
Conflicts:
	source/blender/windowmanager/wm.h
2017-03-06 02:13:55 +01:00
Julian Eisel
7015b229d1 Fixup for python UI definition 2017-03-06 02:13:22 +01:00
a5d19a22b7 Fixes for HMD support windows build (thanks LazyDodo) 2017-03-06 01:34:32 +01:00
Julian Eisel
80444effc6 Multi-View: Map cursor coordinates to visual coordinates
When rendering multi-view in side-by-side or top-bottom mode, we squash
the UI to half of its size and draw it twice on screen. That means the
cursor coordinates used for UI interaction don't match what's visible on
screen.
This commit is a little event system hack (tm) to fix this. It has some
small glitches with cursor grabbing, but nothing to bad.
We'll also use it for viewport HMD support.

D1350, thanks for the feedback @dfelinto!
2017-03-06 01:32:35 +01:00
1d1ba540bb New OpenHMD 0.3rc version with PSVR, Oculus CV1 and better Vive tracking support.
Also introduces global shader, which will be adjusted based on the variables of the HMD drivers, this will make the manual selection of lens correction shaders obsolete, will be removed in next commit.

The hmd window is currently black before started (due to shader not having the hmd data yet), will be fixed as well.
2017-03-06 01:23:14 +01:00
Julian Eisel
edd74baa15 Merge branch 'master' into HMD_viewport 2017-03-06 00:08:01 +01:00
Julian Eisel
20763919a1 Fix issues changing HMD device 2017-03-05 23:48:43 +01:00
Julian Eisel
d5f0807c63 Fix python UI for building without HMD 2017-03-05 23:39:34 +01:00
Julian Eisel
6907aa26c6 Disable OpenHMD dummy device for release builds
Also fixing warning.
2017-03-05 22:32:46 +01:00
Julian Eisel
4950ce4cd9 Don't allow orthographic view in HMD view
Displaying camera in orthographic mode is still allowed. We don't want
to mess with render data and forcing perspective viewport rendering in
HMD view even if the camera is set to be orthographic might be
confusing.
2017-03-05 21:56:49 +01:00
Julian Eisel
07706a28d0 "Only Render" option for HMD view 2017-03-05 20:36:30 +01:00
Julian Eisel
2f0d8e799a Use view orientation data from current 3D view for creating HMD view 2017-03-05 18:31:17 +01:00
e72af060ab CMake: confine WIN32 options 2017-03-06 04:05:00 +11:00
Julian Eisel
b3c156927a Mirror mode support (sync HMD viewpoint with regular 3D view)
Adds option "Mirror HMD View" to the HMD panel in the 3D view.

In this implementation we update/redraw the mirrored 3D views with the
HMD view, which can actually cause some extra slowdown (drawing the
viewport at least once more). We decided that this would be the best
solution for now, as the other option would be opening a separate window
showing the mirrored result, which is a bit too much against the
non-overlapping paradigma IMHO.
We could also draw the HMD view into some buffer and reuse this for
mirrored displays, but that would mess up projection matrices.
In Blender 2.8 we'll probably be able to use multi-threaded drawing
anyway, for which this would be the perfect use case.

3D View regions mirroring the HMD view are locked, for quadview we only
use the non-locked region for mirroring.
2017-03-05 17:19:51 +01:00
5f98cd6360 Cleanup: typos 2017-03-05 23:36:49 +11:00
a461216885 BMesh: Add 'cut' separate mode for intersect tool
It was only possible to separate all geometry from an intersection or none.

Made this into an enum with a 3rd option to 'Cut', (now default)
which keeps each side of the intersection separate
without splitting faces in half.
2017-03-05 23:36:46 +11:00
3caeb51d7f Fix T50855: Intersect (knife) w/o separate doesn't select 2017-03-05 22:28:16 +11:00
f75b52eca1 Fix T50843: Pitched Audio renders incorrectly in VSE
There was a bug in the intended code behaviour to always seek with a
pitch of 1.0 regardless of pitch/pitch animation/doppler effects.

Check the bug report for a more detailed explanation of problems
concerning pitch and seeking.
2017-03-05 12:19:32 +01:00
4a4d71414e BLI_rect: add init from point functions
Initialize a rectangle from point+size.
2017-03-05 20:51:23 +11:00
284c7f72a1 Fix Vive compile option 2017-03-04 15:56:06 +01:00
2089a17f7e Fix T50838: Surface Deform DM use after free issue
Implementd fix suggested by @sergey in T50838.
2017-03-04 03:16:50 -03:00
6b9d73e8a7 Cleanup: expose struct for ED_view3d_mats_rv3d_* 2017-03-04 13:32:40 +11:00
7b92b64742 Fix own previous commit, sorry about that :( 2017-03-03 17:23:22 +01:00
2e8398c095 Get rid of BLI_task_pool_stop().
Comments said that function was supposed to 'stop worker threads', but
it absolutely did not do anything like that, was merely wiping out TODO
queue of tasks from given pool (kind of subset of what
`BLI_task_pool_cancel()` does).

Misleading, and currently useless, we can always add it back if we need
it some day, but for now we try to simplify that area.
2017-03-03 17:16:39 +01:00
18c2a44333 Fix ugly mistake in BLI_task - freeing while some tasks are still being processed.
Freeing pool was calling `BLI_task_pool_stop()`, which only clears
pool's tasks that are in TODO queue, whithout ensuring no more tasks
from that pool are being processed in worker threads.

This could lead to use-after-free random (and seldom) crashes.

Now use instead `BLI_task_pool_cancel()`, which does waits for all tasks
being processed to finish, before returning.
2017-03-03 17:12:03 +01:00
5f05dac28f Update comment which was remained in an old place 2017-03-03 16:36:21 +01:00
17cf423f30 Cleanup: Indentation 2017-03-03 15:53:55 +01:00
91ce13e90d Fix T50842: NLA Influence Curve draws out of bounds when it exceeds the 0-1 range 2017-03-04 01:24:21 +13:00
c0d0ef142f Cleanup: GPU_select never took NULL rect 2017-03-03 22:24:08 +11:00
25de610876 Cleanup: redundant header, use const, short -> bool 2017-03-03 22:24:08 +11:00
cdfae957f2 When creating texture/image in Texture Paint mode, both datablocks should get the same name
The paint slot name was not the same as what is displayed on the texture properties panel.
Instead, the slot type (e.g. "Diffuse Color") was used as the name.

Patch by Suchaaver (@minifigmaster125) with minor changes from @mont29.

Reviewers: mont29, sergey

Maniphest Tasks: T50704

Differential Revision: https://developer.blender.org/D2523
2017-03-03 10:50:01 +01:00
810d7d4694 Cycles: Fix possibly uninitialized variable
Hopefully this was a reason of randomly disappearing textures in our renders.
2017-03-03 10:10:26 +01:00
df88d54284 Fix T49655: Reloading library breaks proxies.
Can't say enough how much I hate those proxies... their duality (sharing
some aspects of both direct *and* indirect users) is a nightmare to handle. :(
2017-03-03 08:52:19 +01:00
42cb93205c Fix own stupid mistake in recent mesh 'split_faces' rework.
Was assigning new edge index to ml_prev->e, and then assigning ml_pre->e
to orig_index...
2017-03-02 17:22:03 +01:00
Julian Eisel
a78717a72d Fix duplicated 'Accurate' property for manipulator keymap item
Is already added through Transform_Properties
2017-03-02 13:39:01 +01:00
Julian Eisel
e7dc46d278 Fix weird "use_planar_constraint" button in redo panel
Issue was that the VIEW_OT_manipulator operator calls the transform
operators and passes them it's own operator properties. That means the
transform operator got properties passed that it doesn't have.
2017-03-02 13:37:42 +01:00
a83a68b9b6 Threads: Use atomics instead of spin when entering threaded malloc 2017-03-02 12:42:34 +01:00
87f8bb8d1d Fix another part of T50565: Planar constraints were always initialized to accurate transform
Now it is defined by keymap.
2017-03-02 12:18:07 +01:00
499faa8b11 Fix second part T50565: Using planar transform once makes it enabled by default
Was caused by property being saved by the operator manager.
2017-03-02 11:20:57 +01:00
856077618a Fix T50830: Wrong context when calling surfacedeform_bind
The custom poll function for surfacedeform_bind seems to have caused
issues when calling it from Python. Fixed by using the generic modifier
poll function, and setting the button to be active or not in the
Python UI code instead. (there might be a better way, but for now this
works fine)
2017-03-01 17:56:10 -03:00
193827e59b Correct comment
Thanks to @dingto for noticing.
2017-03-01 14:12:03 -05:00
49c99549eb Cleanup: Use .enabled instead of .active 2017-03-01 13:06:19 -05:00
278fce1170 Fix T50565: Planar constraints don't work properly with non-Blender key configurations
The issue was introduced by 4df75e5 and seems we just need to explicitly
add new keymap item now.

There is still some difference from old behavior, which is planar transform
is using precision movement since e138cde and here i don't see nice solution
currently: the change was requested here in the studio and it's just a
conflict in picking shift key for something which is not supposed to be
accurate.

At least now it's possible to invoke planar constraint and simply unhold
shift.
2017-03-01 18:00:54 +01:00
7fcae7ba60 Task scheduler: Remove query for the pool's number of threads
Not really happy of per-pool threads limit, need to find better
approach to that. But at least it's possible to get rid of half
of the nastyness here by removing getter which was only used in
an assert statement.

That piece of code was already well-tested and this code becomes
obsolete in the new depsgraph and does no longer exists in blender
2.8 branch.
2017-03-01 18:00:54 +01:00
ecee40e919 All drop-down buttons should use the same width 2017-03-01 19:30:18 +03:00
714e85b534 Cleanup: code-style, duplicate header 2017-03-02 00:16:36 +11:00
32c5f3d772 Fix text and icon positioning issues 2017-03-01 16:11:21 +03:00
f0cf15b5c6 Task scheduler: Remove counter of done tasks
This was only used for progress report, and it's wrong because:

- Pool might in theory be re-used by different tasks
- We should not make any decision based on scheduling stats

Proper way is to take care of progress by the task itself.
2017-03-01 12:45:51 +01:00
351c9239ed Cleanup: Use explicit unsigned int in atomics 2017-03-01 12:01:19 +01:00
c1012c6c3a Cleanup: update copyright and Blender description 2017-02-28 12:04:43 -05:00
87f236cd10 Cycles: Fix division by zero in volume code which was producing -nan 2017-02-28 17:33:06 +01:00
efe78d824e Fix/workaround T48549: Crash baking high-to-low-poly normal map in cycles
For now only prevent crash.
2017-02-28 14:08:33 +01:00
a581b65822 Fix T49936: Cycles point density get's it's bounding box from basis shape key 2017-02-28 12:41:56 +01:00
6d1ac79514 Cleanup: Grey --> Gray 2017-02-27 19:33:57 -05:00
4fa4132e45 Surface Deform Modifier (SDef)
Implementation of the SDef modifier, which allows meshes to be bound by
surface, thus allowing things such as cloth simulation proxies.

User documentation: https://wiki.blender.org/index.php/User:Lucarood/SurfaceDeform

Reviewers: mont29, sergey

Subscribers: Severin, dfelinto, plasmasolutions, kjym3

Differential Revision: https://developer.blender.org/D2462
2017-02-27 13:49:14 -03:00
cd5c853307 Fix memory leak when making duplicates real and parent had constraints
Thanks Bastien for help!
2017-02-27 17:46:41 +01:00
Julian Eisel
724a991b7f Fix changing device activates it unintentionally
Activating in this context means that OpenHMD starts polling the device
for rotation values. That can slow down things, so we only do it when
actually starting an HMD session.
2017-02-27 17:19:55 +01:00
Julian Eisel
3a79183097 Don't check if HMD returns valid IPD
OpenHMD always returns a valid value, so this check is just a waste of
resources.
2017-02-27 17:05:11 +01:00
Julian Eisel
f705c53cfa Use solid draw mode by default for HMD view 2017-02-27 16:37:11 +01:00
2342cd0a0f Fix/workaround T50677: Shrinkwrap constraint don't get updated when target mesh gets modified
Do a "full" update on leaving sculpt mode, so we are sure scene will be brought
to a consistent state.

Ideally we'll only do that when there are objects which depends on geometry
without re-calculating self geometry, but that's a bit tricky currently.
2017-02-27 16:27:53 +01:00
Julian Eisel
a8a93f000a Fix wrong modelview matrices
Was wrongly applying modelview matrices from HMD onto Blender's.
2017-02-27 16:23:45 +01:00
691ffb60b9 Similar to previous commit, but for object constraints 2017-02-27 16:19:52 +01:00
bf7006c15a Depsgraph: Shrinkwrap constraint actually depends on geometry 2017-02-27 16:00:39 +01:00
5acac13eb4 Cycles: Fix compilation error on vanilla Ubuntu 16.10
Patch by @swerner, thanks!
2017-02-27 15:22:51 +01:00
f1b21d5960 Fix T50634: Hair Primitive as Triangles + Hair shader with a texture = crash
Attributes were not resized after pushing new triangles to the mesh.
2017-02-27 15:21:14 +01:00
209a64111e Fix part of T50634: Hair Primitive as Triangles + Hair shader with a texture = crash
Wrong formula was used to calculate needed verts and tris to be reserved.
2017-02-27 15:21:14 +01:00
00ceb6d2f4 Cycles: Make it more clear values never changes by using const qualifier 2017-02-27 15:21:14 +01:00
f7d67835e9 Cleanup: typo in struct name 2017-02-28 00:38:33 +11:00
cc78690be3 Cycles: Forgot this in previous commit 2017-02-27 12:54:35 +01:00
238db604c5 Cycles: Add more logs about what's going on in shader optimization 2017-02-27 12:38:24 +01:00
845ba1a6fb Cycles: Experiment with replacing Sharp Glossy with GGX when Filter Glossy is used
The idea is to make it simpler to remove noise from scenes when some prop uses
Sharp glossy closure and causes noise in certain cases. Previously Sharp Glossy
was not affected by Filter Glossy at all, which was quite confusing.

Here is a file which demonstrates the issue: {F417797}

After applying the patch all the noise from the scene is gone.

This change also solves fireflies reported in T50700.

Reviewers: brecht, lukasstockner97

Differential Revision: https://developer.blender.org/D2416
2017-02-27 12:33:59 +01:00
406398213c Fix missing break setting curve auto-handles 2017-02-27 13:35:03 +11:00
Julian Eisel
3ef07b29c5 Minor UI message fixes 2017-02-26 22:54:42 +01:00
631ecbc4ca Fix unreported bug: Ensure you have the correct array directory even after the dm->release(dm) 2017-02-26 14:16:54 -03:00
112e4de885 Improve add-on UI error message
Show the paths of the duplicate addons

D791 by @gregzaal
2017-02-27 03:57:11 +11:00
Julian Eisel
8f55592e77 Use "General" as default lens distortion shader 2017-02-26 17:46:05 +01:00
Julian Eisel
926b9ea918 Fix driver for DeePoon HMD
Patch by @TheOnlyJoey, thx for fixing (and breaking!) this ;)
2017-02-26 17:36:51 +01:00
Julian Eisel
0261a18677 Merge branch 'master' into HMD_viewport 2017-02-26 17:18:25 +01:00
0561aa771b Cleanup: minor changes to array_store
- remove unused struct member.
- misleading variable name.
2017-02-26 15:29:09 +11:00
5c3216e233 Fix compiling after a0b8a9f 2017-02-25 14:58:08 +01:00
d66d5790e9 Fix (unreported) missing update when adding constraint from RNA. 2017-02-25 11:38:02 +01:00
94ca09e01c Fix rows with fixed last item (D2524) 2017-02-25 13:18:41 +03:00
2c4564b044 Alembic: avoid crashing when reading non-indexed UV params. 2017-02-25 07:08:42 +01:00
a0b8a9fe68 Alembic: addition of a scope timer to perform basic profiling. 2017-02-25 07:08:42 +01:00
8c5826f59a Fix T50698: Cycles baking artifacts with transparent surfaces. 2017-02-25 03:12:53 +01:00
15f1072ee2 Fix build error with macOS / clang / c++11. 2017-02-25 03:12:53 +01:00
caaf5f0a09 Fix T50757: Alembic, assign imported materials to the object data
instead of to the object itself.
2017-02-24 21:19:52 +01:00
9062c086b4 Fix T50676: Crash on closing while frameserver rendering.
Can't see any reason to call AUD exit early in WM_exit, that's a
low-level module that has no dependency on anything else in Blender, but
is dependency of some other parts of Blender, so it should rather be
exited late in the process!
2017-02-24 14:58:38 +01:00
1e29286c8c Cycles: Fix compilation warning with CUDA on OSX 2017-02-24 14:33:10 +01:00
f49e28bae7 Cycles: Fix non-zero exit status when rendering animation from CLI and running out of memory 2017-02-24 14:25:38 +01:00
4c164487bc Add "Gravitation" option to "Force" type force fields
This adds an option to force fields of type "Force", which enables the
simulation of gravitational behavior (dist^-2 falloff).

Patch by @AndreasE

Reviewers: #physics, LucaRood, mont29

Reviewed By: #physics, LucaRood, mont29

Tags: #physics

Differential Revision: https://developer.blender.org/D2389
2017-02-23 19:23:39 -03:00
29859d0d5e Fix some more minor issue with updated py doc generation. 2017-02-23 22:31:21 +01:00
c067f1d0d4 Fix stupid mistake in previous commit for release builds of API doc. 2017-02-23 22:08:01 +01:00
c7ad27fc07 Update py API doc generation tools to comply to new name scheme on server.
- for rc/release: /api/2.79c/, zip file named blender_python_reference_2.79c_release.zip
 - for dev: /api/master/, zip file named blender_python_reference_2_79_4.zip
2017-02-23 21:45:20 +01:00
6a249bb000 Usual UI messages fixes... 2017-02-23 21:10:43 +01:00
3e486c19ff Merge branch 'HMD_viewport' of git.blender.org:blender into HMD_viewport 2017-02-23 20:06:03 +01:00
22570c0ab4 - Updated OpenHMD with fixes from their master (commit 2379647) 2017-02-23 20:04:56 +01:00
50328b41a7 Cycles: Fix compilation error on 32bit Linux 2017-02-23 17:30:26 +01:00
Julian Eisel
3fb0674a1a Merge branch 'master' into HMD_viewport
Conflicts:
	source/blender/makesdna/DNA_scene_types.h
2017-02-23 15:38:52 +01:00
4e12113bea Cycles: Fix wrong render results with texture limit and half-float textures 2017-02-23 14:46:22 +01:00
13e075600a Cycles: Add utility function to convert float to half
handles overflow and underflow, but not NaN/inf.
2017-02-23 14:42:06 +01:00
9eb647f1c8 Fix T50656: Compositing node editor is empty, no nodes can be added 2017-02-23 11:23:49 +01:00
60592f6778 Fix T50748: Render Time incorrect when refreshing rendered preview in GPU mode 2017-02-23 10:51:06 +01:00
9dd194716b Fix T50736: Zero streaks in Glare node.
Please never, ever use same DNA var for two different things. Even worse
if they do not have same type and ranges!

This is only ensuring issues (as described in report, but also if
animating both RNA props using same DNA var... yuck).

And we were not even saving any byte in DNA, could reuse some padding
there to store the two new needed vars (yes, two, since we cannot re-use
existing one if we want to keep backward *and* forward compatibility).
2017-02-23 10:39:51 +01:00
Julian Eisel
7359cc1060 Fix possible crash in various 3D View operators
Was actually harmeless and not crashing, but I'd say more or less only
by luck: the NULL-check for region data would only evaluate to true for
the correct 3D View region. However, if we were to add region data to a
different region type in future, this would lead to undefined behavior
if executed in the wrong region.
2017-02-23 02:14:27 +01:00
43299f9465 Columns should be expandable by default 2017-02-23 00:06:54 +03:00
5e1d4714fe Fix T50745: Shape key editing on bezier objects broken with Rendered Viewport Shading
So... Curve+shapekey was even more broken than it looked, this report was
actually a nice crasher (immediate crash in an ASAN build when trying to
edit a curve shapekey with some viewport rendering enabled).

There were actually two different issues here.

I) The less critical: rB6f1493f68fe was not fully fixing issues from
T50614. More specifically, if you updated obdata from editnurb
*without* freeing editnurb afterwards, you had a 'restored' (to
original curve) editnurb, without the edited shapekey modifications
anymore. This was fixed by tweaking again `calc_shapeKeys()` behavior in
`ED_curve_editnurb_load()`.

II) The crasher: in `ED_curve_editnurb_make()`, the call to
`init_editNurb_keyIndex()` was directly storing pointers of obdata
nurbs. Since those get freed every time `ED_curve_editnurb_load()` is
executed, it easily ended up being pointers to freed memory. This was
fixed by copying those data, which implied more complex handling code
for editnurbs->keyindex, and some reshuffling of a few functions to
avoid duplicating things between editor's editcurve.c and BKE's curve.c

Note that the separation of functions between editors and BKE area for
curve could use a serious update, it's currently messy to say the least.
Then again, that area is due to rework since a long time now... :/

Finally, aligned 'for_render' curve evaluation to mesh one - now
editing a shapekey will show in rendered viewports, if it does have some
weight (exactly as with shapekeys of meshes).
2017-02-22 21:56:49 +01:00
b637db2a7a Cleanup: remove unused orig_nu from keyIndex ghash of editcurves. 2017-02-22 21:56:49 +01:00
99947e2943 Use new api doc links
Differential Revision: https://developer.blender.org/D2522
2017-02-22 11:19:30 -05:00
75cc33fa20 Fix Cycles still saving render output when error happened
This was fixed ages ago for the interface case but not for the
command line. The thing here is that currently external engines
are relying on reports system to indicate that error happened
so suppressing reports storage in the background mode prevented
render pipeline from detecting errors happened.

This is all weak and i don't like it, but this is better than
delivering black frames from the farm.
2017-02-22 13:06:24 +01:00
36c4fc1ea9 Cycles: Fix shading with autosmooth and custom normals
New logic of split_faces was leaving mesh in a proper state
from Blender's point of view, but Cycles wanted loop normals
to be "flushed" to vertex normals.

Now we do such a flush from Cycles side again, so we don't
leave bad meshes behind.

Thanks Bastien for assistance here!
2017-02-22 10:54:36 +01:00
2c30fd83f1 Cycles: Additionally report all OpenCL cflags
This way we can control exact spaces and such added to the cflags
which is crucial to troubleshoot certain drivers.
2017-02-22 10:06:02 +01:00
ae1c1cd8c0 Refactor Mesh split_faces() code to use loop normal spaces.
Finding which loop should share its vertex with which others is not easy
with regular Mesh data (mostly due to lack of advanced topology info, as
opposed with BMesh case).

Custom loop normals computing already does that - and can return 'loop
normal spaces', which among other things contain definitions of 'smooth
fans' of loops around vertices.

Using those makes it easy to find vertices (and then edges) that needs
splitting.

This commit also adds support of non-autosmooth meshes, where we want to
split out flat faces from smooth ones.
2017-02-22 09:40:46 +01:00
3622074bf7 Fix Drawing nested box layouts (D2508) 2017-02-21 21:02:56 +03:00
4e9b17da4c Cycles: Speedup by avoiding extra calculations in noise texture when unneeded
Noise texture is now faster when the color socket is unused. Potential for
speedup spotted by @nutel.

Some performance results:

                     Render Time Before    After    Difference
Gooseberry benchmark         47:51.34    45:55.57       -4%
Koro                         12:24.92    12:18.46     -0.8%
Simple cube (Color socket)      48.53       48.72     +0.3%
Simple cube (Fac socket)        48.74       32.78    -32.7%
Goethe displacement           1:21.18     1:08.47    -15.6%
Cycles brick displacement     3:02.38     2:16.76    -25.0%
Large displacement scene     23:54.12    20:09.62    -15.6%

Reviewed By: sergey

Differential Revision: https://developer.blender.org/D2513
2017-02-21 07:24:33 -05:00
34a502c16a Cleanup: use proper link to the api 2017-02-20 20:21:57 -05:00
696836af1d Fix T50718: Regression: Split Normals Render Problem with Cycles
The issue seems to be caused by vertex normal being re-calculated
to something else than loop normal, which also caused wrong loop
normals after re-calculation.

For now issue is solved by preserving CD_NORMAL for loops after
split_faces() is finished, so render engine can access original
proper value.
2017-02-20 11:56:02 +01:00
75ce4ebc12 Mesh faces split: Add missing vertex normal copy 2017-02-20 11:47:43 +01:00
333dc8d60f Fix T50719: Memory usage won't reset to zero while re-rendering on two video cards
Was only visible with Persistent Images option ON.
2017-02-20 11:02:19 +01:00
9992e6a169 Fix a few compiler warnings with macOS / clang. 2017-02-18 23:59:34 +01:00
3f5b2e2682 Fix T50564: 3D view panning with scroll wheel inconsistent with dragging. 2017-02-18 22:41:56 +01:00
6f1493f68f Fix T50614: Curve doesn't restore initial form after deleting all its shapekeys
Logic of handling shapekeys when entering and leaving edit mode for
curves was... utterly broken.

Was leaving actual curve data with edited shapekey applied to it.
2017-02-17 18:55:52 +01:00
31123f09cd Remove unused functions related to distance between BoundBox and ray 2017-02-17 09:49:20 -03:00
d41451a0ca Forgotten in last commit: Check the allocation 2017-02-16 23:41:38 -03:00
6c59a3b37a Do not release the arrays used in the parameters of the expanded functions of bvhutils
The release of these arrays should be the programmer's discretion since these arrays can continue to be used.

Only the expanded functions `bvhtree_from_mesh_edges_ex` and `bvhtree_from_mesh_looptri_ex` are currently being used in blender (in mesh_remap.c), and from what I could to analyze, these changes can prevent a crash.
2017-02-16 22:55:01 -03:00
7819d36d4e Make File: Print 'blender.exe' at the end of the path to run from 2017-02-16 17:08:33 -05:00
99a6bbf7dd Cleanup: Spelling, Spaces --> Tabs, Whitespace 2017-02-16 17:06:03 -05:00
21eae869ad UI: Move 'relations extras' right below 'relations'
Differential Revision: https://developer.blender.org/D2218
2017-02-16 12:02:32 -05:00
306acb7dda Fix T50687: Cycles baking time estimate and progress bar doesn't work / progress when baking with high samples 2017-02-16 17:15:08 +01:00
26c8d559fe Register test for mesh.split_faces() 2017-02-16 15:36:00 +01:00
6468cb5f9c Faces split: Don't leave CD_NORMAL after split
This is supposed to be a temporary layer.

If someone needs loop normals after split it should explicitly
ask for that.
2017-02-16 11:00:17 +01:00
5cbaf56b26 Cyctes tests: Commit blender.git side changes 2017-02-16 10:36:22 +01:00
fc185fb1d2 CDDM Copy: Only tag data layers dirty if we ignored tessellation data
This solves assert failure in CustomData_from_bmeshpoly() happening with
broom.blend file from barber shop SVN.
2017-02-16 09:55:44 +01:00
809ed38075 Cleanup: Indentation 2017-02-16 09:16:20 +01:00
781507d2dd Freestyle: Feature edge selection by nested object groups.
A group of object groups can be formed by means of the dupli_group option in
the Object properties window.  The present revision extends the Selection by
Group option in the Freestyle Line Set so as to support not only flat object
groups but also nested groups.
2017-02-16 10:53:11 +09:00
9b3d415f6a Fix more corner cases failing in mesh faces split
Now we handle properly case with edge-fan meshes, which should
fix bad topology calculated for cash register which was causing
crashes in the studio.
2017-02-15 23:09:31 +01:00
40e5bc15e9 Fix wrong edges created by split faces
We need to first split all vertices before we can reliably
check whether edge can be reused or not.

There is still known issue happening with a edge-fan mesh
with some faces being on the same plane.
2017-02-15 21:41:25 +01:00
41e0085fd3 [Alembic] Fix msvc warning - C4138 '*/' found outside of comment 2017-02-15 12:40:41 -07:00
e22d4699cb Cycles: Cleanup, style 2017-02-15 20:33:49 +01:00
13d31b1604 Fix T50542: Wrong metadata frame when using OpenGL render 2017-02-15 17:09:49 +01:00
3e628eefa9 Motion blur investigation feature
This commit adds a way to debug Cycles motion blur issues which
are usually happening due to something crazy happening in between
of frames. Biggest trouble was that artists had no clue about
what's happening in subframes before they render. This is at
least inefficient workflow when dealing with motion blur shots
with complex animation.

Now there is an option in Time Line Editor which could be found
in View -> Show Subframe. This option will expose current frame
with it's subframe to the time line editor header and it'll allow
scrubbing with a subframe precision in time line editor.

Please note that none of the tools in Blender are aware of
subframe, so they'll likely be using current integer frame still.

This is something we don't consider a bug for now, the whole
purpose for now is to give a tool for investigation. Eventually
we'll likely tweak all tools to be aware of subframe.

Hopefully now we can finish the movie here in the studio..
2017-02-15 16:19:05 +01:00
efbe47f9cd Fix T50662: Auto-split affects on smooth mesh when it sohuldn't
Seems to be a precision error comparing proper floating point
normal with the one coming from short.
2017-02-15 15:21:15 +01:00
fe47163a1e Cycles: Fix CUDA compilation error after recent changes 2017-02-15 15:01:08 +01:00
20283bfa0b Fix wrong loop normals left after face splitting
Let's keep all data in a consistent state, so we don't have any
issues later on.

This solves rendering artifacts mentioned in the previous commit.
2017-02-15 14:58:49 +01:00
dd79f907a7 Mesh: Re-implement face split solving issue mentioned earlier
Now new edges will be properly created between original and
new split vertices.

Now topology is correct, but shading is still not quite in
some special cases.
2017-02-15 14:49:42 +01:00
8b8c0d0049 Cycles: Don't calculate primitive time if BVH motion steps are not used
Solves memory regression by the default configuration.
2017-02-15 12:59:31 +01:00
6cdc954e8c Cycles: Pass special flag whether BVH motion steps are used
Doesn't currently change anything, but would need for some future
work here.

It uses existing padding in kernel BVH structure, so there is
nothing changed memory-wise.
2017-02-15 12:45:06 +01:00
dc7bbd731a Cycles: Fix wrong hair render results when using BVH motion steps
The issue here was mainly coming from minimal pixel width feature
which is quite commonly enabled in production shots.

This feature will use some probabilistic heuristic in the curve
intersection function to check whether we need to return intersection
or not. This probability is calculated for every intersection check.
Now, when we use multiple BVH nodes for curve primitives we increase
probability of that primitive to be considered a good intersection
for us. This is similar to increasing minimal width of curve.

What is worst here is that change in the intersection probability
fully depends on exact layout of BVH, meaning probability might
change differently depending on a view angle, the way how builder
binned the primitives and such. This makes it impossible to do
simple check like dividing probability by number of BVH steps.

Other solution might have been to split BVH into fully independent
trees, but that will increase memory usage of all the static
objects in the scenes, which is also not something desirable.

For now used most simple but robust approach: store BVH primitives
time and test it in curve intersection functions. This solves the
regression, but has two downsides:

- Uses more memory.

  which isn't surprising, and ANY solution to this problem will
  use more memory.

  What we still have to do is to avoid this memory increase for
  cases when we don't use BVH motion steps.

- Reduces number of maximum available textures on pre-kepler cards.

  There is not much we can do here, hardware gets old but we need
  to move forward on more modern hardware..
2017-02-15 12:45:04 +01:00
088c6a17ba Cycles: Fix missing initialization of triangle BVH steps
Likely was harmless for Blender, but better be safe here.
2017-02-15 12:44:52 +01:00
5723aa8c02 Cycles: Fix wrong pointiness caused by precision issues 2017-02-15 12:40:13 +01:00
b36e26bbce Revert "Mesh: Solve incorrect result of mesh.split_faces()"
The change was delivering broken topology for certain cases.
The assumption that new edge only connects new vertices was
wrong.

Reverting to a commit which was giving correct render results
but was using more memory.

This reverts commit af1e48e8ab.
2017-02-15 12:40:13 +01:00
384b7e18f1 UI: Wireframe modifier- make crease grayed out when disabled 2017-02-14 23:48:35 -05:00
402b0aa59b Comments: notes on polyfill2d, minor corrections 2017-02-15 14:17:06 +11:00
af1e48e8ab Mesh: Solve incorrect result of mesh.split_faces()
This function was keeping original edges and was creating some
extra vertices which is not something we are really looking
forward to,
2017-02-14 17:02:22 +01:00
737a3b8a0a Mesh: Cleanup, use shorter version of loop 2017-02-14 16:27:09 +01:00
324d057b25 Mesh: Use faster calculation of previous loop 2017-02-14 16:27:09 +01:00
4d325693e1 BKE_boundbox_ensure_minimum_dimensions is no longer necessary
The bug T46099 no longer applies since the addition of `dist_squared_to_projected_aabb_simple`
Has also been added comments that relates to an occlusion bug with the ruler. I'll investigate this.
2017-02-14 10:25:00 -03:00
6c104f62b9 transform_snap_object: Remove do_bb parameter. It is always true 2017-02-14 09:38:20 -03:00
54102ab36e Alembic: fix naming of imported transforms.
When importing an Alembic file with grouped transforms, it would badly name the transforms, taking the name of the parent instead of its own.

Patch by @maxime.robinot

Differential Revision: https://developer.blender.org/D2507
2017-02-14 08:15:13 +01:00
930186d3df Cycles: Optimize sorting of transparent intersections on CUDA 2017-02-13 18:24:45 +01:00
21dbfb7828 Cycles: Fix wrong transparent shadows with CUDA
Was a bug in recent optimization commit.
2017-02-13 18:22:10 +01:00
581c819013 Cycles: Fix wrong shading on GPU when background has NaN pixels and MIS enabled
Quite simple fix for now which only deals with this case. Maybe we want to do
some "clipping" on image load time so regular textures wouldn't give NaN as
well.
2017-02-13 16:32:55 +01:00
81eee0f536 Cycles: Use fast math without finite optimization
This allows us to use faster math and still have reliable
isnan/isfinite tests.

Only do it for host side, kernels stays unchanged.

Thanks Lukas Stockner for the tip!
2017-02-13 16:25:35 +01:00
37afa965a4 Fix T50655: Pointiness is too slow to calculate
Optimize vertex de-duplication the same way as we do doe Remove Doubles.
2017-02-13 12:00:10 +01:00
594015fb7e Cycles: Use Cycles-side mesh instead of C++ RNA
Those are now matching and it's faster to skip C++ RNA to
calculate pointiness.
2017-02-13 10:40:05 +01:00
9148ce9f3c F-Curve normalization: Do proper curve min/max instead of handle min/max
Would be cool to find some way to cache the results.
2017-02-13 10:02:04 +01:00
5552e83b53 Cycles: Don't use built-in API for image sequences in preview mode
Our Python API is not ready for such things at all. Better be slower
but more correct for until we improve our API.
2017-02-11 22:24:59 +01:00
e76364adcd Image: Fix non-deterministic behavior of image sequence loading
The issue was caused by usage of non-initialized image user, which
could have different settings, causing some random image being loaded
or not loaded at all.

This caused non-deterministic behavior of Cycles image loading because
it was querying image information from several places.

This fixes crash reported in T50616, but it's not a complete fix
because preview rendering in material is wrong (same wrong as in
2.78a release).
2017-02-11 22:19:49 +01:00
1ac6e4c7a2 UI: Redesign the VSE multicam strip
Idea from https://rightclickselect.com/p/sequencer/zfbbbc/sequencer-panels-update by @pauloup

|{F434631}|{F434624}|
|Before |After|

Test file:
{F434643}
2017-02-11 11:35:02 -05:00
3ede515b5b Use dummy versionning numbers for missing libraries.
We now assert that we now file version of libraries (needed for
do_version after linking step), so for missing libraries, set dummy
numbers (using version of main .blend file actually).
2017-02-10 22:50:45 +01:00
ef017ec9d0 Added support for correct Oculus DK1 and DK2 shaders with additional Generic shader (which could/should work for most other HMD's)
Shaders can be changed in options so you can pick a shader that matches your device
2017-02-10 22:11:48 +01:00
9d8a9cacc3 De-duplicate min/max calculation in F-Curve normalization 2017-02-10 18:10:26 +01:00
3318e7bd13 Fixed small oops with copy paste 2017-02-10 17:28:50 +01:00
0bbbeead7d Fixed HMD branch for current master 2017-02-10 17:20:27 +01:00
68f931fd90 Merge branch 'master' of git.blender.org:blender into HMD_viewport 2017-02-10 16:50:30 +01:00
e33e58bf23 CTests: Initial work to cover Cycles nodes with OpenGL tests
Works similar to regular Cycles tests, just does OpenGL render to
get output image.

Seems to work fine with the only funny effect: Blender window will
pop up for each of the tests. This is current limitation of our
OpenGL context. Might be changed in the future.
2017-02-10 14:52:54 +01:00
e991af0934 Cleanup: Trailing whitespace 2017-02-10 14:08:12 +01:00
cd4309ced0 Cycles: Cleanup, move EdgeMap to blender_util
it's better place for such an utility structure. Still not fully ideal tho.
2017-02-10 13:34:10 +01:00
0178915ce9 Cycles: Make an utility class for edge map
Simplifies some logic.
2017-02-10 13:34:09 +01:00
fd7e9f7974 Cycles: Fix pointiness attribute giving wrong results with autosplit
Basically made the algorithm to handle vertices with the same coordinate
as a single vertex.
2017-02-10 13:34:09 +01:00
d395d81bfc Cycles: Cleanup: Use less indentation by inverting condition 2017-02-10 13:34:09 +01:00
0b65b889ef Cycles: Calculate all vertex attribute after faces generation
This way the calculation is not spread over multiple places.
2017-02-10 13:34:09 +01:00
b26da8b467 Cycles: Cleanup: use vector instead of bare malloc
This way memory is more "manageable" and easier to follow.
2017-02-10 13:34:09 +01:00
b929eef8c5 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:54:00 +01:00
38155c7d3c Do not overide text 2017-02-09 16:25:04 -05:00
bb1367cdaf Fix T50629 -- Add remove doubles to the cleanup menu
Also move it up in the verticies menu
2017-02-09 16:18:33 -05:00
e523cde574 Cleanup: Remove commented code
Code has been commented from before 2010 and relates to old Background image code.
2017-02-09 09:26:57 -05:00
d2f4900d1a Use a smaller cross icon for clearing search box contents 2017-02-09 19:08:58 +13:00
351eb4fad1 More tweaks to Normalisation options in Graph Editor
* Added a new dedicated icon for normalize
* Only use an icon for "Auto"
2017-02-09 18:59:51 +13:00
316d23f2ba Graph Editor: Replace Normalise/Auto checkboxes with toggle buttons
These take less space, fit in better with rest of the UI, and make their relationship clearer
2017-02-09 17:10:49 +13:00
117d90b3da Fix: GPencil delete operators did not respect color locking 2017-02-09 17:10:48 +13:00
b16fd22018 Cycles: Fix regression with transparent shadows in volume 2017-02-08 14:00:48 +01:00
da31a82832 Cycles: Solve speed regression by casting opaque ray first 2017-02-08 14:00:48 +01:00
04cf1538b5 Cycles: Fix compilation error on OpenCL 2017-02-08 14:00:48 +01:00
31a025f51e Cycles: Split shadow functions to avoid some duplicated calculations 2017-02-08 14:00:48 +01:00
dde40989f3 Cycles: Store shadow intersections in the kernel globals
Seems CUDA failed to de-duplicate the array across multiple inlined
versions of the shadow_blocked(). Helped it a bit with that now.

Gives about 100MB memory improvement on a scenes after previous
commit and brings up memory "regression" to only 100MB comparing to
the master branch now.
2017-02-08 14:00:48 +01:00
7447950bc3 Cycles: Speedup transparent shadows on CUDA
This commit enables record-all behavior of transparent shadows
rays.

Render times difference goes as following:

               GTX 1080 render time
BMW                  -0.5%
Fishy Cat            -0.0%
Pabellon Barcelona   -11.6%
Classroom            +1.2%
Koro                 -58.6%

Kernel will now use some extra VRAM memory to store the intersection
array (200MB on my configuration). This we can optimize out with some
further commits.
2017-02-08 14:00:48 +01:00
9830eeb44b Cycles: Implement record-all transparent shadow function for GPU
The idea is to record all possible transparent intersections when
shooting transparent ray on GPU (similar to what we were doing  on
CPU already).

This avoids need of doing whole ray-to-scene intersections queries
for each intersection and speeds up a lot cases like transparent
hair in the cost of extra memory.

This commit is a base ground for now and this feature is kept
disabled for until some further tweaks.
2017-02-08 14:00:48 +01:00
9c3d202e56 Cycles: Use an utility function to sort intersections array 2017-02-08 14:00:48 +01:00
58a10122d0 Cycles: Make GPU version of shadow_blocked() closer to CPU
Now we break the traversal cycle and then perform volume attenuation
and check with zero throughput. Not sure it makes any measurable sense
at this moment, but in the future it might help de-duplicating some
extra logic here.
2017-02-08 14:00:48 +01:00
98a1855803 Cycles: De-duplicate transparent shadows attenuation
Fair amount of code was duplicated for CPU and GPU, now we are
using inlined function to avoid such duplication.
2017-02-08 14:00:48 +01:00
8cda364d6f Fix T49249: Alembic export with multiple hair systems crash blender
Removed unnecessary call to DM_update_tessface_data(). This call is
already performed by DM_ensure_tessface(dm). The call being performed
twice caused a failing BLI_assert().

Reviewed by: Kévin Dietrich
2017-02-08 12:26:36 +01:00
ac38d5652b Alembic export: avoid infinite loops trying to find parent objects.
Also added some assertions for debugging purposes

Reviewed by: Kévin Dietrich
2017-02-08 12:26:36 +01:00
95e7f93fa2 Alembic export: only create transform writer if the object should be exported
Reviewed by: Kévin Dietrich
2017-02-08 12:26:36 +01:00
b320873382 Alembic: #undef'ed the correct macro
TEST_RET is not defined anywhere in Blender's sources, and LAYER_CMP
is no longer used after this function ends.
2017-02-08 12:26:36 +01:00
ce9df09067 Alembic: Use getXForm() in check, because it's used in rest of the function too
This makes the code within the function consistent.
2017-02-08 12:26:36 +01:00
82df7100c8 Alembic: Renamed copy_zup_yup to copy_yup_from_zup (and same for zup_from_yup)
With the new names the arguments (yup, zup) are in the same order as
they appear in the function name. The old names used copy_src_dst(dst,
src), which I found very confusing. Furthermore, now it is clear from
where to where the copy is made.

This makes the function names a little bit longer, though. If that is
a real issue, we can just name them zup_from_yup(zup, yup).

Reviewed by: Kévin Dietrich
2017-02-08 12:26:36 +01:00
69dbeeca48 Cleanup: Use const qualifier in some of color management code 2017-02-07 17:49:54 +01:00
b641d016e1 Sequencer: Some extra speedup in color space conversion
Use the new utility from coloranagement which multi-threads byte to
float conversion.

Gives extra 10% speedup from quick tests.
2017-02-07 17:49:54 +01:00
ce629c5dd9 Color management: Add utility function to convert byte to float with processor applied 2017-02-07 17:49:54 +01:00
e5bb005369 Sequencer: Speedup conversion to sequencer space
Speedup is mainly gained by multi-threading. Gives about 3x
fps gain on an edit shot file.

There is still some room for improvements, will happen in one
of the upcoming commits.
2017-02-07 17:49:54 +01:00
5d6177111d Color management: Implement threaded byte buffer conversion
The title says it all actually: now we can convert byte buffer
directly, without need of temporary float buffer.
2017-02-07 17:49:54 +01:00
03be3102c7 Param is_cached not being used in bvhtree_from_mesh_edges_setup_data
This could cause bugs in the memory release
2017-02-07 11:03:10 -03:00
03544eccb4 Fix missing hair after rendering with different viewport/render settings
Derived mesh for particles did not include tessellated faces when it
was expected to. Now added explicit function to copy CDDM with tess
faces without need to re-tessellate the result.
2017-02-07 14:21:29 +01:00
53896d4235 Fix T49253: Cycles blackbody is wrong on AVX2 CPU on Windows
Seems to be bug in optimizer, but managed to reshuffle in a way
which should also give some speedup.
2017-02-07 13:05:19 +01:00
1158800d1b PIL_time_utildefines: also show total time in TIMEIT_AVERAGED. 2017-02-07 10:14:46 +01:00
f7eaaf35b4 Fix (unreported) Object previews being written even for skipped objects. 2017-02-06 20:58:18 +01:00
e217839fd3 Cleanup writefile code a bit.
Modernize some of it a bit, saves quite some lines of blabla (using
shile instead of for loops... tsssts...).
2017-02-06 20:43:14 +01:00
dbdc346e9f CMake: Remove MOTO library dependency when it is not needed
It is not necessary to add MOTO library dependency when we use
WITH_IK_SOLVER (now it uses Eigen) or we use WITH_MOD_BOOLEAN (it was
used by bsp intern library some time ago but it is not present in the
code anymore).

Reviewers: mont29, sergey

Subscribers: mont29, sergey

Differential Revision: https://developer.blender.org/D2477
2017-02-06 19:29:42 +01:00
0170c682fe Specify the correct size of the BVHTree of edges
~edge_num~ edges_num_active
Not always all the edges enter in the build
2017-02-06 14:59:31 -03:00
e3f99329d8 Standardization and style for BKE_bvhutils
Add `bvhtree_from_mesh_edges_ex` and callbacks to nearest_to_ray (Similar to the other functions of this code)
2017-02-06 14:11:06 -03:00
ac8348d033 Fix 'public' global 'g_atexit' var in Blender.
No reason to not make this private to this file, and it gave conflict
when using bpy as module and loading it in a GLib application (which
also has a g_atexit var).
2017-02-06 17:42:30 +01:00
9e97b00873 Fix compilation error after recent change 2017-02-06 15:29:13 +01:00
c7f40caa2c Add shortcuts for unsigned int, short, long and char
Feel free to use those in the new code.

And stay away from simple "unsigned".
2017-02-06 15:04:13 +01:00
c5cc9e046d Use hash instead of linear lookup in armature deform
This avoids calling linear lookup 100s of time when dealing with
real-life character.

Still some tweaks possible.
2017-02-06 14:47:36 +01:00
d0015cba02 Multi-thread displace modifier
The title says it all actually. Use BLI task to loop over vertices
and distort their locations. Gives 2x FPS increase in a file with
just time-dependent displace modifier on my desktop.
2017-02-06 14:21:29 +01:00
89f3837d68 Displace modifier: Use special version of texture sampling
This version will give less spin locks and now well-tested by render engines.

This should reduce amount of threading overhead when having multiple objects
with displace modifier enabled.

In the future this will also help us threading the modifier.

There are more modifiers which could benefit from this, but let's first
investigate the new behavior with one of them.
2017-02-06 12:37:08 +01:00
385fe4f0ce Add special texture sampling function which takes image pool argument
Using image pool will reduce number of thread locks when acquiring image.
Useful when it's needed to sample texture fewzillion times a second.
2017-02-06 12:23:03 +01:00
223aff987a Fix memory leak when building without audaspace 2017-02-06 11:18:20 +01:00
Phil Christensen
351c409317 C++ conformance fixes (MSVC /permissive-)
We (the Microsoft C++ team) use the Blender project as part of our "Real world code" tests.
I noticed a place in WIN32 specific code (dvpapi.cpp:85) where a string literal is losing
its const-ness when being passed to BLI_dynlib_open().  This is not permitted when using the
/permissive- conformance compiler switch (see our blog
https://blogs.msdn.microsoft.com/vcblog/2016/11/16/permissive-switch/)

My suggested fix is to add const and propagate it where needed.  Another possible fix would be
to explicitly cast away the const.

Reviewers: mont29, sergey, LazyDodo

Subscribers: Blendify, sergey, mont29, LazyDodo

Tags: #platform:_windows

Differential Revision: https://developer.blender.org/D2495
2017-02-06 10:44:56 +01:00
22156d951d fix T50602: Avoid crash when executing transform_snap_context_project_view3d_mixed with dist_px NULL 2017-02-06 01:01:39 -03:00
da08aa4b96 Cleaning of the last commit: lack of attention with the debug of time X(
This was a stupid mistake
2017-02-04 19:06:41 -03:00
75aa866211 Optimize BVHTree creation of vertices that have BLI_bitmap test
Instead of reference the vertex first and test the bitmap afterwards. Test the bitmap first and reference the vertex after.

In a mesh with 31146 vertices and the entire bitmap disabled, the loop time is 243% faster
With all bitmap enabled, the time becomes 463473% faster!!!

One possible reason for this huge difference in peformance is that maybe the compiler is not putting the function "BM_vert_at_index" inline (I dont know if buildbot do this, but it's good to investigate).
2017-02-04 19:01:29 -03:00
47caf343c0 fix T50592: Scene.raycast not working
Ray_start and ray_normal values were being ignored
2017-02-04 18:17:15 -03:00
a2c469edc2 Fix (unreported) crash in new snap code.
Looks like `object_map` and `mem_arena` may be NULL sometimes...

Also, cleaned up function pointers declaration of Nearest2dUserData,
those were warning out in gcc. Please, *always* use typdef defined
prototypes for function pointers, it is sooooo much cleaner and clearer
that way. And easy to convert from compatible functions too.
2017-02-04 21:51:27 +01:00
6663099810 Fix T50590: BI lamp doesn't hold a texture in this case.
BKE_lamp_free was somehow missing the refactor of datablocks handling
(which, among other things, completely separated ID refcounting and
linking management from ID freeing itself).

Either forgot during development, or lost during merge...
2017-02-04 21:31:52 +01:00
c367e23d46 Snap System: Use callbaks to differentiate how referenced vertives of DerivedMeshs and Bmeshs
Before it was informed the type of object in the `userdata`, and a same function ran between the types to obtain the coordinates of the vertices
2017-02-03 20:08:57 -03:00
a0561a05ef Remove flag: SNAP_OBJECT_USE_CACHE from snap_context
Since the cache is created in one way or another, this flag is not really making a difference
More details here: D2496
2017-02-03 19:03:31 -03:00
21f3767809 fix T46892: snap to closest point now works with Individual Origins
The code looks for the closest element between its centers. In the case of islands, the center of each vertex is the center of the island.
The solution here is to skip the search for islands when the operation is translation
2017-02-03 13:15:44 -03:00
0b4a9caf51 Forgotten in committee ddf99214dc
In obect mode, the rotation matrix need to be restored to the initial value if a snap point is not found
2017-02-03 12:57:02 -03:00
0e459ad1a3 Buildbot: Re-enable cuda support for OSX 2017-02-03 16:11:05 +01:00
52696a0d3f Fix T50125: Shortcut keys missing in menus for Clear Location, Rotation, and Scale.
Menu entries and shortcuts did not have exact same behavior, now they do
(using shortcuts' behavior).
2017-02-03 16:10:00 +01:00
f3a7104adb Fix T49860: Copying vgroups between objects sharing the same obdata was not possible.
Pretty straight forward actually, just do not bother about obdata part
of vgroups in that case, only copy object part of it.

And let's curse once again those stuff spread accross several types of
data-blocks...
2017-02-03 15:47:44 +01:00
a1820afa30 Depsgraph: Add some extra debug prints on eval 2017-02-03 14:05:59 +01:00
030e99588d Tests: Use proper order for EXPECT_EQ() 2017-02-03 12:03:59 +01:00
aea17a612d Tests: Use EXPECT_FALSE() instead of EXPECT_EQ(foo, false) 2017-02-03 11:52:47 +01:00
dc1b45ff1a Tests: Use EXPECT_TRUE() instead of EXPECT_EQ(foo, true) 2017-02-03 11:52:29 +01:00
e1e85454ea Cycles: Cleanup, order of arguments to EXPECT_EQ
The order was wrong from the semantic point of view, caused
by some legacy workarounds in Libmv. Didn't realize it's was
not how things were expected to be used.
2017-02-03 11:35:34 +01:00
103f2655ab Explode modifier: Don't tessellate DM if we are not going to apply modifier 2017-02-03 11:03:47 +01:00
ddf99214dc fix T49494: snap_align_rotation should use a local pivot to make the transformation
The problem was simple, just transform the global coordinates of t->tsnap.snapTarget to local coordinates.
(Some comments were added to the code)
2017-02-03 02:27:57 -03:00
9f67367f0a Fix T50084: Adding torus re-orders UV layers.
Issue was indeed in join operation, mesh in which we join all others
could be re-added to final data after others, leading to undesired
re-ordering of CD layers, and existing vertices etc. being shifted away
from their original indices, etc.

All kind of more or less bad and undesired changes, fixed by always
re-inserting destination mesh first.

Also cleaned up a bit that code, it was doing some rather
non-recommanded things (like allocating zero-sized mem, doing own
coocking to remove a data-block from main, etc.).
2017-02-02 21:42:00 +01:00
33e456b0ce install_deps.sh: don't use backticks
The script complained that it could not find the executable "--build-all".
2017-02-02 17:49:24 +01:00
9e2dca933e Fix T50524: Basis shapekey editing while rendering bug.
Root of the issue was BM_mesh_bm_to_me() breaking application of basis
offset to 'child' shapekeys, when called more than once from same BMesh.
2017-02-02 17:05:48 +01:00
feb588060a Fix T50497: prop_search not correctly drew in UI (D2473) 2017-02-02 17:30:50 +03:00
86747ff180 Fix T50535: Cycles render segfault when Explode modifier before hair particle modifier + UV material
Tricky issue caused by CDDM_copy() coying MFACE array but not MTFACE which
confused logic later on.

Now we don't copy ANY tessellation unless it is requested to.

Thanks Bastien for help and review!
2017-02-02 14:36:30 +01:00
6edfa73f5c Revert the change of a default in a recent commit
This was my own mistake
2017-02-01 23:46:53 -05:00
Michael Stahre
7f10a889e3 Fix incorrect spot lamp blend in python GPU uniform export.
Reviewed By: brecht

Differential Revision: https://developer.blender.org/D2378
2017-02-02 04:03:26 +01:00
Michael Stahre
d4e0557cf1 Fix missing uniform type for python GPU uniform export.
Reviewed By: brecht

Differential Revision: https://developer.blender.org/D2379
2017-02-02 04:03:26 +01:00
Aaron
3ab8895610 UI: Add missing colon 2017-02-01 14:56:11 -05:00
fb61711b1a Fix T50570: pressing pgup or pgdn in any scrollable area irreversably alters scrolling speed.
'page' prop of scroll up/down operators would get stuck once set once by
pageup/down keys... Now only take this prop into account if explicitely
set, not when its value is inherited from previous run.
2017-02-01 12:52:26 +01:00
c231c29afa Cycles tests: Allow python auto-exec 2017-02-01 10:13:40 +01:00
fa19940dc6 Cycles: Fix rng_state initialization when using resumable rendering 2017-02-01 05:43:17 +01:00
92258f3678 Snap System: BVH: Ignore calculations, in parent nodes, used only in perspective view
Strangely this change does not affect the performance very much.
Suzanne subdividide 6x (ortho view):
Before:0.00013983
After :0.00013920

But it makes it easier to read the code
2017-01-31 21:43:44 -03:00
75a4c836d6 Snap System: Invert the test order of the elements to snap (useful for ruler)
When the function that tests snap on multiple elements starts from the face and ends at the vertex, the transition between elements becomes much smoother.
2017-01-31 17:10:34 -03:00
a90622ce93 Fix T50331: New Dependency Graph - "frame" python driver expression not working 2017-01-31 12:17:55 +01:00
326516c9d7 Cycles: Fix spelling in comment 2017-01-31 12:08:19 +01:00
b3690cdecd Fix variable shadow and avoid calculating same value twice 2017-01-31 11:55:29 +01:00
Dalai Felinto
887fc0ff6d Silence unused var warnings after rBac58a7fa 2017-01-31 11:00:50 +01:00
b5682a6fdd Cleanup: use 'cb_flag', not 'cd_flag' for library_query callbacks.
`cd_flag` tends to be used for CustomData flags in mesh area, while for
library_query those are rather callback flags...
2017-01-31 10:41:25 +01:00
60e387f5e3 Cleanup: Rename callback flags from library_query to IDWALK_CB_...
Better to have clear way to tell whether flag is parameter for
BKE_library_foreach_ID_link(), parameter for its callback function, or
return value from this callback function.
2017-01-31 09:47:59 +01:00
a928a9c1e1 Fix compilation error: too few arguments to function call.
D2492 by @tomjpsun.
2017-01-31 07:00:31 +01:00
d07e2416db Fix bug not reported: Ruler/Protractor: Snap to vertices and edges was not considering the depth variation
Taking advantage of the area, the depth is decreased 0.01 BU to each loop to give priority to elements in order: Vertice > Edge > Face. This increases the threshold and improves the snap to multiple elements
2017-01-30 23:49:09 -03:00
b841d60bf8 Snap System: Return depth by snapping to edges and vertices, because the Ruler only works right this way
The Ruler snaps to the element with the lowest depth.
2017-01-30 22:49:44 -03:00
a50b173952 Use the same solution to test the pixel distance to the AABB, with BoundBox
The previous solution took arbitrary values to determine if the mouse was near or not to the Bound Box (it simply scaled the Bound Box).

Now the same function that detected the distance from the BVHTree nodes to the mouse is used in the Bound Box
2017-01-30 22:27:38 -03:00
4e1025376e Freestyle: Use of the Fill Range by Selection operator in the mesh edit mode.
This revision extends the functionality of the "Fill Range by Selection" button in
the "Distance from Camera/Object" modifiers so that only selected mesh vertices
in the edit mode are taken into account  (instead of considering all vertices when
in the object mode) to compute the min & max distances from the reference.
This will give users much finer control on the range values.
2017-01-31 09:08:10 +09:00
bc4aeefe82 Make 'make local' twice quicker.
Use new Main->relations ID usages mapping in BKE_library_make_local().

This allows a noticeable simplification in code, and can be up to twice
quicker as previous code (Make Local: All from 2 to 1 minute e.g. in a
huge production file with thousands of linked data-blocks).

Note that new code has been successfuly tested with several complex cases
(production files from Agent327), as well as some testcases from recent
bug reports related to that function. But as always, nothing beats real
usage by real users, so please check this before we release 2.79. ;)

Main areas that would be affected: Make Local operations (L shortcut in
3DView), and append from libraries.
2017-01-30 22:33:20 +01:00
eadfd901ad Optimization: pass Main to BKE_library_foreach_ID_link() and use its relations.
Use Main->relations in BKE_library_foreach_ID_link(), when possible
(i.e. IDWALK_READONLY is set), and if the data is available of course.

This is quite minor optimization, no sensible improvements are expected,
but does not hurt either to avoid potentially tens of looping over e.g.
objects constraints and modifiers, or heap of drivers...
2017-01-30 22:33:20 +01:00
fbd28d375a Fix missing non-ID nodetrees in ID relationships built from library_query.c
This shall fix both existing code (bpy mapping, and local/lib usages
checks), and new Main->relations generation.
2017-01-30 22:33:20 +01:00
4443bad30a Add optional, free-after-use usages mapping of IDs to Main.
The new MainIDRelations stores two mappings, one from ID users to ID
used, the other vice-versa.

That data is assumed to be short-living runtime, code creating it is
responsible to clear it asap. It will be much useful in places where we
handle relations between IDs for a lot of them at once.

Note: This commit is not fully functional, that is, the infamous, ugly,
PoS non-ID nodetrees will not be handled correctly when building relations.
Fix needed here is a bit noisy, so will be done in next own commit.
2017-01-30 22:33:20 +01:00
997a210b08 Fix T49632: Grease pencil in "Edit Strokes" mode: Snap tool did not snap points to active object
A simple confusion between enums: ~SNAP_NOT_ACTIVE~
2017-01-30 18:30:19 -03:00
4580ace4c1 Alembic/CacheFile: fix crash de-referencing NULL pointer. 2017-01-30 10:46:24 +01:00
62f2c44ffb Cleanup: Unused function and and variables in snap code
Please doublecheck ED_transform_snap_object_project_ray_ex() is really
valid, it's weird to have extra arguments here unused.
2017-01-30 09:26:33 +01:00
505ff16dbf Snap System: BVH: ignore AABBs behind ray
This provides a slight improvement in performance in specific cases, such as when the observer is inside a high poly object and executes snap to edge or vertex
2017-01-30 02:49:41 -03:00
318ee2e8c1 Fix unreported bug: parameter ray_start repeated
The bug would only be seen in terms of performance
2017-01-30 02:26:00 -03:00
167ab03f36 Solve compilation error: Field has incomplete type 'enum eViewProj'
Error reported by @tomjpsun
Patch D2491
2017-01-30 02:19:18 -03:00
cdff659036 Freestyle: Fix (unreported) wrong distance calculation in the Fill Range by Selection operator.
Distance calculation performed by the "Fill Range by Selection" button of the
"Distance from Camera" color, alpha and thickness modifiers was incorrect,
limiting the usefulness of the functionality.

The problem was that the distance between the camera and individual vertex
locations was calculated in the world space, which was inconsistent with the
distance calculation done by the modifiers in the camera space.
2017-01-30 12:18:39 +09:00
6c23a1b8b9 Remove BKE_boundbox_ray_hit_check
Remove `BKE_boundbox_ray_hit_check` since it is no longer being used and can be easily replaced by `isect_ray_aabb_v3_simple`
2017-01-29 14:19:58 -03:00
b99491caf7 [msvc] Set proper OpenSubdiv flags when not using find_package to find opensubdiv. Fixes T50548 2017-01-29 10:00:38 -07:00
cf6ca226fa New math_geom function isect_ray_aabb_v3_simple
The new `isect_ray_aabb_v3_simple` function replaces the `BKE_boundbox_ray_hit_check` and can be used in BVHTree Root (first AABB). So it is much more efficient.
2017-01-29 13:56:58 -03:00
dead79a16a Rename func set_SnapData to snap_data_set
Don't use CamelCase in functions and try to keep area affected first, and action last, in names
2017-01-29 13:13:14 -03:00
88b0b22914 fix T50486: Don't always do the ray_start_correction in the ortho view
You need to make sure that ray_start is really far away, because even in the Orthografic view, in some cases, the ray can start inside the object
2017-01-29 12:26:15 -03:00
cd596fa1c7 Remove struct PreDefProject and store all immutable parameters within the new struct SnapData
In order to simplify the reading of these functions, the parameters: `snap_to`, `mval`, `ray_start`, `ray_dir`, `view_proj` and `depth_range` are now stored in the struct `SnapData`
2017-01-29 12:07:14 -03:00
d6f965b99c Fix T50550: GPUShader: compile error - Background image not showing in
viewport.

Caused by rBd6cf28c5e15739f864fbf04614c2a50708b4b152, which forgot to
update the GLSL code for the "Light Path" node.
2017-01-29 16:00:25 +01:00
15b253c082 Fix blurry icons 2017-01-29 17:21:57 +03:00
ba116c8e9c fix D2489: Collada exporter broke edit data when exporting Armature while in Armature edit mode 2017-01-28 22:10:20 +01:00
c64c901535 fix D2489: Collada exporter broke edit data when exporting Armature while in Armature edit mode 2017-01-28 21:51:18 +01:00
e4e1900012 Fix (IRC reported) DataTransfer modifier affecting base mesh in some cases.
Checking only whether mverts is same as base mesh one is not enough in
all cases, some modifiers (deform ones) can only generate new mvert
data, while keeping others from original mesh.

Now checking both mvert or medge, hopefully this will be enough to catch
all problematic cases this time.

Thanks @gaia for finding that problem. :)
2017-01-27 19:27:07 +01:00
11abb13483 Fix T50534, Part II: warn user when DataTransfer mod affects custom normals.
Custom normals need Autosmooth setting to be enabled, always!
2017-01-27 19:07:29 +01:00
fb2f95c91a Fix T50534: Part I, cleanup loop normals generated during modifier stack evaluation.
Those could stay around, and be displayed in 3DView even when autosmooth
was disabled (but would not be 'active').
2017-01-27 19:07:29 +01:00
bfe3b967fa UI: Move Scene Game Properties to the Scene Tab (was in world) 2017-01-27 11:36:53 -05:00
436f1e3345 Snap Functions: Remove the use of the function 'BLI_bvhtree_find_nearest_to_ray' in transform_snap_object
Although the "BLI_bvhtree_find_nearest_to_ray" function is more practical than the generic "BLI_bvhtree_walk_dfs", it does not work to snap in perspective view. This makes it necessary to add "ifs" and functions that make the code difficult to understand

patch: D2474
2017-01-27 13:02:05 -03:00
0330741548 Cycles: Add option to replace GI with AO approximation after certain amount of bounces
This is a speed up option which is mainly useful for viewport. Gives nice speedup in
the barbershop scene of 2x when replacing GI with AO after 2nd bounce without loosing
too much details.

Reviewers: brecht

Subscribers: eyecandy, venomgfx

Differential Revision: https://developer.blender.org/D2383
2017-01-27 14:21:49 +01:00
Dalai Felinto
84b18162cf Fixup for rBac58a7fa (HSV doversion)
We are not bumping file version, but we cannot have the doversion code running twice.
In this particular case it was crashing files, since we were setting node->storage to NULL, and later on accessing it.
2017-01-27 11:24:23 +01:00
bce9e80d82 CMake: Fix typo 2017-01-27 05:24:58 +01:00
67bef6bcf6 Depsgraph: Fix typo in assert 2017-01-26 17:22:54 +01:00
fd69ba2255 Depsgraph: Link from material to object shading
This is a ground work for the upcoming changes in Blender 2.8 branch
where we need to do special actions to reconstruct shaders when
material changes.
2017-01-26 17:01:37 +01:00
c441eb27ea Depsgraph: Add relation from node tree to material it's coming from 2017-01-26 16:49:24 +01:00
331f721725 Depsgraph: Remove owner argument from relations builder as well
The idea was to link something to a parent, but the point is:
we must not pass owner deep and then have any parent-type-related
logic implemented in the "children".
2017-01-26 16:36:37 +01:00
f14e1da5aa Fix (unreported) crash when file browser attempts to show preview of some defective font
Confirmed with the Wine's bundled fonts.
2017-01-27 00:36:24 +09:00
3c3c52a74b Depsgraph: Remove owner node argument which was simply passed around 2017-01-26 16:29:09 +01:00
ac58a7fa19 Compositor: Make HSV node inputs a real sockets
This is much more flexible solution which will allow doing some
more procedural features.

Reviewers: brecht, dfelinto, mont29

Reviewed By: mont29

Subscribers: Severin

Differential Revision: https://developer.blender.org/D2403
2017-01-26 15:20:13 +01:00
Dalai Felinto
18cf3e1a38 Fix unfreed memory after cleaning render layers
The freestyle data was never freed when removing a renderlayer.

```
blender -b --factory-startup --debug-memory --python-expr "import bpy;bpy.ops.scene.render_layer_add();bpy.context.scene.render.layers.active_index=0;bpy.ops.scene.render_layer_remove()"
```
2017-01-26 11:58:51 +01:00
01527197aa Alembic: fix compile error on Linux. 2017-01-26 06:18:07 +01:00
b91edd61d0 Fix T50287: Blender crashes when open a blend that contains an alembic
file.

Missed in rB62a2ed97b.
2017-01-26 06:16:33 +01:00
64f5afdb89 [Cycles/MSVC/Testing] Fix broken test code.
Currently the tests don't run on windows for the following reasons

1) render_graph_finalize has an linking issue due missing a bunch of libraries (not sure why this is not an issue for linux)
2) This one is more interesting, in test/python/cmakelists.txt ${TEST_BLENDER_EXE_BARE} and ${TEST_BLENDER_EXE} are flat out wrong, but for some reason this doesn't matter for most tests, cause ctest will actually go out and look for the executable and fix the path for you *BUT* only for the command, if you use them in any of the parameters it'll happily pass on the wrong path.
3) on linux you can just run a .py file, windows is not as awesome and needs to be told to run it with pyton.
4) had to use the NAME/COMMAND long form of add_test otherwise $<TARGET_FILE:blender> doesn't get expanded, why? beats me.
5) missing idiff.exe for msvc2015/x64 in the libs folder.

This patch addresses 1-4 , but given I have no working Linux build environment, I'm unsure if it'll break anything there

5 has been fixed in rBL61751

Reviewers: juicyfruit, brecht, sergey

Reviewed By: sergey

Subscribers: Blendify

Tags: #cycles, #automated_testing

Differential Revision: https://developer.blender.org/D2367
2017-01-25 09:37:19 -07:00
Dalai Felinto
e5482f986c Fix T50115: stereoscopic video file memory leak 2017-01-25 15:16:36 +01:00
ced20b74e5 Fix T50032: Wrong render result when same image is used with and without alpha 2017-01-25 14:02:59 +01:00
e29a6f739d Fix T50512: Linked Backround scene with animation not updating with new depsgraph
Was missing relations for the set scenes.

Perhaps not ideal solution, but should be good enough for now.
2017-01-25 12:30:29 +01:00
e4de6e87e1 Depsgraph: Do ID tag outside of build_scene
Otherwise it was possible to get ID tags cleared in the middle
of DEG construction when there are set scenes used.
2017-01-25 12:28:27 +01:00
8ea09252c8 Fix T50517: Rendering expecting time is negative 2017-01-25 11:18:12 +01:00
4cbfaa6f3f Revert "UI: Add missing menu item"
This reverts commit 1ad842d432.
2017-01-25 01:33:10 -05:00
1ad842d432 UI: Add missing menu item 2017-01-25 01:00:28 -05:00
a7d5cabd4e Fix T49405: Crash when baking with adaptive subdivision
Blenders baking system currently doesn't support the topology used by
adaptive subdivision and primitive ids will be wrong or out of range
leading to crashes. Updating the baking system to support other
topologies would be a bit involved, so for now we simply disable
subdivision while baking to avoid crashes.
2017-01-25 00:40:45 -05:00
57f937ad5a Remove commented code 2017-01-24 16:00:15 -05:00
Julian Eisel
8a6c689f30 Fix T50386: Crash when spawning pie menus
D2455 by @raa, thanks!
2017-01-24 21:35:38 +01:00
605695de61 Depsgraph: Fix duplicated operation node when two objects are sharing same armature 2017-01-24 17:15:39 +01:00
d84df351d0 Cycles: Don't rely on indirectly included algorithm 2017-01-24 16:39:16 +01:00
Dalai Felinto
f81ead6c38 Fix blenderplayer build 2017-01-18 16:34:01 +01:00
Julian Eisel
c8d1319452 Fix wrong logic in HMD device toggling 2016-11-24 19:45:23 +01:00
Julian Eisel
0c86cebeb2 Merge branch 'master' into HMD_viewport 2016-11-24 19:08:40 +01:00
Julian Eisel
129955e34b Give info on why "Use Device IPD" is disabled
Also renamed RNA properties and removed unneeded update function.
2016-11-23 23:11:00 +01:00
Julian Eisel
67847067b9 Couple of fix for case no device is available/active
Fixes:
* HMD device option using invalid value
* HMD view drawing on-screen info and using wrong matrices
* Hardly usable 3D view due to projection and modelview matrix being unit matrices
All issues where only visible when the HMD device option is set to 'None'
2016-11-23 18:08:26 +01:00
Julian Eisel
6a696c5bb4 Fixes for build options 2016-11-23 17:53:57 +01:00
Julian Eisel
1ea4d4362d Merge branch 'master' into HMD_viewport 2016-11-23 11:58:34 +01:00
Julian Eisel
a757065875 Fix KM_CLICK events broken 2016-11-23 02:26:43 +01:00
Julian Eisel
911fd31894 Fix HMD device set to 'none' after loading factory settings
We now use the last input device if available.
2016-11-23 02:09:30 +01:00
Julian Eisel
585c5e72ab Fix no active HMD when opening file that was saved during HMD session 2016-11-23 01:58:31 +01:00
Julian Eisel
d0000ef6fc Several minor corrections 2016-11-23 01:24:50 +01:00
Julian Eisel
91d0198d0e Make "Use Device Rotation" toggle work again
When this is disabled we just manually calculate the camera offsets. Actually I have no idea if math is correct but it doesn't seem totally wrong at least :P Don't have an HMD to test right now.
2016-11-23 00:52:22 +01:00
Julian Eisel
e2dd63eb55 Allow zooming/panning while HMD view is in camera perspective 2016-11-22 17:04:28 +01:00
Julian Eisel
48b38797c6 Merge branch 'master' into HMD_viewport
Conflicts:
	source/blender/makesrna/intern/rna_userdef.c
2016-11-20 19:32:02 +01:00
Julian Eisel
e06fa55a48 Add a dropdown to support multiple lens-distortion shaders 2016-11-20 00:11:41 +01:00
Julian Eisel
d9428f7a03 Merge branch 'master' into HMD_viewport
Conflicts:
	source/blender/blenloader/intern/versioning_270.c
2016-11-19 21:09:48 +01:00
Julian Eisel
c2b72626bf Replace low-level HMD check with higher level API call 2016-11-19 19:25:13 +01:00
Julian Eisel
8bfc10ce66 Make HMD window a proper 'restricted' window
A restricted window is a new concept that doesn't allow changing the screen of a window in any way. This way we can ensure the HMD window is only used for displaying the 3D View, so users can't accidentally change it without knowing how to get back. This also fixes some issues we had when using temp screens like they're used for UserPrefs.
Fixes:
* Could open toolbar/properties in HMD view
* HMD window used when opening UserPrefs through menu/shortcut
* Could easily change editor to non-3D-View
2016-11-19 13:38:17 +01:00
Julian Eisel
a29c325c83 Move HMD view shading option to window manager level
Was a bit ugly to have this in scene level, window manager isn't perfect either, but prefer it there.
2016-11-18 00:12:57 +01:00
Julian Eisel
509945633b Move HMD panel into 3D View properties
Still not a really perfect place since this is global, but can't think of a better one. More options will be added later on, so worth having an own panel.
2016-11-17 23:06:30 +01:00
Julian Eisel
fdb0d37bdf Remove scene level HMDVIEW_SESSION_RUNNING flag
Also separated HMD view drawing from stereo3d drawing some more.
2016-11-15 23:30:05 +01:00
Julian Eisel
ccf5de8a71 Merge branch 'master' into HMD_viewport
Conflicts:
	source/blender/blenloader/intern/versioning_270.c
	source/blender/editors/interface/resources.c
2016-11-15 16:18:56 +01:00
Julian Eisel
9ce9540afd Move HMD options to User Preferences 2016-11-11 17:45:46 +01:00
Julian Eisel
fdd4c5a98d Merge branch 'master' into HMD_viewport
Conflicts:
	source/blender/blenloader/intern/versioning_270.c
2016-11-11 16:22:40 +01:00
e2ccfdaa29 Fix bplayer (c) 2016-11-03 20:28:48 +01:00
8e1cf5237f Merge branch 'master' into HMD_viewport
Conflicts:
	source/blender/blenloader/intern/versioning_270.c
2016-11-03 20:10:55 +01:00
994795c1ed Add libhidapi to install_deps.sh script.
Note: only tested (both package and source compilation) with Debian
testing distro, others (fedora-like, arch-like) might not be working,
especially the compilation option.
2016-11-03 20:05:18 +01:00
TheOnlyJoey
54ed6f8918 Fixed deepoon variables for vc2013 compile 2016-10-31 14:21:47 +01:00
TheOnlyJoey
ce4f04f268 Fixed cmake option for htc vive in OpenHMD 2016-10-29 16:58:09 +02:00
TheOnlyJoey
e7670e9bb0 - Added initial HTC Vive support, still uses complimentary sensor fusion, could drift a bit 2016-10-29 16:21:56 +02:00
TheOnlyJoey
46bc9bcbba - Updated Oculus CV1 support 2016-10-29 16:01:03 +02:00
TheOnlyJoey
1a0d1064ee Removed cordinate frame from OpenHMD Deepoon driver 2016-10-29 01:19:39 +02:00
Julian Eisel
bebd1fbcd8 Own panel for HMD stuff
No need to enable "Views" option anymore now.
2016-10-28 23:56:22 +02:00
459f922484 Updated OpenHMD to match their latest master (1c984fb)
Adds support for Oculus Rift CV1 and Deepoon E2
2016-10-28 23:41:39 +02:00
Julian Eisel
913903af74 Fix warning with WITH_OPENHMD enabled 2016-10-28 23:23:25 +02:00
Julian Eisel
1a1b51f329 Fall back to return unit matrix 2016-10-28 23:11:20 +02:00
Julian Eisel
b7beb76211 Fix compiling without WITH_INPUT_HMD 2016-10-28 20:52:30 +02:00
Julian Eisel
2d2d44ca71 No need to apply HMD rotation in operator anymore
Now done by requesting modelview/projection matrices from OpenHMD.
2016-10-28 20:35:38 +02:00
Julian Eisel
14b9e0a933 Use projection matrix from HMD, don't add to Blender's 2016-10-28 20:03:34 +02:00
Julian Eisel
6d52d7e32d Merge branch 'master' into HMD_viewport 2016-10-12 20:17:24 +02:00
Julian Eisel
bf426bdf1e Proper default value for custom HMD IPD 2016-10-12 20:08:37 +02:00
Julian Eisel
a1562bbb53 Use modelview matrix from OpenHMD, get custom IPD to work
Also renamed interocular distance to IPD in UI (slightly different things), removed unused matrix getters and made sure enabling/disabling custom IPD behaves nicely. Note that both projection and modelview matrices from OpenHMD get the Blender equivalents applied on top, so they act as relative transformations. Rotating, zooming and panning in HMD view works properly too now.
2016-10-12 19:53:03 +02:00
Julian Eisel
505b1fdcb2 Always use projection matrix from OpenHMD
Was previously only used while in camera view.
Right now, you can't zoom during HMD session, should be fixable though. Custom interocular distance and optional HMD rotation don't work now either, need to check if we want to keep them.
2016-10-12 13:05:41 +02:00
Julian Eisel
b95a7c0af3 Fix disabling lens distortion shader causing OpenGL shader error
Also cleanup.
2016-10-12 01:06:09 +02:00
Julian Eisel
f8cfffec4f Use center as pivot for rotating views, avoid passing around arg 2016-10-11 22:44:14 +02:00
Julian Eisel
17a7c6a140 Fix warning without WITH_INPUT_HMD 2016-10-11 22:21:53 +02:00
Julian Eisel
e4a82a1e39 Make HMD IPD work properly with Multi-view format 2016-10-11 22:18:41 +02:00
Julian Eisel
7a4138a5b9 Toggle into scene camera when opening HMD window 2016-10-11 21:53:06 +02:00
Julian Eisel
99a29209b4 Fix crashes with HMD view in scenes without camera 2016-10-11 18:54:29 +02:00
Julian Eisel
637ca57ce9 Init proper default settings when creating new scene 2016-10-11 18:43:42 +02:00
Julian Eisel
9d9db8f748 Fix checkbox for getting IPD from device always disabled while no HMD session runs 2016-10-11 18:41:26 +02:00
Julian Eisel
ed34f17604 Refactor HMD->Camera relation, avoid low-level call 2016-10-11 18:05:11 +02:00
Julian Eisel
3db824b617 Show info in tooltip on why HMD session can't be started 2016-10-11 15:50:11 +02:00
Julian Eisel
24f4c98cc2 Move interocular distance settings out of camera data
These aren't just for the camera, but for entire HMD session.
2016-10-09 03:08:03 +02:00
Julian Eisel
c1846b18b1 Move HMD view settings into own scene level struct
For some reason I placed this in RenderData earlier.
2016-10-09 02:41:43 +02:00
Julian Eisel
f40b22365d HMD view doesn't require own multiview mode anymore
HMD view buttons and options are always visible in "Views" panel now (Properties Editor -> Render Layers context).
2016-10-09 01:22:25 +02:00
Julian Eisel
ebc32889be Return info in tooltip on why IPD button is disabled 2016-10-08 23:14:49 +02:00
Julian Eisel
ddb2a36a4d Merge branch 'master' into HMD_viewport
Conflicts:
	source/blender/blenloader/intern/versioning_270.c
	source/blender/editors/interface/resources.c
2016-10-08 23:06:51 +02:00
Julian Eisel
17cbaf5d16 Merge branch 'master' into HMD_viewport
Conflicts:
	intern/ghost/intern/GHOST_System.cpp
	intern/ghost/intern/GHOST_System.h
	source/blender/blenkernel/BKE_blender_version.h
	source/blender/blenloader/CMakeLists.txt
	source/blender/blenloader/intern/versioning_270.c
	source/blender/windowmanager/CMakeLists.txt
	source/blender/windowmanager/intern/wm_window.c
	source/blenderplayer/bad_level_call_stubs/CMakeLists.txt
2016-09-08 13:30:20 +02:00
Julian Eisel
2ccdd0be51 Fix non-HMD window not drawing viewport in camera view
Also added WITH_INPUT_HMD checks
2016-08-03 16:48:04 +02:00
Julian Eisel
753dbee557 Merge branch 'HMD_viewport' of git.blender.org:blender into HMD_viewport 2016-08-02 01:23:33 +02:00
Julian Eisel
495e99fbc1 Undo accidental change 2016-08-02 01:19:46 +02:00
Julian Eisel
2924c09298 Viewport HMD integration using OpenHMD
= Viewport HMD integration using OpenHMD =

This adds initial support for controlling the viewport view using a head mounted display (HMD).

To use it, go to the Properties Editor, Render Layers context. Enable Views, select "HMD View". You can then open a new HMD Window from there and start a HMD session.

**TODOs:**
* Move HMD options to a better place, they are not Render Layer related (Maybe properties region?)
* Zoom and pan don't work in HMD window while in camera view
* View streched vertically in HMD window while not in camera view
* TODOs/XXXs marked in code (esp. WM_ calls in BKE_)
* Apply D1350 for better mouse interaction while in HMD view

Reviewers: sergey, dfelinto

Differential Revision: https://developer.blender.org/D2133
2016-08-02 01:10:28 +02:00
Julian Eisel
3d9fca040b Update/correct version patching 2016-08-02 00:42:19 +02:00
Julian Eisel
122e479fe7 Fixes for WITH_OPENHMD and WITH_INPUT_HMD options
And cleanup.
2016-08-02 00:39:07 +02:00
Julian Eisel
d0fce1c992 Cleanup: Undo whitespace changes, comments, etc 2016-08-02 00:28:11 +02:00
Julian Eisel
eb9f4d233c Merge branch 'master' into HMD_viewport 2016-08-01 23:01:40 +02:00
Julian Eisel
e1b662f017 Adjust opening position and size of HMD window 2016-08-01 22:30:53 +02:00
Julian Eisel
a68db93fc2 Fix streched viewport in camera view 2016-08-01 22:06:33 +02:00
Julian Eisel
6e30e9b16d Various cleanup 2016-08-01 21:58:21 +02:00
Julian Eisel
7cf31cb048 Cleanup: Use 4x4 matrices, naming, compiler hints, use API function 2016-08-01 02:49:36 +02:00
Julian Eisel
8f025c41e4 Merge branch 'master' into HMD_viewport
Conflicts:
	intern/ghost/intern/GHOST_System.h
	source/blender/blenkernel/intern/camera.c
	source/blender/blenkernel/intern/screen.c
	source/blender/editors/space_view3d/drawobject.c
	source/blender/editors/space_view3d/space_view3d.c
2016-08-01 02:23:40 +02:00
Julian Eisel
28d4cdaffc Reset writefile.c to earlier state to avoid merge hell
Was caused by whitespace auto-cleaning.
2016-08-01 01:49:38 +02:00
Julian Eisel
d90aec52ff Fix linking with Blenderplayer enabled 2016-08-01 01:11:06 +02:00
3774a424ea Implemented initial support for using HMD projection matrices in blender viewport.
Also did some general cleaning
2016-07-31 21:24:55 +02:00
Julian Eisel
95074bcd12 Always use parallel convergence in HMD mode
Previously it was just using whatever was set in non-HMD mode.
I guess using parallel convergence for usage with HMDs is correct, could be wrong though ;)
2016-06-08 20:07:52 +02:00
Julian Eisel
506dfd65eb Only allow using Device IPD if it's available 2016-06-08 19:44:32 +02:00
Julian Eisel
eebc41ec4f Don't display "Set Stereo 3D" button for HMD mode 2016-06-08 18:49:56 +02:00
185619229c Fixed locks when opening/closing HMD sessions
Spaces to Tabs
2016-06-08 16:57:18 +02:00
b99acd7338 Merge branch 'HMD_viewport' of git.blender.org:blender into HMD_viewport 2016-06-08 14:09:38 +02:00
Julian Eisel
699df00847 Make branch compile with blenderplayer 2016-06-07 20:16:23 +02:00
Julian Eisel
dbd5663c26 Merge branch 'master' into HMD_viewport
Conflicts:
	build_files/cmake/macros.cmake
	intern/ghost/intern/GHOST_SystemX11.cpp
	source/blender/editors/space_view3d/view3d_ops.c
2016-06-07 20:14:35 +02:00
90746deeec Merge branch 'HMD_viewport' of git.blender.org:blender into HMD_viewport 2016-05-21 03:08:27 +02:00
Julian Eisel
c2fe571634 Merge branch 'master' into HMD_viewport 2016-05-20 23:21:07 +02:00
Julian Eisel
bf4fe3c84f Add compiler hints to WM_device API 2016-05-20 23:16:34 +02:00
Julian Eisel
4c4333e06c Add asserts for total device number 2016-05-20 23:13:35 +02:00
Julian Eisel
18f050f951 Fix all HMDs in UserPref device option showing same name 2016-05-20 22:56:17 +02:00
53bf3e1d84 Merge branch 'HMD_viewport' of git.blender.org:blender into HMD_viewport 2016-05-20 17:58:29 +02:00
Julian Eisel
072f453448 Merge branch 'master' into HMD_viewport
Conflicts:
	release/scripts/startup/bl_ui/properties_data_camera.py
	source/blender/blenkernel/BKE_blender.h
	source/blender/blenloader/intern/versioning_270.c
	source/blender/editors/interface/interface_handlers.c
	source/blender/editors/space_view3d/view3d_view.c
	source/blender/makesdna/DNA_camera_types.h
	source/blender/windowmanager/intern/wm_event_system.c
	source/blender/windowmanager/intern/wm_operators.c
2016-05-20 01:17:29 +02:00
Julian Eisel
cc160fb0a2 Fix compilation with OPENHMD_DRIVER_EXTERNAL or OPENHMD_DRIVER_ANDROID 2016-05-20 01:01:51 +02:00
b90f3b1982 Updated OpenHMD to latest git version
Now uses threading for updating the hmd, better polling rates for performance on heavy scenes/low framerates
2016-05-19 00:46:44 +02:00
Julian Eisel
a32710fd90 Merge branch 'master' into HMD_viewport 2016-04-13 19:59:45 +02:00
Julian Eisel
a742abfafb Fix crash when stopping HMD session
OpenHMD context should only be closed when deleting GHOST_OpenHMDManager, forgot to change that in rB0c029b7f86a0.
2016-04-13 19:56:35 +02:00
Julian Eisel
deb3e28954 Don't split view in lens distortion shader
We don't want to do this in lens distortion shader since we can't add the view offset needed for the 3D effect.
2016-04-13 19:41:41 +02:00
Julian Eisel
077e3109c8 Correction to previos commit: Use int for region size 2016-04-13 00:51:32 +02:00
Julian Eisel
4424a8e844 Use non-fixed screen size for lens distortion shader
Was assuming 1920x1080. Also minor cleanup.
2016-04-13 00:45:14 +02:00
Julian Eisel
6485c25c0e Fix compile error with WITH_INPUT_HMD disabled 2016-04-10 21:40:31 +02:00
Julian Eisel
8ec1bb0966 Corrections for WITH_INPUT_HMD 2016-04-10 21:07:12 +02:00
Julian Eisel
1a3c402585 Display HMD vendor name in UserPref HMD device option
And minor cleanup.
2016-04-10 20:47:51 +02:00
Julian Eisel
088e381ae2 Quiet warnings without WITH_OPENHMD 2016-04-10 20:18:55 +02:00
Julian Eisel
21fc36fbc8 Bring back version patch
Without it building with WITH_OPENHMD disabled will activate an invalid UserPref HMD device item.
2016-04-10 20:10:24 +02:00
Julian Eisel
d81b2309bc Automate selecting HMD device
This automates setting of HMD device UserPref option a bit, so that it's ready to go without manual adjustments.
We use the last device plugged in on startup (if one is available). On runtime, plugging in a device makes it active if 'None' was previously selected in the UserPref option.
Saving HMD in UserPrefs should also be supported, but can't test.
Also removes EVT_HMD_DEVICENUM_CHANGE and version patch, they're not needed anymore.
2016-04-10 19:57:45 +02:00
Julian Eisel
16af40cc36 Send an event when a HMD was plugged in/out
It's not used for now, will commit separately.
2016-04-10 19:17:56 +02:00
Julian Eisel
691e8b135c More minor cleanup 2016-04-10 15:50:27 +02:00
Julian Eisel
60645b4030 Minor cleanup 2016-04-10 02:23:10 +02:00
Julian Eisel
30723504be Fix crash opening UserPrefs on some systems. 2016-04-10 02:13:51 +02:00
Julian Eisel
4bb2efcb6e Merge branch 'master' into HMD_viewport 2016-04-10 01:42:21 +02:00
Julian Eisel
0c029b7f86 Cleanup & fixes in GHOST_OpenHMDManager
Fix crash opening UserPrefs->System with HMD session running, fix OpenHMD context being re-created on each redraw of UserPrefs->System, get rid of m_available (can use m_device NULL check instead), other minor cleanup.
2016-04-10 01:40:31 +02:00
b189710cd8 - Fixed getting device information for the user preferences
- Defaulting to device 0 in openhmd which is the last plugged in (will fallback on Dummy Device)
2016-04-06 16:41:24 +02:00
Julian Eisel
88879dfae1 Add assert to ensure HMD view is always fullscreen 2016-03-29 02:19:11 +02:00
Julian Eisel
eec5ac5927 Cleanup: Unused variable/unused value 2016-03-29 01:58:01 +02:00
Julian Eisel
bacadeb8c4 Add build option WITH_INPUT_HMD
If we later want to support other drivers aside from OpenHMD, we only want OpenHMD to work at the low GHOST level. The new option is for the higher, driver independent level.
Since currently only OpenHMD is supported, I added a compile warning for the case HMD input is enabled and OpenHMD is disabled. Also added a compile error for the case OpenHMD is enabled and HMD input is disabled.

This means we now have 3 HMD build options:
* WITH_INPUT_HMD - General HMD support
* WITH_OPENHMD - OpenHMD driver support
* WITH_OPENHMD_DYNLOAD - Dynamic runtime OpenHMD deps loading

Actually, _INPUT_HMD isn't totally correct since it does more than just input, but wanted to stick to naming conventions.
2016-03-29 01:42:40 +02:00
Julian Eisel
85759e74ab Merge branch 'master' into HMD_viewport 2016-03-29 00:00:51 +02:00
Julian Eisel
0b41972dca Fix compiling with WITH_OPENHMD disabled 2016-03-28 23:51:10 +02:00
Julian Eisel
c04031e94f Fix reading HMD window from file causing crash on session start 2016-03-28 23:40:46 +02:00
Julian Eisel
45397af24a Some hacks to disallow toggeling out of fullscreen in an HMD window 2016-03-28 23:02:50 +02:00
Julian Eisel
2f4148d833 Remove unused storage for lens distortion shader
Also removes unneeded button from UI and unneeded RNA defines.
2016-03-28 21:38:04 +02:00
Julian Eisel
c8eb1c93af Fix memory leak in lens distortion shader
Also, the shader itself wasn't drawing previously, which it does now (but still incorrect).
2016-03-28 21:13:45 +02:00
Julian Eisel
8f9b30610b Sync Cycles UI code 2016-03-28 20:55:46 +02:00
Julian Eisel
410b681d1f Option for HMD view lens distortion shader
Enabled by default. Note that shader is currently broken though.
2016-03-28 20:50:56 +02:00
Julian Eisel
b6174113c9 Fix HMD session not ended correctly when closing HMD view during session 2016-03-28 19:09:13 +02:00
Julian Eisel
72e5ee8471 Cleanup: Tweak operator names 2016-03-28 19:06:24 +02:00
Julian Eisel
c5fc10ba3f Add UserPref option to change HMD device
A new file wm_device.c is added with this, think this is good to have.

NOTE: Couldn't really test if changing device actually works as I don't have one. Without a device available everything seems to work though.
2016-03-28 15:15:41 +02:00
Julian Eisel
03e8afdb8d Option to request interocular distance from HMD driver
Adds a new camera option to request the interocular distance (IPD) from the HMD device/driver. It's still an open design question if it's even worth to support a custom distance though.

Also hides convergence options for HMD mode, not sure if those are needed.
2016-03-28 12:43:11 +02:00
Julian Eisel
2d57a89629 Show option for interocular distance for HMD mode
Just as for stereo 3D, available in properties editor, camera context.
2016-03-27 15:00:52 +02:00
Julian Eisel
f83eba6011 Merge branch 'master' into HMD_viewport 2016-03-27 14:09:22 +02:00
Julian Eisel
367b6f1646 Merge branch 'master' into HMD_viewport 2016-03-26 01:16:44 +01:00
c0ddaefb5d HMD: Cleanup of CMake file 2016-03-25 10:42:03 +01:00
58568d1bd3 HMD: Add support of lazil loading udev library
This way we can statically link against hidapi libraries but dont'
require static linking against udev or even having specific ABI
version of this library installed on the client machine.

For now the following libraries will try to be loaded:
  libudev.so, libudev.so.0, libudev.so.1 and libudev.so.2

Not future proof since it might be version 3 of udev releases
eventually, good enough for the beginning. We can simply do a
for-loop to query like 100 of ABIs.

Udev wrangler is a bit different from other wranglers we've got,
it has wrapper functions around dlopen-ed symbols, so you can't
check directly if function was loaded or not, but this is the
only way to make external libraries working fine with wrangler
without need of re-compiling the library.
2016-03-25 10:31:10 +01:00
b811750153 HMD: Quick and dirty way to make sort of portable builds on Linux
It will require having libudev.so.1 which isn't ideal but should work for
most distros for now.

Will be worked around later with udev wrangler.
2016-03-24 20:01:16 +01:00
Julian Eisel
9f145cd1b4 Merge branch 'master' into HMD_viewport 2016-03-22 01:26:07 +01:00
Julian Eisel
0751953efd Option for HMD view shading mode 2016-03-22 01:25:01 +01:00
ad502106e4 - Fixed correct event polling for all operating systems
- Fixed up openhmd cmake for windows builds
2016-03-18 17:18:46 +01:00
Julian Eisel
9e1583a0a9 Fix inner manipulator circle not aligned to viewplane 2016-03-18 03:12:12 +01:00
d8239304de Open/close HMD device based on session status 2016-03-18 03:07:40 +01:00
Julian Eisel
d04b6a7cda Fix anaglyph viewport drawing with HMD view open 2016-03-17 23:13:34 +01:00
Julian Eisel
49d9131ebd Fix stopping session not exiting fullscreen 2016-03-17 22:58:42 +01:00
Julian Eisel
599355304d Fix camera not being reset when stopping session by closing HMD window 2016-03-17 22:53:57 +01:00
Julian Eisel
5a8e1c28c8 Reset camera on HMD session end
Added utility functions for getting/setting rotation from quaterion.
2016-03-17 22:50:00 +01:00
134be85218 Fixed memory addressing, should work on every system now 2016-03-17 22:03:13 +01:00
3609e8868c Added check for nan events from OpenHMD 2016-03-17 21:05:45 +01:00
Julian Eisel
53d36ad280 All camera rotation modes work now 2016-03-17 20:38:05 +01:00
12ee739cbc Fixed warnings for compiling OpenHMD, added static flag for windows compile 2016-03-17 20:06:05 +01:00
Julian Eisel
e56fda407c Fix: Image editor window opened when trying to open UserPref window 2016-03-17 18:48:20 +01:00
Julian Eisel
85cde2a444 Fix start session button not grayed out if HMD window was closed using window handlers 2016-03-17 18:38:28 +01:00
Julian Eisel
9c4e06fcc4 Make HMD session non-modal and move it to WM level 2016-03-17 18:14:56 +01:00
062d66156b Expanded OpenHMDManager with additional features 2016-03-17 18:04:07 +01:00
b7ff6efaf2 Fixed hmd event despatching for all operating systems 2016-03-17 17:24:45 +01:00
Julian Eisel
38c6437df7 Use initial camera rotation as starting rotation for HMD
We have to store the previous orientation quaternion so we can get the delta rotation to apply to the object. For now I added a global variable - ugly but works ;)

Currently, you have to set the camera to use quaternion rotation mode, others aren't really usable yet.
2016-03-17 15:56:44 +01:00
53d1c4ed05 Added compile static to OpenHMD cmake on windows 2016-03-17 15:46:48 +01:00
fcaf81cf2d Moved updating the OpenHMD events in the ghost system to a GHOST_System base class wich get called by the derived for OS independent updating 2016-03-17 15:24:27 +01:00
Julian Eisel
98535f578a Draw second camera with offset (actual 3D effect)
We're simply reusing stereo 3D pipeline here.
2016-03-17 00:17:45 +01:00
Julian Eisel
13d06fa38b Fix viewplane drawn with wrong offset 2016-03-17 00:15:49 +01:00
Julian Eisel
164a1af8cd Use a more common way to open the HMD window 2016-03-16 20:18:57 +01:00
f35c1a339d Added OpenHMD in the build structure, uses WITH_OPENHMD so it can be disabled
Has a requirement on libhidapi, cmake checks for that (should be added to install-deps)
2016-03-16 19:48:05 +01:00
Julian Eisel
a9d0ca72c6 Fix cycles not drawing correct settings for HMD UI 2016-03-16 17:24:32 +01:00
Julian Eisel
b0f91cc221 Merge remote-tracking branch 'github/vr_experiments' into HMD_viewport 2016-03-16 16:52:56 +01:00
Julian Eisel
c3b1c5d026 Merge remote-tracking branch 'github/vr_experiments' into HMD_viewport 2016-03-16 16:09:39 +01:00
Julian Eisel
1863ebcacc Fix outliner not recieving events while HMD session is running 2016-03-11 18:28:08 +01:00
Julian Eisel
5ff399d69a Let button to open HMD window close the win if it's already opened 2016-03-11 18:10:18 +01:00
Julian Eisel
30647c0d5c Custom title for HMD window ("Blender HMD View") 2016-03-11 17:03:45 +01:00
Julian Eisel
5ec1249769 Store HMD Window in Window Manager, avoids lookups and screen flag 2016-03-11 16:25:27 +01:00
Julian Eisel
a3d4644996 UI: Minor adjustments 2016-03-11 14:56:12 +01:00
163e978be1 Fixed lens distortion orientation 2016-03-11 06:24:11 +01:00
Julian Eisel
4f38d44eb2 Fix HMD updating even if HMD session is not running 2016-03-11 04:55:56 +01:00
Julian Eisel
cde072b618 Cleanup: Style, removed debug prints 2016-03-11 04:55:56 +01:00
713829c8e4 Merge branch 'vr_experiments' of https://github.com/julianeisel/blender into vr_experiments 2016-03-11 04:46:52 +01:00
e806f478e5 Finished lens distortion shader, removed some unused variables and cleaned up a bit 2016-03-11 04:45:52 +01:00
Julian Eisel
5b8c1da845 Fix HMD update events missing window 2016-03-11 04:43:33 +01:00
Julian Eisel
b8d2c0da47 Allow cursor to be in any window without stopping HMD update 2016-03-11 04:18:48 +01:00
Julian Eisel
c5a75b8647 Fix modal HMD session handler only called while cursor is in main window 2016-03-11 03:30:19 +01:00
Julian Eisel
409154f1f8 Don't allow to open multiple HMD views
And cleanup.
2016-03-11 03:24:23 +01:00
Julian Eisel
994e0b04d9 Fix missing play button 2016-03-11 03:17:52 +01:00
Julian Eisel
e4bc3bac37 Use modal handler for HMD session
Also some cleanup.
2016-03-11 03:05:14 +01:00
Julian Eisel
fe520b7688 Initial side-by-side HMD view support 2016-03-11 01:32:07 +01:00
d737b41a47 Added lens distortion glsl shader for use with HMD (Head Mounted Display) functionality
NOTE: Still has some debug information and test buttons
2016-03-10 20:02:02 +01:00
Julian Eisel
759be70ab4 Couple of fixes and make stuff working 2016-03-10 07:25:06 +01:00
Julian Eisel
8b701bb913 Hook up HMD with camera 2016-03-10 06:22:54 +01:00
Julian Eisel
764a878938 Get operator to open HMD window to work 2016-03-10 03:58:09 +01:00
Galadus
408cbe918b minor changes
ui patches copied from Severin
2016-03-10 01:38:26 +01:00
Galadus
57424a2401 Added OpenHMD Ghost manager
Added OpenHMD Ghost event
Added OpenHMD windowmanager event type for vr camera transform updates
Began integration if the OpenHMDManager with the ghost system (only updated from the GHOST_SystemX11 for now)
2016-03-09 21:44:53 +01:00
1041 changed files with 44597 additions and 18945 deletions

4
.gitmodules vendored
View File

@@ -2,15 +2,19 @@
path = release/scripts/addons
url = ../blender-addons.git
ignore = all
branch = master
[submodule "release/scripts/addons_contrib"]
path = release/scripts/addons_contrib
url = ../blender-addons-contrib.git
ignore = all
branch = master
[submodule "release/datafiles/locale"]
path = release/datafiles/locale
url = ../blender-translations.git
ignore = all
branch = master
[submodule "source/tools"]
path = source/tools
url = ../blender-dev-tools.git
ignore = all
branch = master

View File

@@ -371,6 +371,13 @@ if(WIN32)
option(WITH_INPUT_IME "Enable Input Method Editor (IME) for complex Asian character input" ON)
endif()
option(WITH_INPUT_NDOF "Enable NDOF input devices (SpaceNavigator and friends)" ${_init_INPUT_NDOF})
# HMD - actually not really input, there's also some other stuff for it
option(WITH_INPUT_HMD "Enable HMD support in Blender (Head Mounted Displays for VR support)" ON)
option(WITH_OPENHMD "Enable OpenHMD driver library" ON)
option(WITH_OPENHMD_DYNLOAD "Dynamically load OpenHMD dependencies at runtime" OFF)
mark_as_advanced(WITH_OPENHMD_DYNLOAD)
option(WITH_RAYOPTIMIZATION "Enable use of SIMD (SSE) optimizations for the raytracer" ON)
if(UNIX AND NOT APPLE)
option(WITH_INSTALL_PORTABLE "Install redistributeable runtime, otherwise install into CMAKE_INSTALL_PREFIX" ON)
@@ -445,6 +452,7 @@ option(WITH_BOOST "Enable features depending on boost" ON)
# Unit testsing
option(WITH_GTESTS "Enable GTest unit testing" OFF)
option(WITH_OPENGL_TESTS "Enable OpenGL related unit testing (Experimental)" OFF)
# Documentation
@@ -518,18 +526,20 @@ endif()
option(WITH_LEGACY_DEPSGRAPH "Build Blender with legacy dependency graph" ON)
mark_as_advanced(WITH_LEGACY_DEPSGRAPH)
# Use hardcoded paths or find_package to find externals
option(WITH_WINDOWS_FIND_MODULES "Use find_package to locate libraries" OFF)
mark_as_advanced(WITH_WINDOWS_FIND_MODULES)
if(WIN32)
# Use hardcoded paths or find_package to find externals
option(WITH_WINDOWS_FIND_MODULES "Use find_package to locate libraries" OFF)
mark_as_advanced(WITH_WINDOWS_FIND_MODULES)
option(WITH_WINDOWS_CODESIGN "Use signtool to sign the final binary." OFF)
mark_as_advanced(WITH_WINDOWS_CODESIGN)
option(WITH_WINDOWS_CODESIGN "Use signtool to sign the final binary." OFF)
mark_as_advanced(WITH_WINDOWS_CODESIGN)
set(WINDOWS_CODESIGN_PFX CACHE FILEPATH "Path to pfx file to use for codesigning.")
mark_as_advanced(WINDOWS_CODESIGN_PFX)
set(WINDOWS_CODESIGN_PFX CACHE FILEPATH "Path to pfx file to use for codesigning.")
mark_as_advanced(WINDOWS_CODESIGN_PFX)
set(WINDOWS_CODESIGN_PFX_PASSWORD CACHE STRING "password for pfx file used for codesigning.")
mark_as_advanced(WINDOWS_CODESIGN_PFX_PASSWORD)
set(WINDOWS_CODESIGN_PFX_PASSWORD CACHE STRING "password for pfx file used for codesigning.")
mark_as_advanced(WINDOWS_CODESIGN_PFX_PASSWORD)
endif()
# avoid using again
option_defaults_clear()
@@ -706,6 +716,15 @@ if(WITH_PYTHON_MODULE AND WITH_PYTHON_INSTALL)
message(FATAL_ERROR "WITH_PYTHON_MODULE requires WITH_PYTHON_INSTALL to be OFF")
endif()
if(WITH_INPUT_HMD AND NOT WITH_OPENHMD)
message(WARNING "WITH_INPUT_HMD is enabled, but OpenHMD driver (WITH_OPENHMD) is disabled. "
"Only a limited set of HMD features will be available.")
endif()
if(WITH_OPENHMD AND NOT WITH_INPUT_HMD)
message(FATAL_ERROR "WITH_OPENHMD requires WITH_INPUT_HMD")
endif()
# may as well build python module without a UI
if(WITH_PYTHON_MODULE)
@@ -723,7 +742,7 @@ if(NOT WITH_BOOST)
macro(set_and_warn
_setting _val)
if(${${_setting}})
message(STATUS "'WITH_BOOST' is disabled: forceing 'set(${_setting} ${_val})'")
message(STATUS "'WITH_BOOST' is disabled: forcing 'set(${_setting} ${_val})'")
endif()
set(${_setting} ${_val})
endmacro()
@@ -924,7 +943,7 @@ if(WITH_X11)
if(WITH_X11_ALPHA)
find_library(X11_Xrender_LIB Xrender ${X11_LIB_SEARCH_PATH})
mark_as_advanced(X11_Xrender_LIB)
if (X11_Xrender_LIB)
if(X11_Xrender_LIB)
list(APPEND PLATFORM_LINKLIBS ${X11_Xrender_LIB})
else()
set(WITH_X11_ALPHA OFF)

View File

@@ -1,4 +1,4 @@
# -*- mode: gnumakefile; tab-width: 8; indent-tabs-mode: t; -*-
# -*- mode: gnumakefile; tab-width: 4; indent-tabs-mode: t; -*-
# vim: tabstop=4
#
# ##### BEGIN GPL LICENSE BLOCK #####
@@ -113,7 +113,7 @@ CMAKE_CONFIG = cmake $(BUILD_CMAKE_ARGS) \
# X11 spesific
ifdef DISPLAY
CMAKE_CONFIG_TOOL = cmake-gui
else
else
CMAKE_CONFIG_TOOL = ccmake
endif
@@ -127,7 +127,7 @@ all: .FORCE
# # if test ! -f $(BUILD_DIR)/CMakeCache.txt ; then \
# # $(CMAKE_CONFIG); \
# # fi
# # do this always incase of failed initial build, could be smarter here...
@$(CMAKE_CONFIG)

View File

@@ -30,13 +30,13 @@ with-all,with-opencollada,\
ver-ocio:,ver-oiio:,ver-llvm:,ver-osl:,ver-osd:,ver-openvdb:,\
force-all,force-python,force-numpy,force-boost,\
force-ocio,force-openexr,force-oiio,force-llvm,force-osl,force-osd,force-openvdb,\
force-ffmpeg,force-opencollada,force-alembic,\
force-ffmpeg,force-opencollada,force-alembic,force-hidapi\
build-all,build-python,build-numpy,build-boost,\
build-ocio,build-openexr,build-oiio,build-llvm,build-osl,build-osd,build-openvdb,\
build-ffmpeg,build-opencollada,build-alembic,\
build-ffmpeg,build-opencollada,build-alembic,build-hidapi\
skip-python,skip-numpy,skip-boost,\
skip-ocio,skip-openexr,skip-oiio,skip-llvm,skip-osl,skip-osd,skip-openvdb,\
skip-ffmpeg,skip-opencollada,skip-alembic \
skip-ffmpeg,skip-opencollada,skip-alembic,skip-hidapi \
-- "$@" \
)
@@ -182,6 +182,9 @@ ARGUMENTS_INFO="\"COMMAND LINE ARGUMENTS:
--build-ffmpeg
Force the build of FFMpeg.
--build-hidapi
Force the build of hidapi.
Note about the --build-foo options:
* They force the script to prefer building dependencies rather than using available packages.
This may make things simpler and allow working around some distribution bugs, but on the other hand it will
@@ -234,6 +237,9 @@ ARGUMENTS_INFO="\"COMMAND LINE ARGUMENTS:
--force-ffmpeg
Force the rebuild of FFMpeg.
--force-hidapi
Force the rebuild of hidapi.
Note about the --force-foo options:
* They obviously only have an effect if those libraries are built by this script
(i.e. if there is no available and satisfactory package)!
@@ -277,7 +283,10 @@ ARGUMENTS_INFO="\"COMMAND LINE ARGUMENTS:
Unconditionally skip OpenCOLLADA installation/building.
--skip-ffmpeg
Unconditionally skip FFMpeg installation/building.\""
Unconditionally skip FFMpeg installation/building.
--skip-hidapi
Unconditionally skip hidapi installation/building.\""
##### Main Vars #####
@@ -322,8 +331,8 @@ OPENEXR_FORCE_REBUILD=false
OPENEXR_SKIP=false
_with_built_openexr=false
OIIO_VERSION="1.7.8"
OIIO_VERSION_MIN="1.6.0"
OIIO_VERSION="1.7.13"
OIIO_VERSION_MIN="1.7.13"
OIIO_VERSION_MAX="1.9.0" # UNKNOWN currently # Not supported by current OSL...
OIIO_FORCE_BUILD=false
OIIO_FORCE_REBUILD=false
@@ -360,7 +369,7 @@ OPENVDB_FORCE_REBUILD=false
OPENVDB_SKIP=false
# Alembic needs to be compiled for now
ALEMBIC_VERSION="1.6.0"
ALEMBIC_VERSION="1.7.1"
ALEMBIC_VERSION_MIN=$ALEMBIC_VERSION
ALEMBIC_FORCE_BUILD=false
ALEMBIC_FORCE_REBUILD=false
@@ -399,6 +408,12 @@ MP3LAME_DEV=""
OPENJPEG_USE=false
OPENJPEG_DEV=""
HIDAPI_VERSION="0.8.0"
HIDAPI_VERSION_MIN="0.8.0"
HIDAPI_FORCE_BUILD=false
HIDAPI_FORCE_REBUILD=false
HIDAPI_SKIP=false
# Whether to use system GLEW or not (OpenSubDiv needs recent glew to work).
NO_SYSTEM_GLEW=false
@@ -597,6 +612,9 @@ while true; do
--build-alembic)
ALEMBIC_FORCE_BUILD=true; shift; continue
;;
--build-hidapi)
HIDAPI_FORCE_BUILD=true; shift; continue
;;
--force-all)
PYTHON_FORCE_REBUILD=true
NUMPY_FORCE_REBUILD=true
@@ -611,6 +629,7 @@ while true; do
OPENCOLLADA_FORCE_REBUILD=true
FFMPEG_FORCE_REBUILD=true
ALEMBIC_FORCE_REBUILD=true
HIDAPI_FORCE_REBUILD=true
shift; continue
;;
--force-python)
@@ -654,6 +673,9 @@ while true; do
--force-alembic)
ALEMBIC_FORCE_REBUILD=true; shift; continue
;;
--force-hidapi)
HIDAPI_FORCE_REBUILD=true; shift; continue
;;
--skip-python)
PYTHON_SKIP=true; shift; continue
;;
@@ -693,6 +715,9 @@ while true; do
--skip-alembic)
ALEMBIC_SKIP=true; shift; continue
;;
--skip-hidapi)
HIDAPI_SKIP=true; shift; continue
;;
--)
# no more arguments to parse
break
@@ -791,11 +816,13 @@ OPENCOLLADA_REPO_BRANCH="master"
FFMPEG_SOURCE=( "http://ffmpeg.org/releases/ffmpeg-$FFMPEG_VERSION.tar.bz2" )
HIDAPI_SOURCE=( "https://github.com/signal11/hidapi/archive/hidapi-0.8.0-rc1.tar.gz" )
CXXFLAGS_BACK=$CXXFLAGS
if [ "$USE_CXX11" = true ]; then
WARNING "You are trying to use c++11, this *should* go smoothely with any very recent distribution
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.
Please note that until the transition to C++11-built libraries if completed in your distribution, situation will
@@ -839,7 +866,8 @@ You may also want to build them yourself (optional ones are [between brackets]):
* [OpenSubDiv $OSD_VERSION_MIN] (from $OSD_SOURCE_REPO, branch $OSD_SOURCE_REPO_BRANCH, commit $OSD_SOURCE_REPO_UID).
* [OpenVDB $OPENVDB_VERSION_MIN] (from $OPENVDB_SOURCE), [Blosc $OPENVDB_BLOSC_VERSION] (from $OPENVDB_BLOSC_SOURCE).
* [OpenCollada] (from $OPENCOLLADA_SOURCE, branch $OPENCOLLADA_REPO_BRANCH, commit $OPENCOLLADA_REPO_UID).
* [Alembic $ALEMBIC_VERSION] (from $ALEMBIC_SOURCE).\""
* [Alembic $ALEMBIC_VERSION] (from $ALEMBIC_SOURCE).
* [HIDAPI $HIDAPI_VERSION] (from $HIDAPI_SOURCE).\""
if [ "$DO_SHOW_DEPS" = true ]; then
PRINT ""
@@ -2236,9 +2264,6 @@ compile_ALEMBIC() {
return
fi
compile_HDF5
PRINT ""
# To be changed each time we make edits that would modify the compiled result!
alembic_magic=2
_init_alembic
@@ -2266,8 +2291,16 @@ compile_ALEMBIC() {
cmake_d="-D CMAKE_INSTALL_PREFIX=$_inst"
# Without Boost or TR1, Alembic requires C++11.
if [ "$USE_CXX11" != true ]; then
cmake_d="$cmake_d -D ALEMBIC_LIB_USES_BOOST=ON"
cmake_d="$cmake_d -D ALEMBIC_LIB_USES_TR1=OFF"
fi
if [ -d $INST/boost ]; then
cmake_d="$cmake_d -D BOOST_ROOT=$INST/boost"
if [ -d $INST/boost ]; then
cmake_d="$cmake_d -D BOOST_ROOT=$INST/boost"
fi
cmake_d="$cmake_d -D USE_STATIC_BOOST=ON"
else
cmake_d="$cmake_d -D USE_STATIC_BOOST=OFF"
@@ -2285,8 +2318,6 @@ compile_ALEMBIC() {
cmake_d="$cmake_d -D USE_STATIC_HDF5=OFF"
cmake_d="$cmake_d -D ALEMBIC_ILMBASE_LINK_STATIC=OFF"
cmake_d="$cmake_d -D ALEMBIC_SHARED_LIBS=OFF"
cmake_d="$cmake_d -D ALEMBIC_LIB_USES_BOOST=ON"
cmake_d="$cmake_d -D ALEMBIC_LIB_USES_TR1=OFF"
INFO "ILMBASE_ROOT=$INST/openexr"
fi
@@ -2508,6 +2539,75 @@ compile_FFmpeg() {
fi
}
#### Build HIDAPI ####
_init_hidapi() {
_src=$SRC/hidapi-$HIDAPI_VERSION
_inst=$INST/hidapi-$HIDAPI_VERSION
_inst_shortcut=$INST/hidapi
}
clean_hidapi() {
_init_hidapi
_clean
}
compile_hidapi() {
if [ "$NO_BUILD" = true ]; then
WARNING "--no-build enabled, HIDAPI will not be compiled!"
return
fi
# To be changed each time we make edits that would modify the compiled result!
hidapi_magic=1
_init_hidapi
# Clean install if needed!
magic_compile_check hidapi-$HIDAPI_VERSION $hidapi_magic
if [ $? -eq 1 -o "$HIDAPI_FORCE_REBUILD" = true ]; then
clean_hidapi
fi
if [ ! -d $_inst ]; then
INFO "Building hidapi-$HIDAPI_VERSION"
prepare_opt
if [ ! -d $_src -o true ]; then
mkdir -p $SRC
download HIDAPI_SOURCE[@] "$_src.tar.gz"
INFO "Unpacking hidapi-$HIDAPI_VERSION"
tar -C $SRC --transform "s,(/?)hidapi-[^/]*(.*),\1hidapi-$HIDAPI_VERSION\2,x" -xf $_src.tar.gz
fi
cd $_src
./bootstrap
./configure --prefix=$_inst
make -j$THREADS install
make clean
if [ -d $_inst ]; then
_create_inst_shortcut
else
ERROR "hidapi-$HIDAPI_VERSION failed to compile, exiting"
exit 1
fi
magic_compile_set hidapi-$HIDAPI_VERSION $hidapi_magic
cd $CWD
INFO "Done compiling hidapi-$HIDAPI_VERSION!"
else
INFO "Own hidapi-$HIDAPI_VERSION is up to date, nothing to do!"
INFO "If you want to force rebuild of this lib, use the --force-hidapi option."
fi
run_ldconfig "hidapi"
}
#### Install on DEB-like ####
get_package_version_DEB() {
@@ -2777,7 +2877,7 @@ install_DEB() {
boost_version=$(echo `get_package_version_DEB libboost-dev` | sed -r 's/^([0-9]+\.[0-9]+).*/\1/')
install_packages_DEB libboost-{filesystem,iostreams,locale,regex,system,thread,wave}$boost_version-dev
install_packages_DEB libboost-{filesystem,iostreams,locale,regex,system,thread,wave,program-options}$boost_version-dev
clean_Boost
else
compile_Boost
@@ -2979,6 +3079,34 @@ install_DEB() {
compile_FFmpeg
fi
fi
PRINT ""
_do_compile_hidapi=false
if [ "$HIDAPI_SKIP" = true ]; then
WARNING "Skipping hidapi installation, as requested..."
elif [ "$HIDAPI_FORCE_BUILD" = true ]; then
INFO "Forced hidapi building, as requested..."
_do_compile_hidapi=true
else
check_package_DEB libhidapi-dev
if [ $? -eq 0 ]; then
check_package_version_ge_DEB libhidapi-dev $HIDAPI_VERSION_MIN
if [ $? -eq 0 ]; then
install_packages_DEB libhidapi-dev
clean_hidapi
else
_do_compile_hidapi=true
fi
else
_do_compile_hidapi=true
fi
fi
if [ "$_do_compile_hidapi" = true ]; then
install_packages_DEB libudev-dev libusb-1.0-0-dev
compile_hidapi
fi
}
@@ -3520,6 +3648,33 @@ install_RPM() {
compile_FFmpeg
fi
fi
PRINT ""
_do_compile_hidapi=false
if [ "$HIDAPI_SKIP" = true ]; then
WARNING "Skipping hidapi installation, as requested..."
elif [ "$HIDAPI_FORCE_BUILD" = true ]; then
INFO "Forced hidapi building, as requested..."
_do_compile_hidapi=true
else
check_package_RPM hidapi-devel
if [ $? -eq 0 ]; then
check_package_version_ge_RPM hidapi-devel $HIDAPI_VERSION_MIN
if [ $? -eq 0 ]; then
install_packages_RPM hidapi-devel
clean_hidapi
else
_do_compile_hidapi=true
fi
else
_do_compile_hidapi=true
fi
fi
if [ "$_do_compile_hidapi" = true ]; then
install_packages_RPM libusbx-devel # No libudev in fedora?
compile_hidapi
fi
}
@@ -3945,6 +4100,33 @@ install_ARCH() {
compile_FFmpeg
fi
fi
PRINT ""
_do_compile_hidapi=false
if [ "$HIDAPI_SKIP" = true ]; then
WARNING "Skipping hidapi installation, as requested..."
elif [ "$HIDAPI_FORCE_BUILD" = true ]; then
INFO "Forced hidapi building, as requested..."
_do_compile_hidapi=true
else
check_package_ARCH hidapi
if [ $? -eq 0 ]; then
check_package_version_ge_ARCH hidapi $HIDAPI_VERSION_MIN
if [ $? -eq 0 ]; then
install_packages_ARCH hidapi
clean_hidapi
else
_do_compile_hidapi=true
fi
else
_do_compile_hidapi=true
fi
fi
if [ "$_do_compile_hidapi" = true ]; then
install_packages_ARCH libusb # No libudev in arch?
compile_hidapi
fi
}
@@ -4108,6 +4290,16 @@ install_OTHER() {
INFO "Forced FFMpeg building, as requested..."
compile_FFmpeg
fi
PRINT ""
_do_compile_hidapi=false
if [ "$HIDAPI_SKIP" = true ]; then
WARNING "Skipping hidapi installation, as requested..."
elif [ "$HIDAPI_FORCE_BUILD" = true ]; then
INFO "Forced hidapi building, as requested..."
compile_hidapi
fi
}
#### Printing User Info ####
@@ -4189,7 +4381,7 @@ print_info() {
_buildargs="-U *SNDFILE* -U *PYTHON* -U *BOOST* -U *Boost*"
_buildargs="$_buildargs -U *OPENCOLORIO* -U *OPENEXR* -U *OPENIMAGEIO* -U *LLVM* -U *CYCLES*"
_buildargs="$_buildargs -U *OPENSUBDIV* -U *OPENVDB* -U *COLLADA* -U *FFMPEG* -U *ALEMBIC*"
_buildargs="$_buildargs -U *OPENSUBDIV* -U *OPENVDB* -U *COLLADA* -U *FFMPEG* -U *ALEMBIC* -U *OPENHMD* -U *HIDAPI*"
if [ "$USE_CXX11" = true ]; then
_1="-D WITH_CXX11=ON"
@@ -4252,7 +4444,7 @@ print_info() {
PRINT " $_3"
_buildargs="$_buildargs $_1 $_2 $_3"
if [ -d $INST/osl ]; then
_1="-D CYCLES_OSL=$INST/osl"
_1="-D OSL_ROOT_DIR=$INST/osl"
PRINT " $_1"
_buildargs="$_buildargs $_1"
fi
@@ -4331,6 +4523,17 @@ print_info() {
fi
fi
if [ "$HIDAPI_SKIP" = false ]; then
_1="-D WITH_OPENHMD=ON"
PRINT " $_1"
_buildargs="$_buildargs $_1"
if [ -d $INST/hidapi ]; then
_1="-D HIDAPI_ROOT_DIR=$INST/hidapi"
PRINT " $_1"
_buildargs="$_buildargs $_1"
fi
fi
PRINT ""
PRINT "Or even simpler, just run (in your blender-source dir):"
PRINT " make -j$THREADS BUILD_CMAKE_ARGS=\"$_buildargs\""

View File

@@ -94,6 +94,10 @@ set(OPENCOLORIO_OPENCOLORIO_LIBRARY "${OPENCOLORIO_ROOT_DIR}/lib/libOpenColorIO.
set(OPENCOLORIO_TINYXML_LIBRARY "${OPENCOLORIO_ROOT_DIR}/lib/libtinyxml.a" CACHE STRING "" FORCE)
set(OPENCOLORIO_YAML-CPP_LIBRARY "${OPENCOLORIO_ROOT_DIR}/lib/libyaml-cpp.a" CACHE STRING "" FORCE)
# Freetype
set(FREETYPE_INCLUDE_DIRS "/usr/include/freetype2" CACHE STRING "" FORCE)
set(FREETYPE_LIBRARY "/usr/lib${MULTILIB}/libfreetype.a" CACHE STRING "" FORCE)
# OpenImageIO
if(GLIBC EQUAL "2.19")
set(OPENIMAGEIO_LIBRARY
@@ -102,6 +106,7 @@ if(GLIBC EQUAL "2.19")
/usr/lib${MULTILIB}/libwebp.a
/usr/lib${MULTILIB}/liblzma.a
/usr/lib${MULTILIB}/libjbig.a
${FREETYPE_LIBRARY}
CACHE STRING "" FORCE
)
endif()
@@ -139,5 +144,14 @@ set(OPENVDB_LIBRARY
CACHE BOOL "" FORCE
)
# OpenHMD
if(GLIBC EQUAL "2.19")
set(HIDAPI_LIBRARY
/usr/lib${MULTILIB}/libhidapi-hidraw.a
CACHE STRING "" FORCE
)
set(WITH_OPENHMD_DYNLOAD ON CACHE BOOL "" FORCE)
endif()
# Additional linking libraries
set(CMAKE_EXE_LINKER_FLAGS "-lrt -static-libstdc++" CACHE STRING "" FORCE)

View File

@@ -4,10 +4,10 @@
# <pep8 compliant>
# List of the branches being built automatically overnight
NIGHT_SCHEDULE_BRANCHES = [None]
NIGHT_SCHEDULE_BRANCHES = [None, "blender2.8"]
# List of the branches available for force build
FORCE_SCHEDULE_BRANCHES = ["master", "gooseberry", "experimental-build"]
FORCE_SCHEDULE_BRANCHES = ["master", "blender2.8", "experimental-build"]
"""
Stock Twisted directory lister doesn't provide any information about last file
@@ -127,7 +127,14 @@ def schedule_force_build(name):
project=forcesched.FixedParameter(name="project", default="", hide=True)),
# For now, hide other codebases.
forcesched.CodebaseParameter(hide=True, codebase="blender-translations"),
forcesched.CodebaseParameter(hide=True, codebase="blender-addons"),
forcesched.CodebaseParameter(
codebase="blender-addons",
branch=forcesched.ChoiceStringParameter(
name="branch", choices=["master", "blender2.8"], default="master"),
repository=forcesched.FixedParameter(name="repository", default="", hide=True),
project=forcesched.FixedParameter(name="project", default="", hide=True),
revision=forcesched.FixedParameter(name="revision", default="", hide=True),
),
forcesched.CodebaseParameter(hide=True, codebase="blender-addons-contrib"),
forcesched.CodebaseParameter(hide=True, codebase="blender-dev-tools"),
forcesched.CodebaseParameter(hide=True, codebase="lib svn")],
@@ -139,11 +146,15 @@ def schedule_build(name, hour, minute=0):
scheduler_name = "nightly " + name
if current_branch:
scheduler_name += ' ' + current_branch
# Use special addons submodule branch when building blender2.8 branch.
addons_branch = "master"
if current_branch == "blender2.8":
addons_branch = "blender2.8"
c['schedulers'].append(timed.Nightly(name=scheduler_name,
codebases={
"blender": {"repository": ""},
"blender-translations": {"repository": "", "branch": "master"},
"blender-addons": {"repository": "", "branch": "master"},
"blender-addons": {"repository": "", "branch": addons_branch},
"blender-addons-contrib": {"repository": "", "branch": "master"},
"blender-dev-tools": {"repository": "", "branch": "master"},
"lib svn": {"repository": "", "branch": "trunk"}},
@@ -225,8 +236,7 @@ def git_step(branch=''):
def git_submodules_update():
command = ['git', 'submodule', 'foreach', '--recursive',
'git', 'pull', 'origin', 'master']
command = ['git', 'submodule', 'update', '--remote']
return ShellCommand(name='Submodules Update',
command=command,
description='updating',
@@ -235,7 +245,10 @@ def git_submodules_update():
def lib_svn_step(dir):
return SVN(name='lib svn',
name = "lib svn"
if dir == "darwin":
name = "C++11 lib svn"
return SVN(name=name,
baseURL='https://svn.blender.org/svnroot/bf-blender/%%BRANCH%%/lib/' + dir,
codebase='lib svn',
mode='update',
@@ -264,6 +277,9 @@ def generic_builder(id, libdir='', branch='', rsync=False):
f = BuildFactory()
if libdir != '':
f.addStep(lib_svn_step(libdir))
# Special trick to make sure we always have all the libs.
if libdir.startswith("darwin"):
f.addStep(lib_svn_step("darwin"))
for submodule in ('blender-translations',
'blender-addons',
@@ -286,7 +302,7 @@ def generic_builder(id, libdir='', branch='', rsync=False):
f.addStep(FileUpload(name='upload',
slavesrc='buildbot_upload.zip',
masterdest=filename,
maxsize=150 * 1024 * 1024,
maxsize=180 * 1024 * 1024,
workdir='install'))
f.addStep(MasterShellCommand(name='unpack',
command=['python2.7', unpack_script, filename],

View File

@@ -67,6 +67,9 @@ def get_platform(filename):
def get_branch(filename):
if filename.startswith("blender-2.8"):
return "blender2.8"
tokens = filename.split("-")
branch = ""

View File

@@ -72,10 +72,11 @@ if 'cmake' in builder:
# Set up OSX architecture
if builder.endswith('x86_64_10_6_cmake'):
cmake_extra_options.append('-DCMAKE_OSX_ARCHITECTURES:STRING=x86_64')
cmake_extra_options.append('-DCUDA_NVCC_EXECUTABLE=/usr/local/cuda8-hack/bin/nvcc')
cmake_extra_options.append('-DWITH_CODEC_QUICKTIME=OFF')
cmake_extra_options.append('-DCMAKE_OSX_DEPLOYMENT_TARGET=10.6')
build_cubins = False
cmake_extra_options.append('-DCUDA_HOST_COMPILER=/usr/local/cuda-hack/clang')
cmake_extra_options.append('-DCUDA_NVCC_EXECUTABLE=/usr/local/cuda-hack/nvcc')
elif builder.startswith('win'):
@@ -93,7 +94,6 @@ if 'cmake' in builder:
elif builder.startswith('win32'):
bits = 32
cmake_options.extend(['-G', 'Visual Studio 12 2013'])
cmake_extra_options.append('-DCUDA_NVCC_EXECUTABLE:FILEPATH=C:/Program Files/NVIDIA GPU Computing Toolkit/CUDA/v8.0/bin/nvcc.exe')
elif builder.startswith('linux'):
tokens = builder.split("_")
@@ -112,8 +112,8 @@ if 'cmake' in builder:
chroot_name = 'buildbot_' + deb_name + '_i686'
cuda_chroot_name = 'buildbot_' + deb_name + '_x86_64'
targets = ['player', 'blender', 'cuda']
cmake_extra_options.append('-DCUDA_NVCC_EXECUTABLE=/usr/local/cuda-8.0/bin/nvcc')
cmake_extra_options.extend(["-DCMAKE_C_COMPILER=/usr/bin/gcc-6",
"-DCMAKE_CXX_COMPILER=/usr/bin/g++-6"])
cmake_options.append("-C" + os.path.join(blender_dir, cmake_config_file))
@@ -180,7 +180,7 @@ if 'cmake' in builder:
os.remove('CMakeCache.txt')
retcode = subprocess.call(target_chroot_prefix + ['cmake', blender_dir] + target_cmake_options)
if retcode != 0:
print('Condifuration FAILED!')
print('Configuration FAILED!')
sys.exit(retcode)
if 'win32' in builder or 'win64' in builder:

View File

@@ -111,7 +111,8 @@ if builder.find('cmake') != -1:
if builder.endswith('vc2015'):
platform += "-vc14"
builderified_name = 'blender-{}-{}-{}'.format(blender_full_version, git_hash, platform)
if branch != '':
# NOTE: Blender 2.8 is already respected by blender_full_version.
if branch != '' and branch != 'blender2.8':
builderified_name = branch + "-" + builderified_name
os.rename(result_file, "{}.zip".format(builderified_name))
@@ -177,7 +178,8 @@ if builder.find('cmake') != -1:
blender_hash,
blender_glibc,
blender_arch)
if branch != '':
# NOTE: Blender 2.8 is already respected by blender_full_version.
if branch != '' and branch != 'blender2.8':
package_name = branch + "-" + package_name
upload_filename = package_name + ".tar.bz2"

View File

@@ -0,0 +1,71 @@
# - Find HIDAPI library from http://www.signal11.us/oss/hidapi/
# Find the native HIDAPI includes and library
# This module defines
# HIDAPI_INCLUDE_DIRS, where to find hidapi.h, Set when
# HIDAPI_INCLUDE_DIR is found.
# HIDAPI_LIBRARIES, libraries to link against to use HIDAPI.
# HIDAPI_ROOT_DIR, The base directory to search for HIDAPI.
# This can also be an environment variable.
# HIDAPI_FOUND, If false, do not try to use HIDAPI.
#
# also defined, but not for general use are
# HIDAPI_LIBRARY, where to find the HIDAPI library.
#=============================================================================
# Copyright 2016 Blender Foundation.
#
# Distributed under the OSI-approved BSD License (the "License");
# see accompanying file Copyright.txt for details.
#
# This software is distributed WITHOUT ANY WARRANTY; without even the
# implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
# See the License for more information.
#=============================================================================
# If HIDAPI_ROOT_DIR was defined in the environment, use it.
IF(NOT HIDAPI_ROOT_DIR AND NOT $ENV{HIDAPI_ROOT_DIR} STREQUAL "")
SET(HIDAPI_ROOT_DIR $ENV{HIDAPI_ROOT_DIR})
ENDIF()
SET(_hidapi_SEARCH_DIRS
${HIDAPI_ROOT_DIR}
/usr/local
/sw # Fink
/opt/local # DarwinPorts
/opt/csw # Blastwave
/opt/lib/hidapi
)
FIND_PATH(HIDAPI_INCLUDE_DIR
NAMES
hidapi.h
HINTS
${_hidapi_SEARCH_DIRS}
PATH_SUFFIXES
include/hidapi
)
FIND_LIBRARY(HIDAPI_LIBRARY
NAMES
hidapi hidapi-libusb
HINTS
${_hidapi_SEARCH_DIRS}
PATH_SUFFIXES
lib64 lib
)
# Handle the QUIETLY and REQUIRED arguments and set HIDAPI_FOUND to TRUE if
# all listed variables are TRUE
INCLUDE(FindPackageHandleStandardArgs)
FIND_PACKAGE_HANDLE_STANDARD_ARGS(HIDAPI DEFAULT_MSG
HIDAPI_LIBRARY HIDAPI_INCLUDE_DIR)
IF(HIDAPI_FOUND)
SET(HIDAPI_LIBRARIES ${HIDAPI_LIBRARY})
SET(HIDAPI_INCLUDE_DIRS ${HIDAPI_INCLUDE_DIR})
ENDIF(HIDAPI_FOUND)
MARK_AS_ADVANCED(
HIDAPI_INCLUDE_DIR
HIDAPI_LIBRARY
)

View File

@@ -60,7 +60,7 @@ FIND_FILE(OPENIMAGEIO_IDIFF
NAMES
idiff
HINTS
${OPENIMAGEIO_ROOT_DIR}
${_openimageio_SEARCH_DIRS}
PATH_SUFFIXES
bin
)

View File

@@ -39,13 +39,16 @@ macro(BLENDER_SRC_GTEST_EX NAME SRC EXTRA_LIBS DO_ADD_TEST)
${PTHREADS_LIBRARIES}
extern_glog
extern_gflags)
if(WITH_OPENMP_STATIC)
target_link_libraries(${NAME}_test ${OpenMP_LIBRARIES})
endif()
set_target_properties(${NAME}_test PROPERTIES
RUNTIME_OUTPUT_DIRECTORY "${TESTS_OUTPUT_DIR}"
RUNTIME_OUTPUT_DIRECTORY_RELEASE "${TESTS_OUTPUT_DIR}"
RUNTIME_OUTPUT_DIRECTORY_DEBUG "${TESTS_OUTPUT_DIR}"
INCLUDE_DIRECTORIES "${TEST_INC}")
if(${DO_ADD_TEST})
add_test(${NAME}_test ${TESTS_OUTPUT_DIR}/${NAME}_test)
add_test(NAME ${NAME}_test COMMAND ${TESTS_OUTPUT_DIR}/${NAME}_test WORKING_DIRECTORY $<TARGET_FILE_DIR:blender>)
endif()
endif()
endmacro()

View File

@@ -56,7 +56,7 @@ if(EXISTS ${SOURCE_DIR}/.git)
string(REGEX REPLACE "[\r\n]+" ";" _git_contains_branches "${_git_contains_branches}")
string(REGEX REPLACE ";[ \t]+" ";" _git_contains_branches "${_git_contains_branches}")
foreach(_branch ${_git_contains_branches})
if (NOT "${_branch}" MATCHES "\\(HEAD.*")
if(NOT "${_branch}" MATCHES "\\(HEAD.*")
set(MY_WC_BRANCH "${_branch}")
break()
endif()

View File

@@ -416,14 +416,7 @@ function(setup_liblinks
target_link_libraries(${target} ${OPENCOLORIO_LIBRARIES})
endif()
if(WITH_OPENSUBDIV OR WITH_CYCLES_OPENSUBDIV)
if(WIN32 AND NOT UNIX)
file_list_suffix(OPENSUBDIV_LIBRARIES_DEBUG "${OPENSUBDIV_LIBRARIES}" "_d")
target_link_libraries_debug(${target} "${OPENSUBDIV_LIBRARIES_DEBUG}")
target_link_libraries_optimized(${target} "${OPENSUBDIV_LIBRARIES}")
unset(OPENSUBDIV_LIBRARIES_DEBUG)
else()
target_link_libraries(${target} ${OPENSUBDIV_LIBRARIES})
endif()
endif()
if(WITH_OPENVDB)
target_link_libraries(${target} ${OPENVDB_LIBRARIES} ${TBB_LIBRARIES})
@@ -499,6 +492,10 @@ function(setup_liblinks
endif()
endif()
if(WITH_OPENHMD)
target_link_libraries(${target} ${OPENHMD_LIBRARIES} ${HIDAPI_LIBRARY})
endif()
# We put CLEW and CUEW here because OPENSUBDIV_LIBRARIES dpeends on them..
if(WITH_CYCLES OR WITH_COMPOSITOR OR WITH_OPENSUBDIV)
target_link_libraries(${target} "extern_clew")
@@ -508,6 +505,9 @@ function(setup_liblinks
target_link_libraries(${target} ${CUDA_CUDA_LIBRARY})
endif()
endif()
if(WITH_OPENHMD AND WITH_OPENHMD_DYNLOAD)
target_link_libraries(${target} "extern_udew")
endif()
target_link_libraries(
${target}
@@ -602,6 +602,7 @@ function(SETUP_BLENDER_SORTED_LIBS)
bf_freestyle
bf_ikplugin
bf_modifiers
bf_alembic
bf_bmesh
bf_gpu
bf_blenloader
@@ -620,7 +621,6 @@ function(SETUP_BLENDER_SORTED_LIBS)
bf_imbuf_openimageio
bf_imbuf_dds
bf_collada
bf_alembic
bf_intern_elbeem
bf_intern_memutil
bf_intern_guardedalloc
@@ -714,6 +714,10 @@ function(SETUP_BLENDER_SORTED_LIBS)
list(APPEND BLENDER_SORTED_LIBS bf_quicktime)
endif()
if(WITH_OPENHMD)
list(APPEND BLENDER_SORTED_LIBS extern_openhmd)
endif()
if(WITH_MOD_BOOLEAN)
list(APPEND BLENDER_SORTED_LIBS extern_carve)
endif()
@@ -1581,24 +1585,24 @@ macro(openmp_delayload
endmacro()
MACRO(WINDOWS_SIGN_TARGET target)
if (WITH_WINDOWS_CODESIGN)
if (!SIGNTOOL_EXE)
if(WITH_WINDOWS_CODESIGN)
if(!SIGNTOOL_EXE)
error("Codesigning is enabled, but signtool is not found")
else()
if (WINDOWS_CODESIGN_PFX_PASSWORD)
if(WINDOWS_CODESIGN_PFX_PASSWORD)
set(CODESIGNPASSWORD /p ${WINDOWS_CODESIGN_PFX_PASSWORD})
else()
if ($ENV{PFXPASSWORD})
if($ENV{PFXPASSWORD})
set(CODESIGNPASSWORD /p $ENV{PFXPASSWORD})
else()
message( FATAL_ERROR "WITH_WINDOWS_CODESIGN is on but WINDOWS_CODESIGN_PFX_PASSWORD not set, and environment variable PFXPASSWORD not found, unable to sign code.")
message(FATAL_ERROR "WITH_WINDOWS_CODESIGN is on but WINDOWS_CODESIGN_PFX_PASSWORD not set, and environment variable PFXPASSWORD not found, unable to sign code.")
endif()
endif()
add_custom_command(TARGET ${target}
POST_BUILD
COMMAND ${SIGNTOOL_EXE} sign /f ${WINDOWS_CODESIGN_PFX} ${CODESIGNPASSWORD} $<TARGET_FILE:${target}>
VERBATIM
)
POST_BUILD
COMMAND ${SIGNTOOL_EXE} sign /f ${WINDOWS_CODESIGN_PFX} ${CODESIGNPASSWORD} $<TARGET_FILE:${target}>
VERBATIM
)
endif()
endif()
ENDMACRO()

View File

@@ -1,5 +1,7 @@
set(PROJECT_DESCRIPTION "Blender is a very fast and versatile 3D modeller/renderer.")
set(PROJECT_COPYRIGHT "Copyright (C) 2001-2012 Blender Foundation")
string(TIMESTAMP CURRENT_YEAR "%Y")
set(PROJECT_DESCRIPTION "Blender is the free and open source 3D creation suite software.")
set(PROJECT_COPYRIGHT "Copyright (C) 2001-${CURRENT_YEAR} Blender Foundation")
set(PROJECT_CONTACT "foundation@blender.org")
set(PROJECT_VENDOR "Blender Foundation")
@@ -38,8 +40,8 @@ unset(MY_WC_HASH)
# Force Package Name
execute_process(COMMAND date "+%Y%m%d" OUTPUT_VARIABLE CPACK_DATE OUTPUT_STRIP_TRAILING_WHITESPACE)
string(TOLOWER ${PROJECT_NAME} PROJECT_NAME_LOWER)
if (MSVC)
if ("${CMAKE_SIZEOF_VOID_P}" EQUAL "8")
if(MSVC)
if("${CMAKE_SIZEOF_VOID_P}" EQUAL "8")
set(PACKAGE_ARCH windows64)
else()
set(PACKAGE_ARCH windows32)
@@ -48,7 +50,7 @@ else(MSVC)
set(PACKAGE_ARCH ${CMAKE_SYSTEM_PROCESSOR})
endif()
if (CPACK_OVERRIDE_PACKAGENAME)
if(CPACK_OVERRIDE_PACKAGENAME)
set(CPACK_PACKAGE_FILE_NAME ${CPACK_OVERRIDE_PACKAGENAME}-${PACKAGE_ARCH})
else()
set(CPACK_PACKAGE_FILE_NAME ${PROJECT_NAME_LOWER}-${MAJOR_VERSION}.${MINOR_VERSION}.${PATCH_VERSION}-git${CPACK_DATE}.${BUILD_REV}-${PACKAGE_ARCH})
@@ -135,4 +137,3 @@ unset(MINOR_VERSION)
unset(PATCH_VERSION)
unset(BUILD_REV)

View File

@@ -33,7 +33,7 @@ endmacro()
macro(windows_find_package package_name
)
if(WITH_WINDOWS_FIND_MODULES)
find_package( ${package_name})
find_package(${package_name})
endif(WITH_WINDOWS_FIND_MODULES)
endmacro()
@@ -66,7 +66,7 @@ set(CMAKE_MODULE_LINKER_FLAGS "${CMAKE_MODULE_LINKER_FLAGS} /SAFESEH:NO")
list(APPEND PLATFORM_LINKLIBS
ws2_32 vfw32 winmm kernel32 user32 gdi32 comdlg32
advapi32 shfolder shell32 ole32 oleaut32 uuid psapi Dbghelp
advapi32 shfolder shell32 ole32 oleaut32 uuid psapi Dbghelp setupapi
)
if(WITH_INPUT_IME)
@@ -446,10 +446,20 @@ if(WITH_MOD_CLOTH_ELTOPO)
endif()
if(WITH_OPENSUBDIV OR WITH_CYCLES_OPENSUBDIV)
set(OPENSUBDIV_INCLUDE_DIR ${LIBDIR}/opensubdiv/include)
set(OPENSUBDIV_LIBPATH ${LIBDIR}/opensubdiv/lib)
set(OPENSUBDIV_LIBRARIES ${OPENSUBDIV_LIBPATH}/osdCPU.lib ${OPENSUBDIV_LIBPATH}/osdGPU.lib)
find_package(OpenSubdiv)
set(OPENSUBDIV_INCLUDE_DIR ${LIBDIR}/opensubdiv/include)
set(OPENSUBDIV_LIBPATH ${LIBDIR}/opensubdiv/lib)
set(OPENSUBDIV_LIBRARIES optimized ${OPENSUBDIV_LIBPATH}/osdCPU.lib
optimized ${OPENSUBDIV_LIBPATH}/osdGPU.lib
debug ${OPENSUBDIV_LIBPATH}/osdCPU_d.lib
debug ${OPENSUBDIV_LIBPATH}/osdGPU_d.lib
)
set(OPENSUBDIV_HAS_OPENMP TRUE)
set(OPENSUBDIV_HAS_TBB FALSE)
set(OPENSUBDIV_HAS_OPENCL TRUE)
set(OPENSUBDIV_HAS_CUDA FALSE)
set(OPENSUBDIV_HAS_GLSL_TRANSFORM_FEEDBACK TRUE)
set(OPENSUBDIV_HAS_GLSL_COMPUTE TRUE)
windows_find_package(OpenSubdiv)
endif()
if(WITH_SDL)

View File

@@ -681,7 +681,7 @@ Image classes
.. attribute:: zbuff
Use depth component of render as grey scale color - suitable for texture source.
Use depth component of render as grayscale color - suitable for texture source.
:type: bool
@@ -817,7 +817,7 @@ Image classes
.. attribute:: zbuff
Use depth component of viewport as grey scale color - suitable for texture source.
Use depth component of viewport as grayscale color - suitable for texture source.
:type: bool
@@ -1260,8 +1260,8 @@ Filter classes
.. class:: FilterGray
Filter for gray scale effect.
Proportions of R, G and B contributions in the output gray scale are 28:151:77.
Filter for grayscale effect.
Proportions of R, G and B contributions in the output grayscale are 28:151:77.
.. attribute:: previous

View File

@@ -427,9 +427,9 @@ if BLENDER_REVISION != "Unknown":
BLENDER_VERSION_DOTS += " " + BLENDER_REVISION # '2.62.1 SHA1'
BLENDER_VERSION_PATH = "_".join(blender_version_strings) # '2_62_1'
if bpy.app.version_cycle == "release":
BLENDER_VERSION_PATH = "%s%s_release" % ("_".join(blender_version_strings[:2]),
bpy.app.version_char) # '2_62_release'
if bpy.app.version_cycle in {"rc", "release"}:
# '2_62a_release'
BLENDER_VERSION_PATH = "%s%s_release" % ("_".join(blender_version_strings[:2]), bpy.app.version_char)
# --------------------------DOWNLOADABLE FILES----------------------------------

View File

@@ -96,6 +96,11 @@ def main():
rsync_base = "rsync://%s@%s:%s" % (args.user, args.rsync_server, args.rsync_root)
blenver = blenver_zip = ""
api_name = ""
branch = ""
is_release = False
# I) Update local mirror using rsync.
rsync_mirror_cmd = ("rsync", "--delete-after", "-avzz", rsync_base, args.mirror_dir)
subprocess.run(rsync_mirror_cmd, env=dict(os.environ, RSYNC_PASSWORD=args.password))
@@ -108,19 +113,24 @@ def main():
subprocess.run(doc_gen_cmd)
# III) Get Blender version info.
blenver = blenver_zip = ""
getver_file = os.path.join(tmp_dir, "blendver.txt")
getver_script = (""
"import sys, bpy\n"
"with open(sys.argv[-1], 'w') as f:\n"
" f.write('%d_%d%s_release\\n' % (bpy.app.version[0], bpy.app.version[1], bpy.app.version_char)\n"
" if bpy.app.version_cycle in {'rc', 'release'} else '%d_%d_%d\\n' % bpy.app.version)\n"
" f.write('%d_%d_%d' % bpy.app.version)\n")
" is_release = bpy.app.version_cycle in {'rc', 'release'}\n"
" branch = bpy.app.build_branch.split()[0].decode()\n"
" f.write('%d\\n' % is_release)\n"
" f.write('%s\\n' % branch)\n"
" f.write('%d.%d%s\\n' % (bpy.app.version[0], bpy.app.version[1], bpy.app.version_char)\n"
" if is_release else '%s\\n' % branch)\n"
" f.write('%d_%d%s_release' % (bpy.app.version[0], bpy.app.version[1], bpy.app.version_char)\n"
" if is_release else '%d_%d_%d' % bpy.app.version)\n")
get_ver_cmd = (args.blender, "--background", "-noaudio", "--factory-startup", "--python-exit-code", "1",
"--python-expr", getver_script, "--", getver_file)
subprocess.run(get_ver_cmd)
with open(getver_file) as f:
blenver, blenver_zip = f.read().split("\n")
is_release, branch, blenver, blenver_zip = f.read().split("\n")
is_release = bool(int(is_release))
os.remove(getver_file)
# IV) Build doc.
@@ -132,7 +142,7 @@ def main():
os.chdir(curr_dir)
# V) Cleanup existing matching dir in server mirror (if any), and copy new doc.
api_name = "blender_python_api_%s" % blenver
api_name = blenver
api_dir = os.path.join(args.mirror_dir, api_name)
if os.path.exists(api_dir):
shutil.rmtree(api_dir)
@@ -150,19 +160,15 @@ def main():
os.rename(zip_path, os.path.join(api_dir, "%s.zip" % zip_name))
# VII) Create symlinks and html redirects.
#~ os.symlink(os.path.join(DEFAULT_SYMLINK_ROOT, api_name, "contents.html"), os.path.join(api_dir, "index.html"))
os.symlink("./contents.html", os.path.join(api_dir, "index.html"))
if blenver.endswith("release"):
symlink = os.path.join(args.mirror_dir, "blender_python_api_current")
if is_release:
symlink = os.path.join(args.mirror_dir, "current")
os.remove(symlink)
os.symlink("./%s" % api_name, symlink)
with open(os.path.join(args.mirror_dir, "250PythonDoc/index.html"), 'w') as f:
f.write("<html><head><title>Redirecting...</title><meta http-equiv=\"REFRESH\""
"content=\"0;url=../%s/\"></head><body>Redirecting...</body></html>" % api_name)
else:
symlink = os.path.join(args.mirror_dir, "blender_python_api_master")
os.remove(symlink)
os.symlink("./%s" % api_name, symlink)
elif branch == "master":
with open(os.path.join(args.mirror_dir, "blender_python_api/index.html"), 'w') as f:
f.write("<html><head><title>Redirecting...</title><meta http-equiv=\"REFRESH\""
"content=\"0;url=../%s/\"></head><body>Redirecting...</body></html>" % api_name)

View File

@@ -86,6 +86,10 @@ if(WITH_CYCLES OR WITH_COMPOSITOR OR WITH_OPENSUBDIV)
endif()
endif()
if(WITH_OPENHMD AND WITH_OPENHMD_DYNLOAD)
add_subdirectory(udew)
endif()
if(WITH_MOD_BOOLEAN)
add_subdirectory(carve)
endif()
@@ -111,3 +115,7 @@ endif()
if(WITH_SDL AND WITH_SDL_DYNLOAD)
add_subdirectory(sdlew)
endif()
if(WITH_OPENHMD)
add_subdirectory(openhmd)
endif()

View File

@@ -1,5 +1,5 @@
Project: OpenCL Wrangler
URL: https://github.com/OpenCLWrangler/clew
License: Apache 2.0
Upstream version: 309a653
Upstream version: 27a6867
Local modifications: None

View File

@@ -369,7 +369,7 @@ typedef unsigned int cl_GLenum;
#endif
/* Define basic vector types */
/* WOrkaround for ppc64el platform: conflicts with bool from C++. */
/* Workaround for ppc64el platform: conflicts with bool from C++. */
#if defined( __VEC__ ) && !(defined(__PPC64__) && defined(__LITTLE_ENDIAN__))
#include <altivec.h> /* may be omitted depending on compiler. AltiVec spec provides no way to detect whether the header is required. */
typedef vector unsigned char __cl_uchar16;
@@ -2765,11 +2765,40 @@ CLEW_FUN_EXPORT PFNCLGETGLCONTEXTINFOKHR __clewGetGLContextInfoKH
#define CL_DEVICE_GPU_OVERLAP_NV 0x4004
#define CL_DEVICE_KERNEL_EXEC_TIMEOUT_NV 0x4005
#define CL_DEVICE_INTEGRATED_MEMORY_NV 0x4006
#define CL_DEVICE_ATTRIBUTE_ASYNC_ENGINE_COUNT_NV 0x4007
#define CL_DEVICE_PCI_BUS_ID_NV 0x4008
#define CL_DEVICE_PCI_SLOT_ID_NV 0x4009
/*********************************
* cl_amd_device_attribute_query *
*********************************/
#define CL_DEVICE_PROFILING_TIMER_OFFSET_AMD 0x4036
#define CL_DEVICE_TOPOLOGY_AMD 0x4037
#define CL_DEVICE_BOARD_NAME_AMD 0x4038
#define CL_DEVICE_GLOBAL_FREE_MEMORY_AMD 0x4039
#define CL_DEVICE_SIMD_PER_COMPUTE_UNIT_AMD 0x4040
#define CL_DEVICE_SIMD_WIDTH_AMD 0x4041
#define CL_DEVICE_SIMD_INSTRUCTION_WIDTH_AMD 0x4042
#define CL_DEVICE_WAVEFRONT_WIDTH_AMD 0x4043
#define CL_DEVICE_GLOBAL_MEM_CHANNELS_AMD 0x4044
#define CL_DEVICE_GLOBAL_MEM_CHANNEL_BANKS_AMD 0x4045
#define CL_DEVICE_GLOBAL_MEM_CHANNEL_BANK_WIDTH_AMD 0x4046
#define CL_DEVICE_LOCAL_MEM_SIZE_PER_COMPUTE_UNIT_AMD 0x4047
#define CL_DEVICE_LOCAL_MEM_BANKS_AMD 0x4048
#define CL_DEVICE_THREAD_TRACE_SUPPORTED_AMD 0x4049
#define CL_DEVICE_GFXIP_MAJOR_AMD 0x404A
#define CL_DEVICE_GFXIP_MINOR_AMD 0x404B
#define CL_DEVICE_AVAILABLE_ASYNC_QUEUES_AMD 0x404C
#ifndef CL_DEVICE_TOPOLOGY_TYPE_PCIE_AMD
#define CL_DEVICE_TOPOLOGY_TYPE_PCIE_AMD 1
typedef union
{
struct { cl_uint type; cl_uint data[5]; } raw;
struct { cl_uint type; cl_char unused[17]; cl_char bus; cl_char device; cl_char function; } pcie;
} cl_device_topology_amd;
#endif
/*********************************
* cl_arm_printf extension

View File

@@ -15,7 +15,7 @@
typedef HMODULE CLEW_DYNLIB_HANDLE;
#define CLEW_DYNLIB_OPEN LoadLibrary
#define CLEW_DYNLIB_OPEN LoadLibraryA
#define CLEW_DYNLIB_CLOSE FreeLibrary
#define CLEW_DYNLIB_IMPORT GetProcAddress
#else
@@ -223,7 +223,7 @@ int clewInit()
__clewSetCommandQueueProperty = (PFNCLSETCOMMANDQUEUEPROPERTY )CLEW_DYNLIB_IMPORT(module, "clSetCommandQueueProperty");
#endif
__clewCreateBuffer = (PFNCLCREATEBUFFER )CLEW_DYNLIB_IMPORT(module, "clCreateBuffer");
__clewCreateSubBuffer = (PFNCLCREATESUBBUFFER )CLEW_DYNLIB_IMPORT(module, "clCreateBuffer");
__clewCreateSubBuffer = (PFNCLCREATESUBBUFFER )CLEW_DYNLIB_IMPORT(module, "clCreateSubBuffer");
__clewCreateImage = (PFNCLCREATEIMAGE )CLEW_DYNLIB_IMPORT(module, "clCreateImage");
__clewRetainMemObject = (PFNCLRETAINMEMOBJECT )CLEW_DYNLIB_IMPORT(module, "clRetainMemObject");
__clewReleaseMemObject = (PFNCLRELEASEMEMOBJECT )CLEW_DYNLIB_IMPORT(module, "clReleaseMemObject");

View File

@@ -114,7 +114,7 @@ extern "C" {
#define cuGLGetDevices cuGLGetDevices_v2
/* Types. */
#if defined(__x86_64) || defined(AMD64) || defined(_M_AMD64)
#if defined(__x86_64) || defined(AMD64) || defined(_M_AMD64) || defined (__aarch64__)
typedef unsigned long long CUdeviceptr;
#else
typedef unsigned int CUdeviceptr;

111
extern/openhmd/CMakeLists.txt vendored Normal file
View File

@@ -0,0 +1,111 @@
# ***** BEGIN GPL LICENSE BLOCK *****
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; either version 2
# of the License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software Foundation,
# Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
#
# ***** END GPL LICENSE BLOCK *****
set(INC
.
src
include
)
set(INC_SYS
)
set(SRC
src/openhmd.c
src/platform-win32.c
src/drv_dummy/dummy.c
src/omath.c
src/platform-posix.c
src/fusion.c
src/queue.c
src/shaders.c
)
# TODO: Either remove this or move to main CMakeLists.txt
OPTION(OPENHMD_DRIVER_OCULUS_RIFT "Oculus Rift DK1, DK2 and CV1" ON)
OPTION(OPENHMD_DRIVER_DEEPOON "Deepoon E2" ON)
OPTION(OPENHMD_DRIVER_PSVR "Sony PSVR" ON)
OPTION(OPENHMD_DRIVER_HTC_VIVE "HTC Vive" ON)
OPTION(OPENHMD_DRIVER_EXTERNAL "External sensor driver" OFF)
OPTION(OPENHMD_DRIVER_ANDROID "General Android driver" OFF)
if(MSVC)
add_definitions(-DOHMD_STATIC)
endif(MSVC)
if(OPENHMD_DRIVER_OCULUS_RIFT)
list(APPEND SRC
src/drv_oculus_rift/rift.c
src/drv_oculus_rift/packet.c
)
add_definitions(-DDRIVER_OCULUS_RIFT)
find_package(HIDAPI REQUIRED)
list(APPEND INC_SYS ${HIDAPI_INCLUDE_DIRS})
endif()
if(OPENHMD_DRIVER_DEEPOON)
list(APPEND SRC
src/drv_deepoon/deepoon.c
src/drv_deepoon/packet.c
)
add_definitions(-DDRIVER_DEEPOON)
find_package(HIDAPI REQUIRED)
list(APPEND INC_SYS ${HIDAPI_INCLUDE_DIRS})
endif()
if(OPENHMD_DRIVER_PSVR)
list(APPEND SRC
src/drv_psvr/psvr.c
src/drv_psvr/packet.c
)
add_definitions(-DDRIVER_PSVR)
find_package(HIDAPI REQUIRED)
list(APPEND INC_SYS ${HIDAPI_INCLUDE_DIRS})
endif()
if(OPENHMD_DRIVER_HTC_VIVE)
list(APPEND SRC
src/drv_htc_vive/vive.c
src/drv_htc_vive/packet.c
)
add_definitions(-DDRIVER_HTC_VIVE)
find_package(HIDAPI REQUIRED)
list(APPEND INC_SYS ${HIDAPI_INCLUDE_DIRS})
endif()
if(OPENHMD_DRIVER_EXTERNAL)
list(APPEND SRC
src/drv_external/external.c
)
add_definitions(-DDRIVER_EXTERNAL)
endif()
if(OPENHMD_DRIVER_ANDROID)
list(APPEND SRC
src/drv_android/android.c
)
add_definitions(-DDRIVER_ANDROID)
endif()
blender_add_lib(extern_openhmd "${SRC}" "${INC}" "${INC_SYS}")

23
extern/openhmd/LICENSE vendored Normal file
View File

@@ -0,0 +1,23 @@
Boost Software License - Version 1.0 - August 17th, 2003
Permission is hereby granted, free of charge, to any person or organization
obtaining a copy of the software and accompanying documentation covered by
this license (the "Software") to use, reproduce, display, distribute,
execute, and transmit the Software, and to prepare derivative works of the
Software, and to permit third-parties to whom the Software is furnished to
do so, all subject to the following:
The copyright notices in the Software and this entire statement, including
the above license grant, this restriction and the following disclaimer,
must be included in all copies of the Software, in whole or in part, and
all derivative works of the Software, unless such copies or derivative
works are solely in the form of machine-executable object code generated by
a source language processor.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT
SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE
FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE,
ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
DEALINGS IN THE SOFTWARE.

9
extern/openhmd/README.md vendored Normal file
View File

@@ -0,0 +1,9 @@
# OpenHMD
This project aims to provide a Free and Open Source API and drivers for immersive technology, such as head mounted displays with built in head tracking.
# License
OpenHMD is released under the permissive Boost Software License (see LICENSE for more information), to make sure it can be linked and distributed with both free and non-free software. While it doesn't require contribution from the users, it is still very appreciated.
# Implemented and maintained by TheOnlyJoey (Joey Ferwerda), contact info@thorwork.org if anything goes wrong

390
extern/openhmd/include/openhmd.h vendored Normal file
View File

@@ -0,0 +1,390 @@
/*
* OpenHMD - Free and Open Source API and drivers for immersive technology.
* Copyright (C) 2013 Fredrik Hultin.
* Copyright (C) 2013 Jakob Bornecrantz.
* Distributed under the Boost 1.0 licence, see LICENSE for full text.
*/
/**
* \file openhmd.h
* Main header for OpenHMD public API.
**/
#ifndef OPENHMD_H
#define OPENHMD_H
#ifdef __cplusplus
extern "C" {
#endif
#ifdef _WIN32
#ifdef DLL_EXPORT
#define OHMD_APIENTRY __cdecl
#define OHMD_APIENTRYDLL __declspec( dllexport )
#else
#ifdef OHMD_STATIC
#define OHMD_APIENTRY __cdecl
#define OHMD_APIENTRYDLL
#else
#define OHMD_APIENTRY __cdecl
#define OHMD_APIENTRYDLL __declspec( dllimport )
#endif
#endif
#else
#define OHMD_APIENTRY
#define OHMD_APIENTRYDLL
#endif
/** Maximum length of a string, including termination, in OpenHMD. */
#define OHMD_STR_SIZE 256
/** Return status codes, used for all functions that can return an error. */
typedef enum {
OHMD_S_OK = 0,
OHMD_S_UNKNOWN_ERROR = -1,
OHMD_S_INVALID_PARAMETER = -2,
OHMD_S_UNSUPPORTED = -3,
OHMD_S_INVALID_OPERATION = -4,
/** OHMD_S_USER_RESERVED and below can be used for user purposes, such as errors within ohmd wrappers, etc. */
OHMD_S_USER_RESERVED = -16384,
} ohmd_status;
/** A collection of string value information types, used for getting information with ohmd_list_gets(). */
typedef enum {
OHMD_VENDOR = 0,
OHMD_PRODUCT = 1,
OHMD_PATH = 2,
} ohmd_string_value;
/** A collection of string descriptions, used for getting strings with ohmd_gets(). */
typedef enum {
OHMD_GLSL_DISTORTION_VERT_SRC = 0,
OHMD_GLSL_DISTORTION_FRAG_SRC = 1,
} ohmd_string_description;
/** A collection of float value information types, used for getting and setting information with
ohmd_device_getf() and ohmd_device_setf(). */
typedef enum {
/** float[4] (get): Absolute rotation of the device, in space, as a quaternion (x, y, z, w). */
OHMD_ROTATION_QUAT = 1,
/** float[16] (get): A "ready to use" OpenGL style 4x4 matrix with a modelview matrix for the
left eye of the HMD. */
OHMD_LEFT_EYE_GL_MODELVIEW_MATRIX = 2,
/** float[16] (get): A "ready to use" OpenGL style 4x4 matrix with a modelview matrix for the
right eye of the HMD. */
OHMD_RIGHT_EYE_GL_MODELVIEW_MATRIX = 3,
/** float[16] (get): A "ready to use" OpenGL style 4x4 matrix with a projection matrix for the
left eye of the HMD. */
OHMD_LEFT_EYE_GL_PROJECTION_MATRIX = 4,
/** float[16] (get): A "ready to use" OpenGL style 4x4 matrix with a projection matrix for the
right eye of the HMD. */
OHMD_RIGHT_EYE_GL_PROJECTION_MATRIX = 5,
/** float[3] (get): A 3-D vector representing the absolute position of the device, in space. */
OHMD_POSITION_VECTOR = 6,
/** float[1] (get): Physical width of the device screen in metres. */
OHMD_SCREEN_HORIZONTAL_SIZE = 7,
/** float[1] (get): Physical height of the device screen in metres. */
OHMD_SCREEN_VERTICAL_SIZE = 8,
/** float[1] (get): Physical separation of the device lenses in metres. */
OHMD_LENS_HORIZONTAL_SEPARATION = 9,
/** float[1] (get): Physical vertical position of the lenses in metres. */
OHMD_LENS_VERTICAL_POSITION = 10,
/** float[1] (get): Physical field of view for the left eye in degrees. */
OHMD_LEFT_EYE_FOV = 11,
/** float[1] (get): Physical display aspect ratio for the left eye screen. */
OHMD_LEFT_EYE_ASPECT_RATIO = 12,
/** float[1] (get): Physical field of view for the left right in degrees. */
OHMD_RIGHT_EYE_FOV = 13,
/** float[1] (get): Physical display aspect ratio for the right eye screen. */
OHMD_RIGHT_EYE_ASPECT_RATIO = 14,
/** float[1] (get, set): Physical interpupillary distance of the user in metres. */
OHMD_EYE_IPD = 15,
/** float[1] (get, set): Z-far value for the projection matrix calculations (i.e. drawing distance). */
OHMD_PROJECTION_ZFAR = 16,
/** float[1] (get, set): Z-near value for the projection matrix calculations (i.e. close clipping distance). */
OHMD_PROJECTION_ZNEAR = 17,
/** float[6] (get): Device specific distortion value. */
OHMD_DISTORTION_K = 18,
/**
* float[10] (set): Perform sensor fusion on values from external sensors.
*
* Values are: dt (time since last update in seconds) X, Y, Z gyro, X, Y, Z accelerometer and X, Y, Z magnetometer.
**/
OHMD_EXTERNAL_SENSOR_FUSION = 19,
/** float[4] (get): Universal shader distortion coefficients (PanoTools model <a,b,c,d>. */
OHMD_UNIVERSAL_DISTORTION_K = 20,
/** float[3] (get): Universal shader aberration coefficients (post warp scaling <r,g,b>. */
OHMD_UNIVERSAL_ABERRATION_K = 21,
} ohmd_float_value;
/** A collection of int value information types used for getting information with ohmd_device_geti(). */
typedef enum {
/** int[1] (get): Physical horizontal resolution of the device screen. */
OHMD_SCREEN_HORIZONTAL_RESOLUTION = 0,
/** int[1] (get): Physical vertical resolution of the device screen. */
OHMD_SCREEN_VERTICAL_RESOLUTION = 1,
/** int[1] (get): Get number of events waiting in digital input event queue. */
OHMD_BUTTON_EVENT_COUNT = 2,
/** int[1] (get): Get if the there was an overflow in the event queue causing events to be dropped. */
OHMD_BUTTON_EVENT_OVERFLOW = 3,
/** int[1] (get): Get the number of physical digital input buttons on the device. */
OHMD_BUTTON_COUNT = 4,
/** int[2] (get): Performs an event pop action. Format: [button_index, button_state], where button_state is either OHMD_BUTTON_DOWN or OHMD_BUTTON_UP */
OHMD_BUTTON_POP_EVENT = 5,
} ohmd_int_value;
/** A collection of data information types used for setting information with ohmd_set_data(). */
typedef enum {
/** void* (set): Set void* data for use in the internal drivers. */
OHMD_DRIVER_DATA = 0,
/**
* ohmd_device_properties* (set):
* Set the device properties based on the ohmd_device_properties struct for use in the internal drivers.
*
* This can be used to fill in information about the device internally, such as Android, or for setting profiles.
**/
OHMD_DRIVER_PROPERTIES = 1,
} ohmd_data_value;
typedef enum {
/** int[1] (set, default: 1): Set this to 0 to prevent OpenHMD from creating background threads to do automatic device ticking.
Call ohmd_update(); must be called frequently, at least 10 times per second, if the background threads are disabled. */
OHMD_IDS_AUTOMATIC_UPDATE = 0,
} ohmd_int_settings;
/** Button states for digital input events. */
typedef enum {
/** Button was pressed. */
OHMD_BUTTON_DOWN = 0,
/** Button was released. */
OHMD_BUTTON_UP = 1
} ohmd_button_state;
/** An opaque pointer to a context structure. */
typedef struct ohmd_context ohmd_context;
/** An opaque pointer to a structure representing a device, such as an HMD. */
typedef struct ohmd_device ohmd_device;
/** An opaque pointer to a structure representing arguments for a device. */
typedef struct ohmd_device_settings ohmd_device_settings;
/**
* Create an OpenHMD context.
*
* @return a pointer to an allocated ohmd_context on success or NULL if it fails.
**/
OHMD_APIENTRYDLL ohmd_context* OHMD_APIENTRY ohmd_ctx_create(void);
/**
* Destroy an OpenHMD context.
*
* ohmd_ctx_destroy de-initializes and de-allocates an OpenHMD context allocated with ohmd_ctx_create.
* All devices associated with the context are automatically closed.
*
* @param ctx The context to destroy.
**/
OHMD_APIENTRYDLL void OHMD_APIENTRY ohmd_ctx_destroy(ohmd_context* ctx);
/**
* Get the last error as a human readable string.
*
* If a function taking a context as an argument (ohmd_context "methods") returns non-successfully,
* a human readable error message describing what went wrong can be retrieved with this function.
*
* @param ctx The context to retrieve the error message from.
* @return a pointer to the error message.
**/
OHMD_APIENTRYDLL const char* OHMD_APIENTRY ohmd_ctx_get_error(ohmd_context* ctx);
/**
* Update a context.
*
* Update the values for the devices handled by a context.
*
* If background threads are disabled, this performs tasks like pumping events from the device. The exact details
* are up to the driver but try to call it quite frequently.
* Once per frame in a "game loop" should be sufficient.
* If OpenHMD is handled in a background thread in your program, calling ohmd_ctx_update and then sleeping for 10-20 ms
* is recommended.
*
* @param ctx The context that needs updating.
**/
OHMD_APIENTRYDLL void OHMD_APIENTRY ohmd_ctx_update(ohmd_context* ctx);
/**
* Probe for devices.
*
* Probes for and enumerates supported devices attached to the system.
*
* @param ctx A context with no currently open devices.
* @return the number of devices found on the system.
**/
OHMD_APIENTRYDLL int OHMD_APIENTRY ohmd_ctx_probe(ohmd_context* ctx);
/**
* Get string from openhmd.
*
* Gets a string from OpenHMD. This is where non-device specific strings reside.
* This is where the distortion shader sources can be retrieved.
*
* @param type The name of the string to fetch. One of OHMD_GLSL_DISTORTION_FRAG_SRC, and OHMD_GLSL_DISTORTION_FRAG_SRC.
* @return a string with a human readable device name.
**/
OHMD_APIENTRYDLL const char* OHMD_APIENTRY ohmd_gets(ohmd_string_description type);
/**
* Get device description from enumeration list index.
*
* Gets a human readable device description string from a zero indexed enumeration index
* between 0 and (max - 1), where max is the number ohmd_ctx_probe returned
* (i.e. if ohmd_ctx_probe returns 3, valid indices are 0, 1 and 2).
* The function can return three types of data. The vendor name, the product name and
* a driver specific path where the device is attached.
*
* ohmd_ctx_probe must be called before calling ohmd_list_gets.
*
* @param ctx A (probed) context.
* @param index An index, between 0 and the value returned from ohmd_ctx_probe.
* @param type The type of data to fetch. One of OHMD_VENDOR, OHMD_PRODUCT and OHMD_PATH.
* @return a string with a human readable device name.
**/
OHMD_APIENTRYDLL const char* OHMD_APIENTRY ohmd_list_gets(ohmd_context* ctx, int index, ohmd_string_value type);
/**
* Open a device.
*
* Opens a device from a zero indexed enumeration index between 0 and (max - 1)
* where max is the number ohmd_ctx_probe returned (i.e. if ohmd_ctx_probe returns 3,
* valid indices are 0, 1 and 2).
*
* ohmd_ctx_probe must be called before calling ohmd_list_open_device.
*
* @param ctx A (probed) context.
* @param index An index, between 0 and the value returned from ohmd_ctx_probe.
* @return a pointer to an ohmd_device, which represents a hardware device, such as an HMD.
**/
OHMD_APIENTRYDLL ohmd_device* OHMD_APIENTRY ohmd_list_open_device(ohmd_context* ctx, int index);
/**
* Open a device with additional settings provided.
*
* Opens a device from a zero indexed enumeration index between 0 and (max - 1)
* where max is the number ohmd_ctx_probe returned (i.e. if ohmd_ctx_probe returns 3,
* valid indices are 0, 1 and 2).
*
* ohmd_ctx_probe must be called before calling ohmd_list_open_device.
*
* @param ctx A (probed) context.
* @param index An index, between 0 and the value returned from ohmd_ctx_probe.
* @param settings A pointer to a device settings struct.
* @return a pointer to an ohmd_device, which represents a hardware device, such as an HMD.
**/
OHMD_APIENTRYDLL ohmd_device* OHMD_APIENTRY ohmd_list_open_device_s(ohmd_context* ctx, int index, ohmd_device_settings* settings);
/**
* Specify int settings in a device settings struct.
*
* @param settings The device settings struct to set values to.
* @param key The specefic setting you wish to set.
* @param value A pointer to an int or int array (containing the expected number of elements) with the value(s) you wish to set.
**/
OHMD_APIENTRYDLL ohmd_status OHMD_APIENTRY ohmd_device_settings_seti(ohmd_device_settings* settings, ohmd_int_settings key, const int* val);
/**
* Create a device settings instance.
*
* @param ctx A pointer to a valid ohmd_context.
* @return a pointer to an allocated ohmd_context on success or NULL if it fails.
**/
OHMD_APIENTRYDLL ohmd_device_settings* OHMD_APIENTRY ohmd_device_settings_create(ohmd_context* ctx);
/**
* Destroy a device settings instance.
*
* @param ctx The device settings instance to destroy.
**/
OHMD_APIENTRYDLL void OHMD_APIENTRY ohmd_device_settings_destroy(ohmd_device_settings* settings);
/**
* Close a device.
*
* Closes a device opened by ohmd_list_open_device. Note that ohmd_ctx_destroy automatically closes any open devices
* associated with the context being destroyed.
*
* @param device The open device.
* @return 0 on success, <0 on failure.
**/
OHMD_APIENTRYDLL int OHMD_APIENTRY ohmd_close_device(ohmd_device* device);
/**
* Get a floating point value from a device.
*
*
* @param device An open device to retrieve the value from.
* @param type What type of value to retrieve, see ohmd_float_value section for more information.
* @param[out] out A pointer to a float, or float array where the retrieved value should be written.
* @return 0 on success, <0 on failure.
**/
OHMD_APIENTRYDLL int OHMD_APIENTRY ohmd_device_getf(ohmd_device* device, ohmd_float_value type, float* out);
/**
* Set a floating point value for a device.
*
* @param device An open device to set the value in.
* @param type What type of value to set, see ohmd_float_value section for more information.
* @param in A pointer to a float, or float array where the new value is stored.
* @return 0 on success, <0 on failure.
**/
OHMD_APIENTRYDLL int OHMD_APIENTRY ohmd_device_setf(ohmd_device* device, ohmd_float_value type, const float* in);
/**
* Get an integer value from a device.
*
* @param device An open device to retrieve the value from.
* @param type What type of value to retrieve, ohmd_int_value section for more information.
* @param[out] out A pointer to an integer, or integer array where the retrieved value should be written.
* @return 0 on success, <0 on failure.
**/
OHMD_APIENTRYDLL int OHMD_APIENTRY ohmd_device_geti(ohmd_device* device, ohmd_int_value type, int* out);
/**
* Set an integer value for a device.
*
* @param device An open device to set the value in.
* @param type What type of value to set, see ohmd_float_value section for more information.
* @param in A pointer to a int, or int array where the new value is stored.
* @return 0 on success, <0 on failure.
**/
OHMD_APIENTRYDLL int OHMD_APIENTRY ohmd_device_seti(ohmd_device* device, ohmd_int_value type, const int* in);
/**
* Set an void* data value for a device.
*
* @param device An open device to set the value in.
* @param type What type of value to set, see ohmd_float_value section for more information.
* @param in A pointer to the void* casted object.
* @return 0 on success, <0 on failure.
**/
OHMD_APIENTRYDLL int OHMD_APIENTRY ohmd_device_set_data(ohmd_device* device, ohmd_data_value type, const void* in);
#ifdef __cplusplus
}
#endif
#endif

335
extern/openhmd/src/drv_android/android.c vendored Normal file
View File

@@ -0,0 +1,335 @@
/*
* OpenHMD - Free and Open Source API and drivers for immersive technology.
* Copyright (C) 2013 Fredrik Hultin.
* Copyright (C) 2013 Jakob Bornecrantz.
* Copyright (C) 2015 Joey Ferwerda
* Distributed under the Boost 1.0 licence, see LICENSE for full text.
*/
/* Android Driver */
#include "android.h"
#ifdef __ANDROID__
#include <android/sensor.h>
#endif // __ANDROID__
typedef struct {
ohmd_device base;
fusion sensor_fusion;
//Android specific
#ifdef __ANDROID__
android_app* state;
ASensorManager* sensorManager;
const ASensor* accelerometerSensor;
const ASensor* gyroscopeSensor;
ASensorEventQueue* sensorEventQueue;
AAssetManager* assetMgr;
short firstRun;
#endif
} android_priv;
//Forward decelerations
static void set_android_properties(ohmd_device* device, ohmd_device_properties* props);
static void nofusion_init(fusion* me);
static void nofusion_update(fusion* me, float dt, const vec3f* accel);
//Static variable for timeDelta;
static float timestamp;
//Android callback for the sensor event queue
static int android_sensor_callback(int fd, int events, void* data)
{
android_priv* priv = (android_priv*)data;
if (priv->accelerometerSensor != NULL)
{
ASensorEvent event;
vec3f gyro;
vec3f accel;
vec3f mag;
float lastevent_timestamp;
while (ASensorEventQueue_getEvents(priv->sensorEventQueue, &event, 1) > 0)
{
if (event.type == ASENSOR_TYPE_ACCELEROMETER)
{
accel.x = event.acceleration.y;
accel.y = -event.acceleration.x;
accel.z = event.acceleration.z;
}
if (event.type == ASENSOR_TYPE_GYROSCOPE)
{
gyro.x = -event.data[1];
gyro.y = event.data[0];
gyro.z = event.data[2];
}
///TODO: Implement mag when available
mag.x = 0.0f;
mag.y = 0.0f;
mag.z = 0.0f;
lastevent_timestamp = event.timestamp;
}
//apply data to the fusion
float dT = 0.0f;
if (timestamp != 0)
dT= (lastevent_timestamp - timestamp) * (1.0f / 1000000000.0f);
//Check if accelerometer only fallback is required
if (!priv->gyroscopeSensor)
nofusion_update(&priv->sensor_fusion, dT, &accel);
else
ofusion_update(&priv->sensor_fusion, dT, &gyro, &accel, &mag); //default
timestamp = lastevent_timestamp;
}
return 1;
}
static void update_device(ohmd_device* device)
{
android_priv* priv = (android_priv*)device;
if(!priv->state)
return;
//We need this since during init the android_app state is not set yet
if (priv->firstRun == 1)
{
priv->sensorEventQueue = ASensorManager_createEventQueue(priv->sensorManager,
priv->state->looper, LOOPER_ID_USER, android_sensor_callback, (void*)priv);
// Start sensors in case this was not done already.
if (priv->accelerometerSensor != NULL)
{
ASensorEventQueue_enableSensor(priv->sensorEventQueue, priv->accelerometerSensor);
// We'd like to get 60 events per second (in us).
ASensorEventQueue_setEventRate(priv->sensorEventQueue, priv->accelerometerSensor, (1000L/60)*1000);
}
if (priv->gyroscopeSensor != NULL)
{
ASensorEventQueue_enableSensor(priv->sensorEventQueue, priv->gyroscopeSensor);
// We'd like to get 60 events per second (in us).
ASensorEventQueue_setEventRate(priv->sensorEventQueue, priv->gyroscopeSensor, (1000L/60)*1000);
}
priv->firstRun = 0;
}
}
static int getf(ohmd_device* device, ohmd_float_value type, float* out)
{
android_priv* priv = (android_priv*)device;
switch(type){
case OHMD_ROTATION_QUAT: {
*(quatf*)out = priv->sensor_fusion.orient;
break;
}
case OHMD_POSITION_VECTOR:
out[0] = out[1] = out[2] = 0;
break;
case OHMD_DISTORTION_K:
// TODO this should be set to the equivalent of no distortion
memset(out, 0, sizeof(float) * 6);
break;
default:
ohmd_set_error(priv->base.ctx, "invalid type given to getf (%d)", type);
return -1;
break;
}
return 0;
}
static int set_data(ohmd_device* device, ohmd_data_value type, void* in)
{
android_priv* priv = (android_priv*)device;
switch(type){
case OHMD_DRIVER_DATA: {
priv->state = (android_app*)in;
break;
}
case OHMD_DRIVER_PROPERTIES: {
set_android_properties(device, (ohmd_device_properties*)in);
break;
}
default:
ohmd_set_error(priv->base.ctx, "invalid type given to set_data (%i)", type);
return -1;
break;
}
return 0;
}
static void close_device(ohmd_device* device)
{
LOGD("closing Android device");
free(device);
}
static ohmd_device* open_device(ohmd_driver* driver, ohmd_device_desc* desc)
{
android_priv* priv = ohmd_alloc(driver->ctx, sizeof(android_priv));
if(!priv)
return NULL;
// Set default device properties
ohmd_set_default_device_properties(&priv->base.properties);
// Set device properties
//TODO: Get information from android about device
//TODO: Use profile string to set default for a particular device (Durovis, VR One etc)
priv->base.properties.hsize = 0.149760f;
priv->base.properties.vsize = 0.093600f;
priv->base.properties.hres = 1280;
priv->base.properties.vres = 800;
priv->base.properties.lens_sep = 0.063500f;
priv->base.properties.lens_vpos = 0.046800f;
priv->base.properties.fov = DEG_TO_RAD(125.5144f);
priv->base.properties.ratio = (1280.0f / 800.0f) / 2.0f;
// calculate projection eye projection matrices from the device properties
ohmd_calc_default_proj_matrices(&priv->base.properties);
// set up device callbacks
priv->base.update = update_device;
priv->base.close = close_device;
priv->base.getf = getf;
priv->base.set_data = set_data;
//init Android sensors
priv->sensorManager = ASensorManager_getInstance();
priv->accelerometerSensor = ASensorManager_getDefaultSensor(priv->sensorManager,
ASENSOR_TYPE_ACCELEROMETER);
priv->gyroscopeSensor = ASensorManager_getDefaultSensor(priv->sensorManager,
ASENSOR_TYPE_GYROSCOPE);
priv->firstRun = 1; //need this since ASensorManager_createEventQueue requires a set android_app*
//Check if accelerometer only fallback is required
if (!priv->gyroscopeSensor)
nofusion_init(&priv->sensor_fusion);
else
ofusion_init(&priv->sensor_fusion); //Default when all sensors are available
return (ohmd_device*)priv;
}
static void get_device_list(ohmd_driver* driver, ohmd_device_list* list)
{
ohmd_device_desc* desc = &list->devices[list->num_devices++];
strcpy(desc->driver, "OpenHMD Generic Android Driver");
strcpy(desc->vendor, "OpenHMD");
strcpy(desc->product, "Android Device");
strcpy(desc->path, "(none)");
desc->driver_ptr = driver;
}
static void destroy_driver(ohmd_driver* drv)
{
LOGD("shutting down Android driver");
free(drv);
}
ohmd_driver* ohmd_create_android_drv(ohmd_context* ctx)
{
ohmd_driver* drv = ohmd_alloc(ctx, sizeof(ohmd_driver));
if(!drv)
return NULL;
drv->get_device_list = get_device_list;
drv->open_device = open_device;
drv->destroy = destroy_driver;
drv->ctx = ctx;
return drv;
}
/* Android specific functions */
static void nofusion_update(fusion* me, float dt, const vec3f* accel)
{
//avg raw accel data to smooth jitter, and normalise
ofq_add(&me->accel_fq, accel);
vec3f accel_mean;
ofq_get_mean(&me->accel_fq, &accel_mean);
vec3f acc_n = accel_mean;
ovec3f_normalize_me(&acc_n);
//reference vectors for axis-angle
vec3f xyzv[3] = {
{1,0,0},
{0,1,0},
{0,0,1}
};
quatf roll, pitch;
//pitch is rot around x, based on gravity in z and y axes
oquatf_init_axis(&pitch, xyzv+0, atan2f(-acc_n.z, -acc_n.y));
//roll is rot around z, based on gravity in x and y axes
//note we need to invert the values when the device is upside down (y < 0) for proper results
oquatf_init_axis(&roll, xyzv+2, acc_n.y < 0 ? atan2f(-acc_n.x, -acc_n.y) : atan2f(acc_n.x, acc_n.y));
quatf or = {0,0,0,1};
//order of applying is yaw-pitch-roll
//yaw is not possible using only accel
oquatf_mult_me(&or, &pitch);
oquatf_mult_me(&or, &roll);
me->orient = or;
}
//shorter buffers for frame smoothing
static void nofusion_init(fusion* me)
{
memset(me, 0, sizeof(fusion));
me->orient.w = 1.0f;
ofq_init(&me->mag_fq, 10);
ofq_init(&me->accel_fq, 10);
ofq_init(&me->ang_vel_fq, 10);
me->flags = FF_USE_GRAVITY;
me->grav_gain = 0.05f;
}
static void set_android_properties(ohmd_device* device, ohmd_device_properties* props)
{
android_priv* priv = (android_priv*)device;
priv->base.properties.hsize = props->hsize;
priv->base.properties.vsize = props->vsize;
priv->base.properties.hres = props->hres;
priv->base.properties.vres = props->vres;
priv->base.properties.lens_sep = props->lens_sep;
priv->base.properties.lens_vpos = props->lens_vpos;
priv->base.properties.fov = DEG_TO_RAD(props->fov);
priv->base.properties.ratio = props->ratio;
}
static void set_android_profile(ohmd_driver* driver, android_hmd_profile profile)
{
switch(profile){
case DROID_DUROVIS_OPEN_DIVE: break;
case DROID_DUROVIS_DIVE_5: break;
case DROID_DUROVIS_DIVE_7: break;
case DROID_CARL_ZEISS_VRONE: break;
case DROID_GOOGLE_CARDBOARD: break;
case DROID_NONE:
default: break;
}
}

View File

@@ -0,0 +1,91 @@
/*
* OpenHMD - Free and Open Source API and drivers for immersive technology.
* Copyright (C) 2013 Fredrik Hultin.
* Copyright (C) 2013 Jakob Bornecrantz.
* Copyright (C) 2015 Joey Ferwerda
* Distributed under the Boost 1.0 licence, see LICENSE for full text.
*/
/* Android Driver */
#ifndef ANDROID_H
#define ANDROID_H
#include "../openhmdi.h"
typedef enum {
DROID_DUROVIS_OPEN_DIVE = 1,
DROID_DUROVIS_DIVE_5 = 2,
DROID_DUROVIS_DIVE_7 = 3,
DROID_CARL_ZEISS_VRONE = 4,
DROID_GOOGLE_CARDBOARD = 5,
DROID_NONE = 0,
} android_hmd_profile;
//Android copy-paste from android_native_app_glue to be able to cast data to something useful
#include <poll.h>
#include <pthread.h>
#include <sched.h>
#include <android/configuration.h>
#include <android/looper.h>
#include <android/native_activity.h>
struct android_app;
struct android_poll_source {
int32_t id;
struct android_app* app;
void (*process)(struct android_app* app, struct android_poll_source* source);
};
typedef struct android_app {
void* userData;
void (*onAppCmd)(struct android_app* app, int32_t cmd);
int32_t (*onInputEvent)(struct android_app* app, AInputEvent* event);
ANativeActivity* activity;
AConfiguration* config;
void* savedState;
size_t savedStateSize;
ALooper* looper;
AInputQueue* inputQueue;
ANativeWindow* window;
ARect contentRect;
int activityState;
int destroyRequested;
pthread_mutex_t mutex;
pthread_cond_t cond;
int msgread;
int msgwrite;
pthread_t thread;
struct android_poll_source cmdPollSource;
struct android_poll_source inputPollSource;
int running;
int stateSaved;
int destroyed;
int redrawNeeded;
AInputQueue* pendingInputQueue;
ANativeWindow* pendingWindow;
ARect pendingContentRect;
} android_app;
enum {
LOOPER_ID_MAIN = 1,
LOOPER_ID_INPUT = 2,
LOOPER_ID_USER = 3
};
#endif // ANDROID_H

332
extern/openhmd/src/drv_deepoon/deepoon.c vendored Normal file
View File

@@ -0,0 +1,332 @@
/*
* OpenHMD - Free and Open Source API and drivers for immersive technology.
* Copyright (C) 2013 Fredrik Hultin.
* Copyright (C) 2013 Jakob Bornecrantz.
* Distributed under the Boost 1.0 licence, see LICENSE for full text.
*/
/* Deepoon Driver - HID/USB Driver Implementation */
#include <stdlib.h>
#include <hidapi.h>
#include <string.h>
#include <stdio.h>
#include <time.h>
#include <assert.h>
#include "deepoon.h"
#define TICK_LEN (1.0f / 1000000.0f) // 1000 Hz ticks
#define KEEP_ALIVE_VALUE (10 * 1000)
#define SETFLAG(_s, _flag, _val) (_s) = ((_s) & ~(_flag)) | ((_val) ? (_flag) : 0)
#define DEEPOON_ID 0x0483
#define DEEPOON_HMD 0x5750
typedef struct {
ohmd_device base;
hid_device* handle;
pkt_sensor_range sensor_range;
pkt_sensor_display_info display_info;
rift_coordinate_frame coordinate_frame, hw_coordinate_frame;
pkt_sensor_config sensor_config;
pkt_tracker_sensor sensor;
double last_keep_alive;
fusion sensor_fusion;
vec3f raw_mag, raw_accel, raw_gyro;
} rift_priv;
static rift_priv* rift_priv_get(ohmd_device* device)
{
return (rift_priv*)device;
}
static int get_feature_report(rift_priv* priv, rift_sensor_feature_cmd cmd, unsigned char* buf)
{
memset(buf, 0, FEATURE_BUFFER_SIZE);
buf[0] = (unsigned char)cmd;
return hid_get_feature_report(priv->handle, buf, FEATURE_BUFFER_SIZE);
}
static int send_feature_report(rift_priv* priv, const unsigned char *data, size_t length)
{
return hid_send_feature_report(priv->handle, data, length);
}
static void set_coordinate_frame(rift_priv* priv, rift_coordinate_frame coordframe)
{
priv->coordinate_frame = coordframe;
// set the RIFT_SCF_SENSOR_COORDINATES in the sensor config to match whether coordframe is hmd or sensor
SETFLAG(priv->sensor_config.flags, RIFT_SCF_SENSOR_COORDINATES, coordframe == RIFT_CF_SENSOR);
// encode send the new config to the Rift
unsigned char buf[FEATURE_BUFFER_SIZE];
int size = dp_encode_sensor_config(buf, &priv->sensor_config);
if(send_feature_report(priv, buf, size) == -1){
ohmd_set_error(priv->base.ctx, "send_feature_report failed in set_coordinate frame");
return;
}
// read the state again, set the hw_coordinate_frame to match what
// the hardware actually is set to just incase it doesn't stick.
size = get_feature_report(priv, RIFT_CMD_SENSOR_CONFIG, buf);
if(size <= 0){
LOGW("could not set coordinate frame");
priv->hw_coordinate_frame = RIFT_CF_HMD;
return;
}
priv->hw_coordinate_frame = (priv->sensor_config.flags & RIFT_SCF_SENSOR_COORDINATES) ? RIFT_CF_SENSOR : RIFT_CF_HMD;
if(priv->hw_coordinate_frame != coordframe) {
LOGW("coordinate frame didn't stick");
}
}
static void handle_tracker_sensor_msg(rift_priv* priv, unsigned char* buffer, int size)
{
uint32_t last_sample_tick = priv->sensor.tick;
if(!dp_decode_tracker_sensor_msg(&priv->sensor, buffer, size)){
LOGE("couldn't decode tracker sensor message");
}
pkt_tracker_sensor* s = &priv->sensor;
dp_dump_packet_tracker_sensor(s);
uint32_t tick_delta = 1000;
if(last_sample_tick > 0) //startup correction
tick_delta = s->tick - last_sample_tick;
float dt = tick_delta * TICK_LEN;
vec3f mag = {{0.0f, 0.0f, 0.0f}};
for(int i = 0; i < 1; i++){ //just use 1 sample since we don't have sample order for this frame
vec3f_from_dp_vec(s->samples[i].accel, &priv->raw_accel);
vec3f_from_dp_vec(s->samples[i].gyro, &priv->raw_gyro);
ofusion_update(&priv->sensor_fusion, dt, &priv->raw_gyro, &priv->raw_accel, &mag);
// reset dt to tick_len for the last samples if there were more than one sample
dt = TICK_LEN;
}
}
static void update_device(ohmd_device* device)
{
rift_priv* priv = rift_priv_get(device);
unsigned char buffer[FEATURE_BUFFER_SIZE];
// Handle keep alive messages
double t = ohmd_get_tick();
if(t - priv->last_keep_alive >= (double)priv->sensor_config.keep_alive_interval / 1000.0 - .2){
// send keep alive message
pkt_keep_alive keep_alive = { 0, priv->sensor_config.keep_alive_interval };
int ka_size = dp_encode_keep_alive(buffer, &keep_alive);
send_feature_report(priv, buffer, ka_size);
// Update the time of the last keep alive we have sent.
priv->last_keep_alive = t;
}
// Read all the messages from the device.
while(true){
int size = hid_read(priv->handle, buffer, FEATURE_BUFFER_SIZE);
if(size < 0){
LOGE("error reading from device");
return;
} else if(size == 0) {
return; // No more messages, return.
}
// currently the only message type the hardware supports (I think)
if(buffer[0] == RIFT_IRQ_SENSORS || buffer[0] == 11){
handle_tracker_sensor_msg(priv, buffer, size);
}else{
LOGE("unknown message type: %u", buffer[0]);
}
}
}
static int getf(ohmd_device* device, ohmd_float_value type, float* out)
{
rift_priv* priv = rift_priv_get(device);
switch(type){
case OHMD_DISTORTION_K: {
for (int i = 0; i < 6; i++) {
out[i] = priv->display_info.distortion_k[i];
}
break;
}
case OHMD_ROTATION_QUAT: {
*(quatf*)out = priv->sensor_fusion.orient;
break;
}
case OHMD_POSITION_VECTOR:
out[0] = out[1] = out[2] = 0;
break;
default:
ohmd_set_error(priv->base.ctx, "invalid type given to getf (%ud)", type);
return -1;
break;
}
return 0;
}
static void close_device(ohmd_device* device)
{
LOGD("closing device");
rift_priv* priv = rift_priv_get(device);
hid_close(priv->handle);
free(priv);
}
static char* _hid_to_unix_path(char* path)
{
char bus [4];
char dev [4];
char *result = malloc( sizeof(char) * ( 20 + 1 ) );
sprintf (bus, "%.*s\n", 4, path);
sprintf (dev, "%.*s\n", 4, path + 5);
sprintf (result, "/dev/bus/usb/%03d/%03d",
(int)strtol(bus, NULL, 16),
(int)strtol(dev, NULL, 16));
return result;
}
static ohmd_device* open_device(ohmd_driver* driver, ohmd_device_desc* desc)
{
rift_priv* priv = ohmd_alloc(driver->ctx, sizeof(rift_priv));
if(!priv)
goto cleanup;
priv->base.ctx = driver->ctx;
// Open the HID device
priv->handle = hid_open_path(desc->path);
if(!priv->handle) {
char* path = _hid_to_unix_path(desc->path);
ohmd_set_error(driver->ctx, "Could not open %s. "
"Check your rights.", path);
free(path);
goto cleanup;
}
if(hid_set_nonblocking(priv->handle, 1) == -1){
ohmd_set_error(driver->ctx, "failed to set non-blocking on device");
goto cleanup;
}
unsigned char buf[FEATURE_BUFFER_SIZE];
int size;
// if the sensor has display info data, use HMD coordinate frame
priv->coordinate_frame = priv->display_info.distortion_type != RIFT_DT_NONE ? RIFT_CF_HMD : RIFT_CF_SENSOR;
// enable calibration
SETFLAG(priv->sensor_config.flags, RIFT_SCF_USE_CALIBRATION, 1);
SETFLAG(priv->sensor_config.flags, RIFT_SCF_AUTO_CALIBRATION, 1);
// apply sensor config
set_coordinate_frame(priv, priv->coordinate_frame);
// set keep alive interval to n seconds
pkt_keep_alive keep_alive = { 0, KEEP_ALIVE_VALUE };
size = dp_encode_keep_alive(buf, &keep_alive);
send_feature_report(priv, buf, size);
// Update the time of the last keep alive we have sent.
priv->last_keep_alive = ohmd_get_tick();
// Set default device properties
ohmd_set_default_device_properties(&priv->base.properties);
// Set device properties
//NOTE: These values are estimations, no one has taken one appart to check
priv->base.properties.hsize = 0.1698f;
priv->base.properties.vsize = 0.0936f;
priv->base.properties.hres = 1920;
priv->base.properties.vres = 1080;
priv->base.properties.lens_sep = 0.0849f;
priv->base.properties.lens_vpos = 0.0468f;;
priv->base.properties.fov = DEG_TO_RAD(110.0); // TODO calculate.
priv->base.properties.ratio = ((float)1920 / (float)1080) / 2.0f;
// calculate projection eye projection matrices from the device properties
ohmd_calc_default_proj_matrices(&priv->base.properties);
// set up device callbacks
priv->base.update = update_device;
priv->base.close = close_device;
priv->base.getf = getf;
// initialize sensor fusion
ofusion_init(&priv->sensor_fusion);
return &priv->base;
cleanup:
if(priv)
free(priv);
return NULL;
}
static void get_device_list(ohmd_driver* driver, ohmd_device_list* list)
{
struct hid_device_info* devs = hid_enumerate(DEEPOON_ID, DEEPOON_HMD);
struct hid_device_info* cur_dev = devs;
while (cur_dev) {
ohmd_device_desc* desc = &list->devices[list->num_devices++];
strcpy(desc->driver, "Deepoon Driver");
strcpy(desc->vendor, "Deepoon");
strcpy(desc->product, "Deepoon E2");
desc->revision = 0;
strcpy(desc->path, cur_dev->path);
desc->driver_ptr = driver;
cur_dev = cur_dev->next;
}
hid_free_enumeration(devs);
}
static void destroy_driver(ohmd_driver* drv)
{
LOGD("shutting down driver");
hid_exit();
free(drv);
}
ohmd_driver* ohmd_create_deepoon_drv(ohmd_context* ctx)
{
ohmd_driver* drv = ohmd_alloc(ctx, sizeof(ohmd_driver));
if(drv == NULL)
return NULL;
drv->get_device_list = get_device_list;
drv->open_device = open_device;
drv->ctx = ctx;
drv->get_device_list = get_device_list;
drv->open_device = open_device;
drv->destroy = destroy_driver;
return drv;
}

111
extern/openhmd/src/drv_deepoon/deepoon.h vendored Normal file
View File

@@ -0,0 +1,111 @@
/*
* OpenHMD - Free and Open Source API and drivers for immersive technology.
* Copyright (C) 2013 Fredrik Hultin.
* Copyright (C) 2013 Jakob Bornecrantz.
* Distributed under the Boost 1.0 licence, see LICENSE for full text.
*/
/* Deepoon Driver Internal Interface */
#ifndef DEEPOON_H
#define DEEPOON_H
#include "../openhmdi.h"
#define FEATURE_BUFFER_SIZE 256
typedef enum {
RIFT_CMD_SENSOR_CONFIG = 2,
RIFT_CMD_RANGE = 4,
RIFT_CMD_KEEP_ALIVE = 8,
RIFT_CMD_DISPLAY_INFO = 9
} rift_sensor_feature_cmd;
typedef enum {
RIFT_CF_SENSOR,
RIFT_CF_HMD
} rift_coordinate_frame;
typedef enum {
RIFT_IRQ_SENSORS = 1
} rift_irq_cmd;
typedef enum {
RIFT_DT_NONE,
RIFT_DT_SCREEN_ONLY,
RIFT_DT_DISTORTION
} rift_distortion_type;
// Sensor config flags
#define RIFT_SCF_RAW_MODE 0x01
#define RIFT_SCF_CALIBRATION_TEST 0x02
#define RIFT_SCF_USE_CALIBRATION 0x04
#define RIFT_SCF_AUTO_CALIBRATION 0x08
#define RIFT_SCF_MOTION_KEEP_ALIVE 0x10
#define RIFT_SCF_COMMAND_KEEP_ALIVE 0x20
#define RIFT_SCF_SENSOR_COORDINATES 0x40
typedef struct {
uint16_t command_id;
uint16_t accel_scale;
uint16_t gyro_scale;
uint16_t mag_scale;
} pkt_sensor_range;
typedef struct {
int32_t accel[3];
int32_t gyro[3];
} pkt_tracker_sample;
typedef struct {
uint8_t report_id;
uint8_t sample_delta;
uint16_t sample_number;
uint32_t tick;
pkt_tracker_sample samples[2];
int16_t mag[3];
} pkt_tracker_sensor;
typedef struct {
uint16_t command_id;
uint8_t flags;
uint16_t packet_interval;
uint16_t keep_alive_interval; // in ms
} pkt_sensor_config;
typedef struct {
uint16_t command_id;
rift_distortion_type distortion_type;
uint8_t distortion_type_opts;
uint16_t h_resolution, v_resolution;
float h_screen_size, v_screen_size;
float v_center;
float lens_separation;
float eye_to_screen_distance[2];
float distortion_k[6];
} pkt_sensor_display_info;
typedef struct {
uint16_t command_id;
uint16_t keep_alive_interval;
} pkt_keep_alive;
bool dp_decode_sensor_range(pkt_sensor_range* range, const unsigned char* buffer, int size);
bool dp_decode_sensor_display_info(pkt_sensor_display_info* info, const unsigned char* buffer, int size);
bool dp_decode_sensor_config(pkt_sensor_config* config, const unsigned char* buffer, int size);
bool dp_decode_tracker_sensor_msg(pkt_tracker_sensor* msg, const unsigned char* buffer, int size);
void vec3f_from_dp_vec(const int32_t* smp, vec3f* out_vec);
int dp_encode_sensor_config(unsigned char* buffer, const pkt_sensor_config* config);
int dp_encode_keep_alive(unsigned char* buffer, const pkt_keep_alive* keep_alive);
void dp_dump_packet_sensor_range(const pkt_sensor_range* range);
void dp_dump_packet_sensor_config(const pkt_sensor_config* config);
void dp_dump_packet_sensor_display_info(const pkt_sensor_display_info* info);
void dp_dump_packet_tracker_sensor(const pkt_tracker_sensor* sensor);
#endif

182
extern/openhmd/src/drv_deepoon/packet.c vendored Normal file
View File

@@ -0,0 +1,182 @@
/*
* OpenHMD - Free and Open Source API and drivers for immersive technology.
* Copyright (C) 2013 Fredrik Hultin.
* Copyright (C) 2013 Jakob Bornecrantz.
* Distributed under the Boost 1.0 licence, see LICENSE for full text.
*/
/* Deepoon Driver - Packet Decoding and Utilities */
#include <stdio.h>
#include "deepoon.h"
#define SKIP_CMD (buffer++)
#define READ8 *(buffer++);
#define READ16 *buffer | (*(buffer + 1) << 8); buffer += 2;
#define READ32 *buffer | (*(buffer + 1) << 8) | (*(buffer + 2) << 16) | (*(buffer + 3) << 24); buffer += 4;
#define READFLOAT ((float)(*buffer)); buffer += 4;
#define READFIXED (float)(*buffer | (*(buffer + 1) << 8) | (*(buffer + 2) << 16) | (*(buffer + 3) << 24)) / 1000000.0f; buffer += 4;
#define WRITE8(_val) *(buffer++) = (_val);
#define WRITE16(_val) WRITE8((_val) & 0xff); WRITE8(((_val) >> 8) & 0xff);
#define WRITE32(_val) WRITE16((_val) & 0xffff) *buffer; WRITE16(((_val) >> 16) & 0xffff);
bool dp_decodesensor_range(pkt_sensor_range* range, const unsigned char* buffer, int size)
{
if(!(size == 8 || size == 9)){
LOGE("invalid packet size (expected 8 or 9 but got %d)", size);
return false;
}
SKIP_CMD;
range->command_id = READ16;
range->accel_scale = READ8;
range->gyro_scale = READ16;
range->mag_scale = READ16;
return true;
}
bool dp_decodesensor_display_info(pkt_sensor_display_info* info, const unsigned char* buffer, int size)
{
if(!(size == 56 || size == 57)){
LOGE("invalid packet size (expected 56 or 57 but got %d)", size);
//return false;
}
SKIP_CMD;
info->command_id = READ16;
info->distortion_type = READ8;
info->h_resolution = READ16;
info->v_resolution = READ16;
info->h_screen_size = READFIXED;
info->v_screen_size = READFIXED;
info->v_center = READFIXED;
info->lens_separation = READFIXED;
info->eye_to_screen_distance[0] = READFIXED;
info->eye_to_screen_distance[1] = READFIXED;
info->distortion_type_opts = 0;
for(int i = 0; i < 6; i++){
info->distortion_k[i] = READFLOAT;
}
return true;
}
bool dp_decodesensor_config(pkt_sensor_config* config, const unsigned char* buffer, int size)
{
if(!(size == 7 || size == 8)){
LOGE("invalid packet size (expected 7 or 8 but got %d)", size);
return false;
}
SKIP_CMD;
config->command_id = READ16;
config->flags = READ8;
config->packet_interval = READ8;
config->keep_alive_interval = READ16;
return true;
}
static void dp_decodesample(const unsigned char* buffer, int32_t* smp)
{
/*
* Decode 3 tightly packed 21 bit values from 4 bytes.
* We unpack them in the higher 21 bit values first and then shift
* them down to the lower in order to get the sign bits correct.
*/
int x = (buffer[0] << 24) | (buffer[1] << 16) | ((buffer[2] & 0xF8) << 8);
int y = ((buffer[2] & 0x07) << 29) | (buffer[3] << 21) | (buffer[4] << 13) | ((buffer[5] & 0xC0) << 5);
int z = ((buffer[5] & 0x3F) << 26) | (buffer[6] << 18) | (buffer[7] << 10);
smp[0] = x >> 11;
smp[1] = y >> 11;
smp[2] = z >> 11;
}
bool dp_decode_tracker_sensor_msg(pkt_tracker_sensor* msg, const unsigned char* buffer, int size)
{
if(!(size == 62 || size == 64)){
LOGE("invalid packet size (expected 62 or 64 but got %d)", size);
return false;
}
msg->report_id = READ8;
buffer += 2;
msg->sample_delta = READ8;
msg->sample_number = READ16;
buffer += 2;
msg->tick = READ32;
for(int i = 0; i < 2; i++){
dp_decodesample(buffer, msg->samples[i].accel);
buffer += 8;
dp_decodesample(buffer, msg->samples[i].gyro);
buffer += 8;
}
return true;
}
// TODO do we need to consider HMD vs sensor "centric" values
void vec3f_from_dp_vec(const int32_t* smp, vec3f* out_vec)
{
out_vec->x = (float)smp[0] * 0.0001f;
out_vec->y = ((float)smp[2] * 0.0001f) * -1;
out_vec->z = (float)smp[1] * 0.0001f;
}
int dp_encode_sensor_config(unsigned char* buffer, const pkt_sensor_config* config)
{
WRITE8(RIFT_CMD_SENSOR_CONFIG);
WRITE16(config->command_id);
WRITE8(config->flags);
WRITE8(config->packet_interval);
WRITE16(config->keep_alive_interval);
return 7; // sensor config packet size
}
int dp_encode_keep_alive(unsigned char* buffer, const pkt_keep_alive* keep_alive)
{
WRITE8(RIFT_CMD_KEEP_ALIVE);
WRITE16(keep_alive->command_id);
WRITE16(keep_alive->keep_alive_interval);
return 5; // keep alive packet size
}
void dp_dump_packet_sensor_config(const pkt_sensor_config* config)
{
(void)config;
LOGD("sensor config");
LOGD(" command id: %u", config->command_id);
LOGD(" flags: %02x", config->flags);
LOGD(" raw mode: %d", !!(config->flags & RIFT_SCF_RAW_MODE));
LOGD(" calibration test: %d", !!(config->flags & RIFT_SCF_CALIBRATION_TEST));
LOGD(" use calibration: %d", !!(config->flags & RIFT_SCF_USE_CALIBRATION));
LOGD(" auto calibration: %d", !!(config->flags & RIFT_SCF_AUTO_CALIBRATION));
LOGD(" motion keep alive: %d", !!(config->flags & RIFT_SCF_MOTION_KEEP_ALIVE));
LOGD(" motion command keep alive: %d", !!(config->flags & RIFT_SCF_COMMAND_KEEP_ALIVE));
LOGD(" sensor coordinates: %d", !!(config->flags & RIFT_SCF_SENSOR_COORDINATES));
LOGD(" packet interval: %u", config->packet_interval);
LOGD(" keep alive interval: %u", config->keep_alive_interval);
}
void dp_dump_packet_tracker_sensor(const pkt_tracker_sensor* sensor)
{
(void)sensor;
LOGD("TEST: deepoon sensor data");
LOGD(" report id: %u", sensor->report_id);
LOGD(" sample delta: %u", sensor->sample_delta);
LOGD(" sample number: %d", sensor->sample_number);
LOGD(" tick: %u", sensor->tick);
for(int i = 0; i < 2; i++){
LOGD(" accel: %d %d %d", sensor->samples[i].accel[0], sensor->samples[i].accel[1], sensor->samples[i].accel[2]);
LOGD(" gyro: %d %d %d", sensor->samples[i].gyro[0], sensor->samples[i].gyro[1], sensor->samples[i].gyro[2]);
}
}

118
extern/openhmd/src/drv_dummy/dummy.c vendored Normal file
View File

@@ -0,0 +1,118 @@
/*
* OpenHMD - Free and Open Source API and drivers for immersive technology.
* Copyright (C) 2013 Fredrik Hultin.
* Copyright (C) 2013 Jakob Bornecrantz.
* Distributed under the Boost 1.0 licence, see LICENSE for full text.
*/
/* Dummy Driver */
#include <string.h>
#include "../openhmdi.h"
typedef struct {
ohmd_device base;
} dummy_priv;
static void update_device(ohmd_device* device)
{
}
static int getf(ohmd_device* device, ohmd_float_value type, float* out)
{
dummy_priv* priv = (dummy_priv*)device;
switch(type){
case OHMD_ROTATION_QUAT:
out[0] = out[1] = out[2] = 0;
out[3] = 1.0f;
break;
case OHMD_POSITION_VECTOR:
out[0] = out[1] = out[2] = 0;
break;
case OHMD_DISTORTION_K:
// TODO this should be set to the equivalent of no distortion
memset(out, 0, sizeof(float) * 6);
break;
default:
ohmd_set_error(priv->base.ctx, "invalid type given to getf (%ud)", type);
return -1;
break;
}
return 0;
}
static void close_device(ohmd_device* device)
{
LOGD("closing dummy device");
free(device);
}
static ohmd_device* open_device(ohmd_driver* driver, ohmd_device_desc* desc)
{
dummy_priv* priv = ohmd_alloc(driver->ctx, sizeof(dummy_priv));
if(!priv)
return NULL;
// Set default device properties
ohmd_set_default_device_properties(&priv->base.properties);
// Set device properties (imitates the rift values)
priv->base.properties.hsize = 0.149760f;
priv->base.properties.vsize = 0.093600f;
priv->base.properties.hres = 1280;
priv->base.properties.vres = 800;
priv->base.properties.lens_sep = 0.063500f;
priv->base.properties.lens_vpos = 0.046800f;
priv->base.properties.fov = DEG_TO_RAD(125.5144f);
priv->base.properties.ratio = (1280.0f / 800.0f) / 2.0f;
priv->base.properties.digital_button_count = 4;
// calculate projection eye projection matrices from the device properties
ohmd_calc_default_proj_matrices(&priv->base.properties);
// set up device callbacks
priv->base.update = update_device;
priv->base.close = close_device;
priv->base.getf = getf;
return (ohmd_device*)priv;
}
static void get_device_list(ohmd_driver* driver, ohmd_device_list* list)
{
ohmd_device_desc* desc = &list->devices[list->num_devices++];
strcpy(desc->driver, "OpenHMD Dummy Driver");
strcpy(desc->vendor, "OpenHMD");
strcpy(desc->product, "Dummy Device");
strcpy(desc->path, "(none)");
desc->driver_ptr = driver;
}
static void destroy_driver(ohmd_driver* drv)
{
LOGD("shutting down dummy driver");
free(drv);
}
ohmd_driver* ohmd_create_dummy_drv(ohmd_context* ctx)
{
ohmd_driver* drv = ohmd_alloc(ctx, sizeof(ohmd_driver));
if(!drv)
return NULL;
drv->get_device_list = get_device_list;
drv->open_device = open_device;
drv->get_device_list = get_device_list;
drv->open_device = open_device;
drv->destroy = destroy_driver;
return drv;
}

View File

@@ -0,0 +1,152 @@
/*
* OpenHMD - Free and Open Source API and drivers for immersive technology.
* Copyright (C) 2013 Fredrik Hultin.
* Copyright (C) 2013 Jakob Bornecrantz.
* Copyright (C) 2015 Joey Ferwerda
* Distributed under the Boost 1.0 licence, see LICENSE for full text.
*/
/* External Driver */
#include "../openhmdi.h"
#include "string.h"
typedef struct {
ohmd_device base;
fusion sensor_fusion;
} external_priv;
static void update_device(ohmd_device* device)
{
}
static int getf(ohmd_device* device, ohmd_float_value type, float* out)
{
external_priv* priv = (external_priv*)device;
switch(type){
case OHMD_ROTATION_QUAT: {
*(quatf*)out = priv->sensor_fusion.orient;
break;
}
case OHMD_POSITION_VECTOR:
out[0] = out[1] = out[2] = 0;
break;
default:
ohmd_set_error(priv->base.ctx, "invalid type given to getf (%d)", type);
return -1;
break;
}
return 0;
}
static int setf(ohmd_device* device, ohmd_float_value type, const float* in)
{
external_priv* priv = (external_priv*)device;
switch(type){
case OHMD_EXTERNAL_SENSOR_FUSION: {
ofusion_update(&priv->sensor_fusion, *in, (vec3f*)(in + 1), (vec3f*)(in + 4), (vec3f*)(in + 7));
}
break;
default:
ohmd_set_error(priv->base.ctx, "invalid type given to setf (%d)", type);
return -1;
break;
}
return 0;
}
static void close_device(ohmd_device* device)
{
LOGD("closing external device");
free(device);
}
static ohmd_device* open_device(ohmd_driver* driver, ohmd_device_desc* desc)
{
external_priv* priv = ohmd_alloc(driver->ctx, sizeof(external_priv));
if(!priv)
return NULL;
// Set default device properties
ohmd_set_default_device_properties(&priv->base.properties);
// Set device properties
//TODO: Get information from external device using set_external_properties?
//Using 'dummy' settings for now
priv->base.properties.hsize = 0.149760f;
priv->base.properties.vsize = 0.093600f;
priv->base.properties.hres = 1280;
priv->base.properties.vres = 800;
priv->base.properties.lens_sep = 0.063500f;
priv->base.properties.lens_vpos = 0.046800f;
priv->base.properties.fov = DEG_TO_RAD(125.5144f);
priv->base.properties.ratio = (1280.0f / 800.0f) / 2.0f;
// calculate projection eye projection matrices from the device properties
ohmd_calc_default_proj_matrices(&priv->base.properties);
// set up device callbacks
priv->base.update = update_device;
priv->base.close = close_device;
priv->base.getf = getf;
priv->base.setf = setf;
ofusion_init(&priv->sensor_fusion);
return (ohmd_device*)priv;
}
static void get_device_list(ohmd_driver* driver, ohmd_device_list* list)
{
ohmd_device_desc* desc = &list->devices[list->num_devices++];
strcpy(desc->driver, "OpenHMD Generic External Driver");
strcpy(desc->vendor, "OpenHMD");
strcpy(desc->product, "External Device");
strcpy(desc->path, "(none)");
desc->driver_ptr = driver;
}
static void destroy_driver(ohmd_driver* drv)
{
LOGD("shutting down external driver");
free(drv);
}
ohmd_driver* ohmd_create_external_drv(ohmd_context* ctx)
{
ohmd_driver* drv = ohmd_alloc(ctx, sizeof(ohmd_driver));
if(!drv)
return NULL;
drv->get_device_list = get_device_list;
drv->open_device = open_device;
drv->destroy = destroy_driver;
drv->ctx = ctx;
return drv;
}
/* external specific functions */
/*static void set_external_properties(ohmd_device* device, ohmd_device_properties* props)
{
external_priv* priv = (external_priv*)device;
priv->base.properties.hsize = props->hsize;
priv->base.properties.vsize = props->vsize;
priv->base.properties.hres = props->hres;
priv->base.properties.vres = props->vres;
priv->base.properties.lens_sep = props->lens_sep;
priv->base.properties.lens_vpos = props->lens_vpos;
priv->base.properties.fov = DEG_TO_RAD(props->fov);
priv->base.properties.ratio = props->ratio;
}*/

View File

@@ -0,0 +1 @@
//Reserved

27
extern/openhmd/src/drv_htc_vive/magic.h vendored Normal file
View File

@@ -0,0 +1,27 @@
static const unsigned char vive_magic_power_on[64] = {
0x04, 0x78, 0x29, 0x38, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x00, 0x01,
0xa8, 0x0d, 0x76, 0x00, 0x40, 0xfc, 0x01, 0x05, 0xfa, 0xec, 0xd1, 0x6d, 0x00,
0x00, 0x6c, 0x00, 0x00, 0x00, 0x00, 0x00, 0xa8, 0x0d, 0x76, 0x00, 0x68, 0xfc,
0x01, 0x05, 0x2c, 0xb0, 0x2e, 0x65, 0x7a, 0x0d, 0x76, 0x00, 0x68, 0x54, 0x72,
0x00, 0x18, 0x54, 0x72, 0x00, 0x00, 0x6a, 0x72, 0x00, 0x00, 0x00, 0x00,
};
static const unsigned char vive_magic_power_off1[64] = {
0x04, 0x78, 0x29, 0x38, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00,
0x30, 0x05, 0x77, 0x00, 0x30, 0x05, 0x77, 0x00, 0x6c, 0x4d, 0x37, 0x65, 0x40,
0xf9, 0x33, 0x00, 0x04, 0xf8, 0xa3, 0x04, 0x04, 0x00, 0x00, 0x00, 0x70, 0xb0,
0x72, 0x00, 0xf4, 0xf7, 0xa3, 0x04, 0x7c, 0xf8, 0x33, 0x00, 0x0c, 0xf8, 0xa3,
0x04, 0x0a, 0x6e, 0x29, 0x65, 0x24, 0xf9, 0x33, 0x00, 0x00, 0x00, 0x00,
};
static const unsigned char vive_magic_power_off2[64] = {
0x04, 0x78, 0x29, 0x38, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00,
0x30, 0x05, 0x77, 0x00, 0xe4, 0xf7, 0x33, 0x00, 0xe4, 0xf7, 0x33, 0x00, 0x60,
0x6e, 0x72, 0x00, 0xb4, 0xf7, 0x33, 0x00, 0x04, 0x00, 0x00, 0x00, 0x70, 0xb0,
0x72, 0x00, 0x90, 0xf7, 0x33, 0x00, 0x7c, 0xf8, 0x33, 0x00, 0xd0, 0xf7, 0x33,
0x00, 0x3c, 0x68, 0x29, 0x65, 0x24, 0xf9, 0x33, 0x00, 0x00, 0x00, 0x00,
};
static const unsigned char vive_magic_enable_lighthouse[5] = {
0x04
};

View File

@@ -0,0 +1,63 @@
#include "vive.h"
#include "config.h"
#ifdef _MSC_VER
#define inline __inline
#endif
inline static uint8_t read8(const unsigned char** buffer)
{
uint8_t ret = **buffer;
*buffer += 1;
return ret;
}
inline static int16_t read16(const unsigned char** buffer)
{
int16_t ret = **buffer | (*(*buffer + 1) << 8);
*buffer += 2;
return ret;
}
inline static uint32_t read32(const unsigned char** buffer)
{
uint32_t ret = **buffer | (*(*buffer + 1) << 8) | (*(*buffer + 2) << 16) | (*(*buffer + 3) << 24);
*buffer += 4;
return ret;
}
bool vive_decode_sensor_packet(vive_sensor_packet* pkt, const unsigned char* buffer, int size)
{
if(size != 52){
LOGE("invalid vive sensor packet size (expected 52 but got %d)", size);
return false;
}
pkt->report_id = read8(&buffer);
for(int j = 0; j < 3; j++){
// acceleration
for(int i = 0; i < 3; i++){
pkt->samples[j].acc[i] = read16(&buffer);
}
// rotation
for(int i = 0; i < 3; i++){
pkt->samples[j].rot[i] = read16(&buffer);
}
pkt->samples[j].time_ticks = read32(&buffer);
pkt->samples[j].seq = read8(&buffer);
}
return true;
}
//TODO: Implement config packet decoding.
bool vive_decode_config_packet(vive_config_packet* pkt, const unsigned char* buffer, int size)
{
if(size != 64){
LOGE("invalid vive sensor packet size (expected 64 but got %d)", size);
return false;
}
return false;
}

441
extern/openhmd/src/drv_htc_vive/vive.c vendored Normal file
View File

@@ -0,0 +1,441 @@
/*
* OpenHMD - Free and Open Source API and drivers for immersive technology.
* Copyright (C) 2013 Fredrik Hultin.
* Copyright (C) 2013 Jakob Bornecrantz.
* Distributed under the Boost 1.0 licence, see LICENSE for full text.
*/
/* HTC Vive Driver */
#define FEATURE_BUFFER_SIZE 256
#define HTC_ID 0x0bb4
#define VIVE_HMD 0x2c87
#define VALVE_ID 0x28de
#define VIVE_WATCHMAN_DONGLE 0x2101
#define VIVE_LIGHTHOUSE_FPGA_RX 0x2000
#define VIVE_TIME_DIV 48000000.0f
#include <string.h>
#include <wchar.h>
#include <hidapi.h>
#include <assert.h>
#include <limits.h>
#include <stdint.h>
#include <stdbool.h>
#include "vive.h"
typedef struct {
ohmd_device base;
hid_device* hmd_handle;
hid_device* imu_handle;
fusion sensor_fusion;
vec3f raw_accel, raw_gyro;
uint32_t last_ticks;
uint8_t last_seq;
vec3f gyro_error;
filter_queue gyro_q;
} vive_priv;
void vec3f_from_vive_vec_accel(const int16_t* smp, vec3f* out_vec)
{
float gravity = 9.81f;
float scaler = 4.0f * gravity / 32768.0f;
out_vec->x = (float)smp[0] * scaler;
out_vec->y = (float)smp[1] * scaler * -1;
out_vec->z = (float)smp[2] * scaler * -1;
}
void vec3f_from_vive_vec_gyro(const int16_t* smp, vec3f* out_vec)
{
float scaler = 8.7f / 32768.0f;
out_vec->x = (float)smp[0] * scaler;
out_vec->y = (float)smp[1] * scaler * -1;
out_vec->z = (float)smp[2] * scaler * -1;
}
static bool process_error(vive_priv* priv)
{
if(priv->gyro_q.at >= priv->gyro_q.size - 1)
return true;
ofq_add(&priv->gyro_q, &priv->raw_gyro);
if(priv->gyro_q.at >= priv->gyro_q.size - 1){
ofq_get_mean(&priv->gyro_q, &priv->gyro_error);
printf("gyro error: %f, %f, %f\n", priv->gyro_error.x, priv->gyro_error.y, priv->gyro_error.z);
}
return false;
}
vive_sensor_sample* get_next_sample(vive_sensor_packet* pkt, int last_seq)
{
int diff[3];
for(int i = 0; i < 3; i++)
{
diff[i] = (int)pkt->samples[i].seq - last_seq;
if(diff[i] < -128){
diff[i] += 256;
}
}
int closest_diff = INT_MAX;
int closest_idx = -1;
for(int i = 0; i < 3; i++)
{
if(diff[i] < closest_diff && diff[i] > 0 && diff[i] < 128){
closest_diff = diff[i];
closest_idx = i;
}
}
if(closest_idx != -1)
return pkt->samples + closest_idx;
return NULL;
}
static void update_device(ohmd_device* device)
{
vive_priv* priv = (vive_priv*)device;
int size = 0;
unsigned char buffer[FEATURE_BUFFER_SIZE];
while((size = hid_read(priv->imu_handle, buffer, FEATURE_BUFFER_SIZE)) > 0){
if(buffer[0] == VIVE_IRQ_SENSORS){
vive_sensor_packet pkt;
vive_decode_sensor_packet(&pkt, buffer, size);
vive_sensor_sample* smp = NULL;
while((smp = get_next_sample(&pkt, priv->last_seq)) != NULL)
{
if(priv->last_ticks == 0)
priv->last_ticks = smp->time_ticks;
uint32_t t1, t2;
t1 = smp->time_ticks;
t2 = priv->last_ticks;
float dt = (t1 - t2) / VIVE_TIME_DIV;
priv->last_ticks = smp->time_ticks;
vec3f_from_vive_vec_accel(smp->acc, &priv->raw_accel);
vec3f_from_vive_vec_gyro(smp->rot, &priv->raw_gyro);
if(process_error(priv)){
vec3f mag = {{0.0f, 0.0f, 0.0f}};
vec3f gyro;
ovec3f_subtract(&priv->raw_gyro, &priv->gyro_error, &gyro);
ofusion_update(&priv->sensor_fusion, dt, &gyro, &priv->raw_accel, &mag);
}
priv->last_seq = smp->seq;
}
}else{
LOGE("unknown message type: %u", buffer[0]);
}
}
if(size < 0){
LOGE("error reading from device");
}
}
static int getf(ohmd_device* device, ohmd_float_value type, float* out)
{
vive_priv* priv = (vive_priv*)device;
switch(type){
case OHMD_ROTATION_QUAT:
*(quatf*)out = priv->sensor_fusion.orient;
break;
case OHMD_POSITION_VECTOR:
out[0] = out[1] = out[2] = 0;
break;
case OHMD_DISTORTION_K:
// TODO this should be set to the equivalent of no distortion
memset(out, 0, sizeof(float) * 6);
break;
default:
ohmd_set_error(priv->base.ctx, "invalid type given to getf (%ud)", type);
return -1;
break;
}
return 0;
}
static void close_device(ohmd_device* device)
{
int hret = 0;
vive_priv* priv = (vive_priv*)device;
LOGD("closing HTC Vive device");
// turn the display off
hret = hid_send_feature_report(priv->hmd_handle, vive_magic_power_off1, sizeof(vive_magic_power_off1));
//printf("power off magic 1: %d\n", hret);
hret = hid_send_feature_report(priv->hmd_handle, vive_magic_power_off2, sizeof(vive_magic_power_off2));
//printf("power off magic 2: %d\n", hret);
hid_close(priv->hmd_handle);
hid_close(priv->imu_handle);
free(device);
}
#if 0
static void dump_indexed_string(hid_device* device, int index)
{
wchar_t wbuffer[512] = {0};
char buffer[1024] = {0};
int hret = hid_get_indexed_string(device, index, wbuffer, 511);
if(hret == 0){
wcstombs(buffer, wbuffer, sizeof(buffer));
printf("indexed string 0x%02x: '%s'\n", index, buffer);
}
}
#endif
static void dump_info_string(int (*fun)(hid_device*, wchar_t*, size_t), const char* what, hid_device* device)
{
wchar_t wbuffer[512] = {0};
char buffer[1024] = {0};
int hret = fun(device, wbuffer, 511);
if(hret == 0){
wcstombs(buffer, wbuffer, sizeof(buffer));
printf("%s: '%s'\n", what, buffer);
}
}
#if 0
static void dumpbin(const char* label, const unsigned char* data, int length)
{
printf("%s:\n", label);
for(int i = 0; i < length; i++){
printf("%02x ", data[i]);
if((i % 16) == 15)
printf("\n");
}
printf("\n");
}
#endif
static hid_device* open_device_idx(int manufacturer, int product, int iface, int iface_tot, int device_index)
{
struct hid_device_info* devs = hid_enumerate(manufacturer, product);
struct hid_device_info* cur_dev = devs;
int idx = 0;
int iface_cur = 0;
hid_device* ret = NULL;
while (cur_dev) {
printf("%04x:%04x %s\n", manufacturer, product, cur_dev->path);
if(idx == device_index && iface == iface_cur){
ret = hid_open_path(cur_dev->path);
printf("opening\n");
}
cur_dev = cur_dev->next;
iface_cur++;
if(iface_cur >= iface_tot){
idx++;
iface_cur = 0;
}
}
hid_free_enumeration(devs);
return ret;
}
static ohmd_device* open_device(ohmd_driver* driver, ohmd_device_desc* desc)
{
vive_priv* priv = ohmd_alloc(driver->ctx, sizeof(vive_priv));
if(!priv)
return NULL;
int hret = 0;
priv->base.ctx = driver->ctx;
int idx = atoi(desc->path);
// Open the HMD device
priv->hmd_handle = open_device_idx(HTC_ID, VIVE_HMD, 0, 1, idx);
if(!priv->hmd_handle)
goto cleanup;
if(hid_set_nonblocking(priv->hmd_handle, 1) == -1){
ohmd_set_error(driver->ctx, "failed to set non-blocking on device");
goto cleanup;
}
// Open the lighthouse device
priv->imu_handle = open_device_idx(VALVE_ID, VIVE_LIGHTHOUSE_FPGA_RX, 0, 2, idx);
if(!priv->imu_handle)
goto cleanup;
if(hid_set_nonblocking(priv->imu_handle, 1) == -1){
ohmd_set_error(driver->ctx, "failed to set non-blocking on device");
goto cleanup;
}
dump_info_string(hid_get_manufacturer_string, "manufacturer", priv->hmd_handle);
dump_info_string(hid_get_product_string , "product", priv->hmd_handle);
dump_info_string(hid_get_serial_number_string, "serial number", priv->hmd_handle);
// turn the display on
hret = hid_send_feature_report(priv->hmd_handle, vive_magic_power_on, sizeof(vive_magic_power_on));
printf("power on magic: %d\n", hret);
// enable lighthouse
//hret = hid_send_feature_report(priv->hmd_handle, vive_magic_enable_lighthouse, sizeof(vive_magic_enable_lighthouse));
//printf("enable lighthouse magic: %d\n", hret);
// Set default device properties
ohmd_set_default_device_properties(&priv->base.properties);
// Set device properties TODO: Get from device
priv->base.properties.hsize = 0.122822f;
priv->base.properties.vsize = 0.068234f;
priv->base.properties.hres = 2160;
priv->base.properties.vres = 1200;
/*
// calculated from here: https://www.gamedev.net/topic/683698-projection-matrix-model-of-the-htc-vive/
priv->base.properties.lens_sep = 0.057863;
priv->base.properties.lens_vpos = 0.033896;
*/
// estimated 'by eye' on jsarret's vive
priv->base.properties.lens_sep = 0.056;
priv->base.properties.lens_vpos = 0.032;
float eye_to_screen_distance = 0.023226876441867737;
//priv->base.properties.fov = DEG_TO_RAD(111.435f); //TODO: Confirm exact mesurements
priv->base.properties.ratio = (2160.0f / 1200.0f) / 2.0f;
/*
ohmd_set_universal_distortion_k(&(priv->base.properties), 0.394119, -0.508383, 0.323322, 0.790942);
*/
ohmd_set_universal_distortion_k(&(priv->base.properties), 1.318397, -1.490242, 0.663824, 0.508021);
ohmd_set_universal_aberration_k(&(priv->base.properties), 1.00010147892f, 1.000f, 1.00019614479f);
// calculate projection eye projection matrices from the device properties
//ohmd_calc_default_proj_matrices(&priv->base.properties);
float l,r,t,b,n,f;
// left eye screen bounds
l = -1.0f * (priv->base.properties.hsize/2 - priv->base.properties.lens_sep/2);
r = priv->base.properties.lens_sep/2;
t = priv->base.properties.vsize - priv->base.properties.lens_vpos;
b = -1.0f * priv->base.properties.lens_vpos;
n = eye_to_screen_distance;
f = n*10e6;
//LOGD("l: %0.3f, r: %0.3f, b: %0.3f, t: %0.3f, n: %0.3f, f: %0.3f", l,r,b,t,n,f);
/* eye separation is handled by IPD in the Modelview matrix */
omat4x4f_init_frustum(&priv->base.properties.proj_left, l, r, b, t, n, f);
//right eye screen bounds
l = -1.0f * priv->base.properties.lens_sep/2;
r = priv->base.properties.hsize/2 - priv->base.properties.lens_sep/2;
n = eye_to_screen_distance;
f = n*10e6;
//LOGD("l: %0.3f, r: %0.3f, b: %0.3f, t: %0.3f, n: %0.3f, f: %0.3f", l,r,b,t,n,f);
/* eye separation is handled by IPD in the Modelview matrix */
omat4x4f_init_frustum(&priv->base.properties.proj_right, l, r, b, t, n, f);
priv->base.properties.fov = 2 * atan2f(
priv->base.properties.hsize/2 - priv->base.properties.lens_sep/2,
eye_to_screen_distance);
// set up device callbacks
priv->base.update = update_device;
priv->base.close = close_device;
priv->base.getf = getf;
ofusion_init(&priv->sensor_fusion);
ofq_init(&priv->gyro_q, 128);
return (ohmd_device*)priv;
cleanup:
if(priv)
free(priv);
return NULL;
}
static void get_device_list(ohmd_driver* driver, ohmd_device_list* list)
{
struct hid_device_info* devs = hid_enumerate(HTC_ID, VIVE_HMD);
struct hid_device_info* cur_dev = devs;
int idx = 0;
while (cur_dev) {
ohmd_device_desc* desc = &list->devices[list->num_devices++];
strcpy(desc->driver, "OpenHMD HTC Vive Driver");
strcpy(desc->vendor, "HTC/Valve");
strcpy(desc->product, "HTC Vive");
desc->revision = 0;
snprintf(desc->path, OHMD_STR_SIZE, "%d", idx);
desc->driver_ptr = driver;
cur_dev = cur_dev->next;
idx++;
}
hid_free_enumeration(devs);
}
static void destroy_driver(ohmd_driver* drv)
{
LOGD("shutting down HTC Vive driver");
free(drv);
}
ohmd_driver* ohmd_create_htc_vive_drv(ohmd_context* ctx)
{
ohmd_driver* drv = ohmd_alloc(ctx, sizeof(ohmd_driver));
if(!drv)
return NULL;
drv->get_device_list = get_device_list;
drv->open_device = open_device;
drv->destroy = destroy_driver;
drv->ctx = ctx;
return drv;
}

41
extern/openhmd/src/drv_htc_vive/vive.h vendored Normal file
View File

@@ -0,0 +1,41 @@
#ifndef VIVE_H
#define VIVE_H
#include <stdint.h>
#include <stdbool.h>
#include "../openhmdi.h"
#include "magic.h"
typedef enum
{
VIVE_CONFIG_DATA = 17,
VIVE_IRQ_SENSORS = 32,
} vive_irq_cmd;
typedef struct
{
int16_t acc[3];
int16_t rot[3];
uint32_t time_ticks;
uint8_t seq;
} vive_sensor_sample;
typedef struct
{
uint8_t report_id;
vive_sensor_sample samples[3];
} vive_sensor_packet;
typedef struct
{
uint8_t report_id;
uint16_t length;
unsigned char config_data[99999];
} vive_config_packet;
void vec3f_from_vive_vec(const int16_t* smp, vec3f* out_vec);
bool vive_decode_sensor_packet(vive_sensor_packet* pkt, const unsigned char* buffer, int size);
bool vive_decode_config_packet(vive_config_packet* pkt, const unsigned char* buffer, int size);
#endif

View File

@@ -0,0 +1,275 @@
/*
* OpenHMD - Free and Open Source API and drivers for immersive technology.
* Copyright (C) 2013 Fredrik Hultin.
* Copyright (C) 2013 Jakob Bornecrantz.
* Distributed under the Boost 1.0 licence, see LICENSE for full text.
*/
/* Oculus Rift Driver - Packet Decoding and Utilities */
#include <stdio.h>
#include "rift.h"
#define SKIP_CMD (buffer++)
#define READ8 *(buffer++);
#define READ16 *buffer | (*(buffer + 1) << 8); buffer += 2;
#define READ32 *buffer | (*(buffer + 1) << 8) | (*(buffer + 2) << 16) | (*(buffer + 3) << 24); buffer += 4;
#define READFLOAT ((float)(*buffer)); buffer += 4;
#define READFIXED (float)(*buffer | (*(buffer + 1) << 8) | (*(buffer + 2) << 16) | (*(buffer + 3) << 24)) / 1000000.0f; buffer += 4;
#define WRITE8(_val) *(buffer++) = (_val);
#define WRITE16(_val) WRITE8((_val) & 0xff); WRITE8(((_val) >> 8) & 0xff);
#define WRITE32(_val) WRITE16((_val) & 0xffff) *buffer; WRITE16(((_val) >> 16) & 0xffff);
bool decode_sensor_range(pkt_sensor_range* range, const unsigned char* buffer, int size)
{
if(!(size == 8 || size == 9)){
LOGE("invalid packet size (expected 8 or 9 but got %d)", size);
return false;
}
SKIP_CMD;
range->command_id = READ16;
range->accel_scale = READ8;
range->gyro_scale = READ16;
range->mag_scale = READ16;
return true;
}
bool decode_sensor_display_info(pkt_sensor_display_info* info, const unsigned char* buffer, int size)
{
if(!(size == 56 || size == 57)){
LOGE("invalid packet size (expected 56 or 57 but got %d)", size);
return false;
}
SKIP_CMD;
info->command_id = READ16;
info->distortion_type = READ8;
info->h_resolution = READ16;
info->v_resolution = READ16;
info->h_screen_size = READFIXED;
info->v_screen_size = READFIXED;
info->v_center = READFIXED;
info->lens_separation = READFIXED;
info->eye_to_screen_distance[0] = READFIXED;
info->eye_to_screen_distance[1] = READFIXED;
info->distortion_type_opts = 0;
for(int i = 0; i < 6; i++){
info->distortion_k[i] = READFLOAT;
}
return true;
}
bool decode_sensor_config(pkt_sensor_config* config, const unsigned char* buffer, int size)
{
if(!(size == 7 || size == 8)){
LOGE("invalid packet size (expected 7 or 8 but got %d)", size);
return false;
}
SKIP_CMD;
config->command_id = READ16;
config->flags = READ8;
config->packet_interval = READ8;
config->keep_alive_interval = READ16;
return true;
}
static void decode_sample(const unsigned char* buffer, int32_t* smp)
{
/*
* Decode 3 tightly packed 21 bit values from 4 bytes.
* We unpack them in the higher 21 bit values first and then shift
* them down to the lower in order to get the sign bits correct.
*/
int x = (buffer[0] << 24) | (buffer[1] << 16) | ((buffer[2] & 0xF8) << 8);
int y = ((buffer[2] & 0x07) << 29) | (buffer[3] << 21) | (buffer[4] << 13) | ((buffer[5] & 0xC0) << 5);
int z = ((buffer[5] & 0x3F) << 26) | (buffer[6] << 18) | (buffer[7] << 10);
smp[0] = x >> 11;
smp[1] = y >> 11;
smp[2] = z >> 11;
}
bool decode_tracker_sensor_msg(pkt_tracker_sensor* msg, const unsigned char* buffer, int size)
{
if(!(size == 62 || size == 64)){
LOGE("invalid packet size (expected 62 or 64 but got %d)", size);
return false;
}
SKIP_CMD;
msg->num_samples = READ8;
msg->timestamp = READ16;
msg->timestamp *= 1000; // DK1 timestamps are in milliseconds
msg->last_command_id = READ16;
msg->temperature = READ16;
msg->num_samples = OHMD_MIN(msg->num_samples, 3);
for(int i = 0; i < msg->num_samples; i++){
decode_sample(buffer, msg->samples[i].accel);
buffer += 8;
decode_sample(buffer, msg->samples[i].gyro);
buffer += 8;
}
// Skip empty samples
buffer += (3 - msg->num_samples) * 16;
for(int i = 0; i < 3; i++){
msg->mag[i] = READ16;
}
return true;
}
bool decode_tracker_sensor_msg_dk2(pkt_tracker_sensor* msg, const unsigned char* buffer, int size)
{
if(!(size == 64)){
LOGE("invalid packet size (expected 62 or 64 but got %d)", size);
return false;
}
SKIP_CMD;
msg->last_command_id = READ16;
msg->num_samples = READ8;
/* Next is the number of samples since start, excluding the samples
contained in this packet */
buffer += 2; // unused: nb_samples_since_start
msg->temperature = READ16;
msg->timestamp = READ32;
/* Second sample value is junk (outdated/uninitialized) value if
num_samples < 2. */
msg->num_samples = OHMD_MIN(msg->num_samples, 2);
for(int i = 0; i < msg->num_samples; i++){
decode_sample(buffer, msg->samples[i].accel);
buffer += 8;
decode_sample(buffer, msg->samples[i].gyro);
buffer += 8;
}
// Skip empty samples
buffer += (2 - msg->num_samples) * 16;
for(int i = 0; i < 3; i++){
msg->mag[i] = READ16;
}
// TODO: positional tracking data and frame data
return true;
}
// TODO do we need to consider HMD vs sensor "centric" values
void vec3f_from_rift_vec(const int32_t* smp, vec3f* out_vec)
{
out_vec->x = (float)smp[0] * 0.0001f;
out_vec->y = (float)smp[1] * 0.0001f;
out_vec->z = (float)smp[2] * 0.0001f;
}
int encode_sensor_config(unsigned char* buffer, const pkt_sensor_config* config)
{
WRITE8(RIFT_CMD_SENSOR_CONFIG);
WRITE16(config->command_id);
WRITE8(config->flags);
WRITE8(config->packet_interval);
WRITE16(config->keep_alive_interval);
return 7; // sensor config packet size
}
int encode_keep_alive(unsigned char* buffer, const pkt_keep_alive* keep_alive)
{
WRITE8(RIFT_CMD_KEEP_ALIVE);
WRITE16(keep_alive->command_id);
WRITE16(keep_alive->keep_alive_interval);
return 5; // keep alive packet size
}
int encode_enable_components(unsigned char* buffer, bool display, bool audio)
{
uint8_t flags = 0;
WRITE8(RIFT_CMD_ENABLE_COMPONENTS);
WRITE16(0); // last command ID
if (display)
flags |= 1;
if (audio)
flags |= 2;
// flags |= 4; // I don't know what it is. Wireless?
WRITE8(flags);
return 4;
}
void dump_packet_sensor_range(const pkt_sensor_range* range)
{
(void)range;
LOGD("sensor range\n");
LOGD(" command id: %d", range->command_id);
LOGD(" accel scale: %d", range->accel_scale);
LOGD(" gyro scale: %d", range->gyro_scale);
LOGD(" mag scale: %d", range->mag_scale);
}
void dump_packet_sensor_display_info(const pkt_sensor_display_info* info)
{
(void)info;
LOGD("display info");
LOGD(" command id: %d", info->command_id);
LOGD(" distortion_type: %d", info->distortion_type);
LOGD(" resolution: %d x %d", info->h_resolution, info->v_resolution);
LOGD(" screen size: %f x %f", info->h_screen_size, info->v_screen_size);
LOGD(" vertical center: %f", info->v_center);
LOGD(" lens_separation: %f", info->lens_separation);
LOGD(" eye_to_screen_distance: %f, %f", info->eye_to_screen_distance[0], info->eye_to_screen_distance[1]);
LOGD(" distortion_k: %f, %f, %f, %f, %f, %f",
info->distortion_k[0], info->distortion_k[1], info->distortion_k[2],
info->distortion_k[3], info->distortion_k[4], info->distortion_k[5]);
}
void dump_packet_sensor_config(const pkt_sensor_config* config)
{
(void)config;
LOGD("sensor config");
LOGD(" command id: %u", config->command_id);
LOGD(" flags: %02x", config->flags);
LOGD(" raw mode: %d", !!(config->flags & RIFT_SCF_RAW_MODE));
LOGD(" calibration test: %d", !!(config->flags & RIFT_SCF_CALIBRATION_TEST));
LOGD(" use calibration: %d", !!(config->flags & RIFT_SCF_USE_CALIBRATION));
LOGD(" auto calibration: %d", !!(config->flags & RIFT_SCF_AUTO_CALIBRATION));
LOGD(" motion keep alive: %d", !!(config->flags & RIFT_SCF_MOTION_KEEP_ALIVE));
LOGD(" motion command keep alive: %d", !!(config->flags & RIFT_SCF_COMMAND_KEEP_ALIVE));
LOGD(" sensor coordinates: %d", !!(config->flags & RIFT_SCF_SENSOR_COORDINATES));
LOGD(" packet interval: %u", config->packet_interval);
LOGD(" keep alive interval: %u", config->keep_alive_interval);
}
void dump_packet_tracker_sensor(const pkt_tracker_sensor* sensor)
{
(void)sensor;
LOGD("tracker sensor:");
LOGD(" last command id: %u", sensor->last_command_id);
LOGD(" timestamp: %u", sensor->timestamp);
LOGD(" temperature: %d", sensor->temperature);
LOGD(" num samples: %u", sensor->num_samples);
LOGD(" magnetic field: %i %i %i", sensor->mag[0], sensor->mag[1], sensor->mag[2]);
for(int i = 0; i < sensor->num_samples; i++){
LOGD(" accel: %d %d %d", sensor->samples[i].accel[0], sensor->samples[i].accel[1], sensor->samples[i].accel[2]);
LOGD(" gyro: %d %d %d", sensor->samples[i].gyro[0], sensor->samples[i].gyro[1], sensor->samples[i].gyro[2]);
}
}

View File

@@ -0,0 +1,456 @@
/*
* OpenHMD - Free and Open Source API and drivers for immersive technology.
* Copyright (C) 2013 Fredrik Hultin.
* Copyright (C) 2013 Jakob Bornecrantz.
* Distributed under the Boost 1.0 licence, see LICENSE for full text.
*/
/* Oculus Rift Driver - HID/USB Driver Implementation */
#include <stdlib.h>
#include <hidapi.h>
#include <string.h>
#include <stdio.h>
#include <time.h>
#include <assert.h>
#include "rift.h"
#define TICK_LEN (1.0f / 1000.0f) // 1000 Hz ticks
#define KEEP_ALIVE_VALUE (10 * 1000)
#define SETFLAG(_s, _flag, _val) (_s) = ((_s) & ~(_flag)) | ((_val) ? (_flag) : 0)
typedef struct {
ohmd_device base;
hid_device* handle;
pkt_sensor_range sensor_range;
pkt_sensor_display_info display_info;
rift_coordinate_frame coordinate_frame, hw_coordinate_frame;
pkt_sensor_config sensor_config;
pkt_tracker_sensor sensor;
uint32_t last_imu_timestamp;
double last_keep_alive;
fusion sensor_fusion;
vec3f raw_mag, raw_accel, raw_gyro;
} rift_priv;
typedef enum {
REV_DK1,
REV_DK2,
REV_CV1
} rift_revision;
typedef struct {
const char* name;
int id;
int iface;
rift_revision rev;
} rift_devices;
static rift_priv* rift_priv_get(ohmd_device* device)
{
return (rift_priv*)device;
}
static int get_feature_report(rift_priv* priv, rift_sensor_feature_cmd cmd, unsigned char* buf)
{
memset(buf, 0, FEATURE_BUFFER_SIZE);
buf[0] = (unsigned char)cmd;
return hid_get_feature_report(priv->handle, buf, FEATURE_BUFFER_SIZE);
}
static int send_feature_report(rift_priv* priv, const unsigned char *data, size_t length)
{
return hid_send_feature_report(priv->handle, data, length);
}
static void set_coordinate_frame(rift_priv* priv, rift_coordinate_frame coordframe)
{
priv->coordinate_frame = coordframe;
// set the RIFT_SCF_SENSOR_COORDINATES in the sensor config to match whether coordframe is hmd or sensor
SETFLAG(priv->sensor_config.flags, RIFT_SCF_SENSOR_COORDINATES, coordframe == RIFT_CF_SENSOR);
// encode send the new config to the Rift
unsigned char buf[FEATURE_BUFFER_SIZE];
int size = encode_sensor_config(buf, &priv->sensor_config);
if(send_feature_report(priv, buf, size) == -1){
ohmd_set_error(priv->base.ctx, "send_feature_report failed in set_coordinate frame");
return;
}
// read the state again, set the hw_coordinate_frame to match what
// the hardware actually is set to just incase it doesn't stick.
size = get_feature_report(priv, RIFT_CMD_SENSOR_CONFIG, buf);
if(size <= 0){
LOGW("could not set coordinate frame");
priv->hw_coordinate_frame = RIFT_CF_HMD;
return;
}
decode_sensor_config(&priv->sensor_config, buf, size);
priv->hw_coordinate_frame = (priv->sensor_config.flags & RIFT_SCF_SENSOR_COORDINATES) ? RIFT_CF_SENSOR : RIFT_CF_HMD;
if(priv->hw_coordinate_frame != coordframe) {
LOGW("coordinate frame didn't stick");
}
}
static void handle_tracker_sensor_msg(rift_priv* priv, unsigned char* buffer, int size)
{
if (buffer[0] == RIFT_IRQ_SENSORS
&& !decode_tracker_sensor_msg(&priv->sensor, buffer, size)){
LOGE("couldn't decode tracker sensor message");
}
if (buffer[0] == RIFT_IRQ_SENSORS_DK2
&& !decode_tracker_sensor_msg_dk2(&priv->sensor, buffer, size)){
LOGE("couldn't decode tracker sensor message");
}
pkt_tracker_sensor* s = &priv->sensor;
dump_packet_tracker_sensor(s);
int32_t mag32[] = { s->mag[0], s->mag[1], s->mag[2] };
vec3f_from_rift_vec(mag32, &priv->raw_mag);
// TODO: handle overflows in a nicer way
float dt = TICK_LEN; // TODO: query the Rift for the sample rate
if (s->timestamp > priv->last_imu_timestamp)
{
dt = (s->timestamp - priv->last_imu_timestamp) / 1000000.0f;
dt -= (s->num_samples - 1) * TICK_LEN; // TODO: query the Rift for the sample rate
}
for(int i = 0; i < s->num_samples; i++){
vec3f_from_rift_vec(s->samples[i].accel, &priv->raw_accel);
vec3f_from_rift_vec(s->samples[i].gyro, &priv->raw_gyro);
ofusion_update(&priv->sensor_fusion, dt, &priv->raw_gyro, &priv->raw_accel, &priv->raw_mag);
dt = TICK_LEN; // TODO: query the Rift for the sample rate
}
priv->last_imu_timestamp = s->timestamp;
}
static void update_device(ohmd_device* device)
{
rift_priv* priv = rift_priv_get(device);
unsigned char buffer[FEATURE_BUFFER_SIZE];
// Handle keep alive messages
double t = ohmd_get_tick();
if(t - priv->last_keep_alive >= (double)priv->sensor_config.keep_alive_interval / 1000.0 - .2){
// send keep alive message
pkt_keep_alive keep_alive = { 0, priv->sensor_config.keep_alive_interval };
int ka_size = encode_keep_alive(buffer, &keep_alive);
if (send_feature_report(priv, buffer, ka_size) == -1)
LOGE("error sending keepalive");
// Update the time of the last keep alive we have sent.
priv->last_keep_alive = t;
}
// Read all the messages from the device.
while(true){
int size = hid_read(priv->handle, buffer, FEATURE_BUFFER_SIZE);
if(size < 0){
LOGE("error reading from device");
return;
} else if(size == 0) {
return; // No more messages, return.
}
// currently the only message type the hardware supports (I think)
if(buffer[0] == RIFT_IRQ_SENSORS || buffer[0] == RIFT_IRQ_SENSORS_DK2) {
handle_tracker_sensor_msg(priv, buffer, size);
}else{
LOGE("unknown message type: %u", buffer[0]);
}
}
}
static int getf(ohmd_device* device, ohmd_float_value type, float* out)
{
rift_priv* priv = rift_priv_get(device);
switch(type){
case OHMD_DISTORTION_K: {
for (int i = 0; i < 6; i++) {
out[i] = priv->display_info.distortion_k[i];
}
break;
}
case OHMD_ROTATION_QUAT: {
*(quatf*)out = priv->sensor_fusion.orient;
break;
}
case OHMD_POSITION_VECTOR:
out[0] = out[1] = out[2] = 0;
break;
default:
ohmd_set_error(priv->base.ctx, "invalid type given to getf (%ud)", type);
return -1;
break;
}
return 0;
}
static void close_device(ohmd_device* device)
{
LOGD("closing device");
rift_priv* priv = rift_priv_get(device);
hid_close(priv->handle);
free(priv);
}
#ifndef _MSC_VER
static char* _hid_to_unix_path(char* path)
{
char bus [4];
char dev [4];
char *result = malloc( sizeof(char) * ( 20 + 1 ) );
sprintf (bus, "%.*s\n", 4, path);
sprintf (dev, "%.*s\n", 4, path + 5);
sprintf (result, "/dev/bus/usb/%03d/%03d",
(int)strtol(bus, NULL, 16),
(int)strtol(dev, NULL, 16));
return result;
}
#else
static char* _hid_to_unix_path(char* path)
{
return path;
}
#endif
static ohmd_device* open_device(ohmd_driver* driver, ohmd_device_desc* desc)
{
rift_priv* priv = ohmd_alloc(driver->ctx, sizeof(rift_priv));
if(!priv)
goto cleanup;
priv->last_imu_timestamp = -1;
priv->base.ctx = driver->ctx;
ohmd_toggle_ovr_service(0); //disable OVRService if running
// Open the HID device
priv->handle = hid_open_path(desc->path);
if(!priv->handle) {
char* path = _hid_to_unix_path(desc->path);
ohmd_set_error(driver->ctx, "Could not open %s. "
"Check your rights.", path);
#ifndef _MSC_VER
free(path);
#endif
goto cleanup;
}
if(hid_set_nonblocking(priv->handle, 1) == -1){
ohmd_set_error(driver->ctx, "failed to set non-blocking on device");
goto cleanup;
}
unsigned char buf[FEATURE_BUFFER_SIZE];
int size;
// Read and decode the sensor range
size = get_feature_report(priv, RIFT_CMD_RANGE, buf);
decode_sensor_range(&priv->sensor_range, buf, size);
dump_packet_sensor_range(&priv->sensor_range);
// Read and decode display information
size = get_feature_report(priv, RIFT_CMD_DISPLAY_INFO, buf);
decode_sensor_display_info(&priv->display_info, buf, size);
dump_packet_sensor_display_info(&priv->display_info);
// Read and decode the sensor config
size = get_feature_report(priv, RIFT_CMD_SENSOR_CONFIG, buf);
decode_sensor_config(&priv->sensor_config, buf, size);
dump_packet_sensor_config(&priv->sensor_config);
// if the sensor has display info data, use HMD coordinate frame
priv->coordinate_frame = priv->display_info.distortion_type != RIFT_DT_NONE ? RIFT_CF_HMD : RIFT_CF_SENSOR;
// enable calibration
SETFLAG(priv->sensor_config.flags, RIFT_SCF_USE_CALIBRATION, 1);
SETFLAG(priv->sensor_config.flags, RIFT_SCF_AUTO_CALIBRATION, 1);
// apply sensor config
set_coordinate_frame(priv, priv->coordinate_frame);
// Turn the screens on
if (desc->revision == REV_CV1)
{
size = encode_enable_components(buf, true, true);
if (send_feature_report(priv, buf, size) == -1)
LOGE("error turning the screens on");
}
// set keep alive interval to n seconds
pkt_keep_alive keep_alive = { 0, KEEP_ALIVE_VALUE };
size = encode_keep_alive(buf, &keep_alive);
if (send_feature_report(priv, buf, size) == -1)
LOGE("error setting up keepalive");
// Update the time of the last keep alive we have sent.
priv->last_keep_alive = ohmd_get_tick();
// update sensor settings with new keep alive value
// (which will have been ignored in favor of the default 1000 ms one)
size = get_feature_report(priv, RIFT_CMD_SENSOR_CONFIG, buf);
decode_sensor_config(&priv->sensor_config, buf, size);
dump_packet_sensor_config(&priv->sensor_config);
// Set default device properties
ohmd_set_default_device_properties(&priv->base.properties);
// Set device properties
priv->base.properties.hsize = priv->display_info.h_screen_size;
priv->base.properties.vsize = priv->display_info.v_screen_size;
priv->base.properties.hres = priv->display_info.h_resolution;
priv->base.properties.vres = priv->display_info.v_resolution;
priv->base.properties.lens_sep = priv->display_info.lens_separation;
priv->base.properties.lens_vpos = priv->display_info.v_center;
priv->base.properties.ratio = ((float)priv->display_info.h_resolution / (float)priv->display_info.v_resolution) / 2.0f;
//setup generic distortion coeffs, from hand-calibration
switch (desc->revision) {
case REV_DK2:
ohmd_set_universal_distortion_k(&(priv->base.properties), 0.247, -0.145, 0.103, 0.795);
ohmd_set_universal_aberration_k(&(priv->base.properties), 0.985, 1.000, 1.015);
break;
case REV_DK1:
ohmd_set_universal_distortion_k(&(priv->base.properties), 1.003, -1.005, 0.403, 0.599);
ohmd_set_universal_aberration_k(&(priv->base.properties), 0.985, 1.000, 1.015);
break;
case REV_CV1:
ohmd_set_universal_distortion_k(&(priv->base.properties), 0.098, .324, -0.241, 0.819);
ohmd_set_universal_aberration_k(&(priv->base.properties), 0.9952420, 1.0, 1.0008074);
/* CV1 reports IPD, but not lens center, at least not anywhere I could find, so use the manually measured value of 0.054 */
priv->display_info.lens_separation = 0.054;
priv->base.properties.lens_sep = priv->display_info.lens_separation;
default:
break;
}
// calculate projection eye projection matrices from the device properties
//ohmd_calc_default_proj_matrices(&priv->base.properties);
float l,r,t,b,n,f;
// left eye screen bounds
l = -1.0f * (priv->display_info.h_screen_size/2 - priv->display_info.lens_separation/2);
r = priv->display_info.lens_separation/2;
t = priv->display_info.v_screen_size - priv->display_info.v_center;
b = -1.0f * priv->display_info.v_center;
n = priv->display_info.eye_to_screen_distance[0];
f = n*10e6;
//LOGD("l: %0.3f, r: %0.3f, b: %0.3f, t: %0.3f, n: %0.3f, f: %0.3f", l,r,b,t,n,f);
/* eye separation is handled by IPD in the Modelview matrix */
omat4x4f_init_frustum(&priv->base.properties.proj_left, l, r, b, t, n, f);
//right eye screen bounds
l = -1.0f * priv->display_info.lens_separation/2;
r = priv->display_info.h_screen_size/2 - priv->display_info.lens_separation/2;
n = priv->display_info.eye_to_screen_distance[1];
f = n*10e6;
//LOGD("l: %0.3f, r: %0.3f, b: %0.3f, t: %0.3f, n: %0.3f, f: %0.3f", l,r,b,t,n,f);
/* eye separation is handled by IPD in the Modelview matrix */
omat4x4f_init_frustum(&priv->base.properties.proj_right, l, r, b, t, n, f);
priv->base.properties.fov = 2 * atan2f(
priv->display_info.h_screen_size/2 - priv->display_info.lens_separation/2,
priv->display_info.eye_to_screen_distance[0]);
// set up device callbacks
priv->base.update = update_device;
priv->base.close = close_device;
priv->base.getf = getf;
// initialize sensor fusion
ofusion_init(&priv->sensor_fusion);
return &priv->base;
cleanup:
if(priv)
free(priv);
return NULL;
}
#define OCULUS_VR_INC_ID 0x2833
#define RIFT_ID_COUNT 4
static void get_device_list(ohmd_driver* driver, ohmd_device_list* list)
{
// enumerate HID devices and add any Rifts found to the device list
rift_devices rd[RIFT_ID_COUNT] = {
{ "Rift (DK1)", 0x0001, -1, REV_DK1 },
{ "Rift (DK2)", 0x0021, -1, REV_DK2 },
{ "Rift (DK2)", 0x2021, -1, REV_DK2 },
{ "Rift (CV1)", 0x0031, 0, REV_CV1 },
};
for(int i = 0; i < RIFT_ID_COUNT; i++){
struct hid_device_info* devs = hid_enumerate(OCULUS_VR_INC_ID, rd[i].id);
struct hid_device_info* cur_dev = devs;
if(devs == NULL)
continue;
while (cur_dev) {
if(rd[i].iface == -1 || cur_dev->interface_number == rd[i].iface){
ohmd_device_desc* desc = &list->devices[list->num_devices++];
strcpy(desc->driver, "OpenHMD Rift Driver");
strcpy(desc->vendor, "Oculus VR, Inc.");
strcpy(desc->product, rd[i].name);
desc->revision = rd[i].rev;
strcpy(desc->path, cur_dev->path);
desc->driver_ptr = driver;
}
cur_dev = cur_dev->next;
}
hid_free_enumeration(devs);
}
}
static void destroy_driver(ohmd_driver* drv)
{
LOGD("shutting down driver");
hid_exit();
free(drv);
ohmd_toggle_ovr_service(1); //re-enable OVRService if previously running
}
ohmd_driver* ohmd_create_oculus_rift_drv(ohmd_context* ctx)
{
ohmd_driver* drv = ohmd_alloc(ctx, sizeof(ohmd_driver));
if(drv == NULL)
return NULL;
drv->get_device_list = get_device_list;
drv->open_device = open_device;
drv->destroy = destroy_driver;
drv->ctx = ctx;
return drv;
}

View File

@@ -0,0 +1,115 @@
/*
* OpenHMD - Free and Open Source API and drivers for immersive technology.
* Copyright (C) 2013 Fredrik Hultin.
* Copyright (C) 2013 Jakob Bornecrantz.
* Distributed under the Boost 1.0 licence, see LICENSE for full text.
*/
/* Oculus Rift Driver Internal Interface */
#ifndef RIFT_H
#define RIFT_H
#include "../openhmdi.h"
#define FEATURE_BUFFER_SIZE 256
typedef enum {
RIFT_CMD_SENSOR_CONFIG = 2,
RIFT_CMD_RANGE = 4,
RIFT_CMD_KEEP_ALIVE = 8,
RIFT_CMD_DISPLAY_INFO = 9,
RIFT_CMD_ENABLE_COMPONENTS = 0x1d
} rift_sensor_feature_cmd;
typedef enum {
RIFT_CF_SENSOR,
RIFT_CF_HMD
} rift_coordinate_frame;
typedef enum {
RIFT_IRQ_SENSORS = 1,
RIFT_IRQ_SENSORS_DK2 = 11
} rift_irq_cmd;
typedef enum {
RIFT_DT_NONE,
RIFT_DT_SCREEN_ONLY,
RIFT_DT_DISTORTION
} rift_distortion_type;
// Sensor config flags
#define RIFT_SCF_RAW_MODE 0x01
#define RIFT_SCF_CALIBRATION_TEST 0x02
#define RIFT_SCF_USE_CALIBRATION 0x04
#define RIFT_SCF_AUTO_CALIBRATION 0x08
#define RIFT_SCF_MOTION_KEEP_ALIVE 0x10
#define RIFT_SCF_COMMAND_KEEP_ALIVE 0x20
#define RIFT_SCF_SENSOR_COORDINATES 0x40
typedef struct {
uint16_t command_id;
uint16_t accel_scale;
uint16_t gyro_scale;
uint16_t mag_scale;
} pkt_sensor_range;
typedef struct {
int32_t accel[3];
int32_t gyro[3];
} pkt_tracker_sample;
typedef struct {
uint8_t num_samples;
uint32_t timestamp;
uint16_t last_command_id;
int16_t temperature;
pkt_tracker_sample samples[3];
int16_t mag[3];
} pkt_tracker_sensor;
typedef struct {
uint16_t command_id;
uint8_t flags;
uint16_t packet_interval;
uint16_t keep_alive_interval; // in ms
} pkt_sensor_config;
typedef struct {
uint16_t command_id;
rift_distortion_type distortion_type;
uint8_t distortion_type_opts;
uint16_t h_resolution, v_resolution;
float h_screen_size, v_screen_size;
float v_center;
float lens_separation;
float eye_to_screen_distance[2];
float distortion_k[6];
} pkt_sensor_display_info;
typedef struct {
uint16_t command_id;
uint16_t keep_alive_interval;
} pkt_keep_alive;
bool decode_sensor_range(pkt_sensor_range* range, const unsigned char* buffer, int size);
bool decode_sensor_display_info(pkt_sensor_display_info* info, const unsigned char* buffer, int size);
bool decode_sensor_config(pkt_sensor_config* config, const unsigned char* buffer, int size);
bool decode_tracker_sensor_msg(pkt_tracker_sensor* msg, const unsigned char* buffer, int size);
bool decode_tracker_sensor_msg_dk2(pkt_tracker_sensor* msg, const unsigned char* buffer, int size);
void vec3f_from_rift_vec(const int32_t* smp, vec3f* out_vec);
int encode_sensor_config(unsigned char* buffer, const pkt_sensor_config* config);
int encode_keep_alive(unsigned char* buffer, const pkt_keep_alive* keep_alive);
int encode_enable_components(unsigned char* buffer, bool display, bool audio);
void dump_packet_sensor_range(const pkt_sensor_range* range);
void dump_packet_sensor_config(const pkt_sensor_config* config);
void dump_packet_sensor_display_info(const pkt_sensor_display_info* info);
void dump_packet_tracker_sensor(const pkt_tracker_sensor* sensor);
#endif

53
extern/openhmd/src/drv_psvr/packet.c vendored Normal file
View File

@@ -0,0 +1,53 @@
#include "psvr.h"
#ifdef _MSC_VER
#define inline __inline
#endif
inline static uint8_t read8(const unsigned char** buffer)
{
uint8_t ret = **buffer;
*buffer += 1;
return ret;
}
inline static int16_t read16(const unsigned char** buffer)
{
int16_t ret = **buffer | (*(*buffer + 1) << 8);
*buffer += 2;
return ret;
}
inline static uint32_t read32(const unsigned char** buffer)
{
uint32_t ret = **buffer | (*(*buffer + 1) << 8) | (*(*buffer + 2) << 16) | (*(*buffer + 3) << 24);
*buffer += 4;
return ret;
}
bool psvr_decode_sensor_packet(psvr_sensor_packet* pkt, const unsigned char* buffer, int size)
{
if(size != 64){
LOGE("invalid psvr sensor packet size (expected 64 but got %d)", size);
return false;
}
buffer += 2; //skip 2
pkt->samples[0].volume = read16(&buffer); //volume
buffer += 12; //unknown, skip 12
pkt->samples[0].tick = read32(&buffer); //TICK
// acceleration
for(int i = 0; i < 3; i++){
pkt->samples[0].gyro[i] = read16(&buffer);
}
// rotation
for(int i = 0; i < 3; i++){
pkt->samples[0].accel[i] = read16(&buffer);
}//34
buffer += 23; //probably other sample somewhere
pkt->samples[0].proximity = read8(&buffer); //255 for close
pkt->samples[0].proximity_state = read8(&buffer); // 0 (nothing) to 3 (headset is on)
return true;
}

296
extern/openhmd/src/drv_psvr/psvr.c vendored Normal file
View File

@@ -0,0 +1,296 @@
/*
* OpenHMD - Free and Open Source API and drivers for immersive technology.
* Copyright (C) 2013 Fredrik Hultin.
* Copyright (C) 2013 Jakob Bornecrantz.
* Distributed under the Boost 1.0 licence, see LICENSE for full text.
*/
/* Sony PSVR Driver */
#define FEATURE_BUFFER_SIZE 256
#define TICK_LEN (1.0f / 1000000.0f) // 1000 Hz ticks
#define SONY_ID 0x054c
#define PSVR_HMD 0x09af
#include <string.h>
#include <wchar.h>
#include <hidapi.h>
#include <assert.h>
#include <limits.h>
#include <stdint.h>
#include <stdbool.h>
#include "psvr.h"
typedef struct {
ohmd_device base;
hid_device* hmd_handle;
hid_device* hmd_control;
fusion sensor_fusion;
vec3f raw_accel, raw_gyro;
uint32_t last_ticks;
uint8_t last_seq;
psvr_sensor_packet sensor;
} psvr_priv;
void vec3f_from_psvr_vec(const int16_t* smp, vec3f* out_vec)
{
out_vec->x = (float)smp[1] * 0.001f;
out_vec->y = (float)smp[0] * 0.001f;
out_vec->z = (float)smp[2] * 0.001f * -1.0f;
}
static void handle_tracker_sensor_msg(psvr_priv* priv, unsigned char* buffer, int size)
{
uint32_t last_sample_tick = priv->sensor.tick;
if(!psvr_decode_sensor_packet(&priv->sensor, buffer, size)){
LOGE("couldn't decode tracker sensor message");
}
psvr_sensor_packet* s = &priv->sensor;
uint32_t tick_delta = 1000;
if(last_sample_tick > 0) //startup correction
tick_delta = s->tick - last_sample_tick;
float dt = tick_delta * TICK_LEN;
vec3f mag = {{0.0f, 0.0f, 0.0f}};
for(int i = 0; i < 1; i++){ //just use 1 sample since we don't have sample order for frame
vec3f_from_psvr_vec(s->samples[i].accel, &priv->raw_accel);
vec3f_from_psvr_vec(s->samples[i].gyro, &priv->raw_gyro);
ofusion_update(&priv->sensor_fusion, dt, &priv->raw_gyro, &priv->raw_accel, &mag);
// reset dt to tick_len for the last samples if there were more than one sample
dt = TICK_LEN;
}
}
static void update_device(ohmd_device* device)
{
psvr_priv* priv = (psvr_priv*)device;
int size = 0;
unsigned char buffer[FEATURE_BUFFER_SIZE];
while(true){
int size = hid_read(priv->hmd_handle, buffer, FEATURE_BUFFER_SIZE);
if(size < 0){
LOGE("error reading from device");
return;
} else if(size == 0) {
return; // No more messages, return.
}
// currently the only message type the hardware supports (I think)
if(buffer[0] == PSVR_IRQ_SENSORS){
handle_tracker_sensor_msg(priv, buffer, size);
}else if (buffer[0] == PSVR_IRQ_VOLUME_PLUS){
//TODO implement
}else if (buffer[0] == PSVR_IRQ_VOLUME_MINUS){
//TODO implement
}else if (buffer[0] == PSVR_IRQ_MIC_MUTE){
//TODO implement
}else{
LOGE("unknown message type: %u", buffer[0]);
}
}
if(size < 0){
LOGE("error reading from device");
}
}
static int getf(ohmd_device* device, ohmd_float_value type, float* out)
{
psvr_priv* priv = (psvr_priv*)device;
switch(type){
case OHMD_ROTATION_QUAT:
*(quatf*)out = priv->sensor_fusion.orient;
break;
case OHMD_POSITION_VECTOR:
out[0] = out[1] = out[2] = 0;
break;
case OHMD_DISTORTION_K:
// TODO this should be set to the equivalent of no distortion
memset(out, 0, sizeof(float) * 6);
break;
default:
ohmd_set_error(priv->base.ctx, "invalid type given to getf (%ud)", type);
return -1;
break;
}
return 0;
}
static void close_device(ohmd_device* device)
{
psvr_priv* priv = (psvr_priv*)device;
LOGD("closing HTC PSVR device");
hid_close(priv->hmd_handle);
hid_close(priv->hmd_control);
free(device);
}
static hid_device* open_device_idx(int manufacturer, int product, int iface, int iface_tot, int device_index)
{
struct hid_device_info* devs = hid_enumerate(manufacturer, product);
struct hid_device_info* cur_dev = devs;
int idx = 0;
int iface_cur = 0;
hid_device* ret = NULL;
while (cur_dev) {
printf("%04x:%04x %s\n", (unsigned int)manufacturer, (unsigned int)product, cur_dev->path);
if(idx == device_index && iface == iface_cur){
ret = hid_open_path(cur_dev->path);
printf("opening\n");
}
cur_dev = cur_dev->next;
iface_cur++;
if(iface_cur >= iface_tot){
idx++;
iface_cur = 0;
}
}
hid_free_enumeration(devs);
return ret;
}
static ohmd_device* open_device(ohmd_driver* driver, ohmd_device_desc* desc)
{
psvr_priv* priv = ohmd_alloc(driver->ctx, sizeof(psvr_priv));
if(!priv)
return NULL;
priv->base.ctx = driver->ctx;
int idx = atoi(desc->path);
// Open the HMD device
priv->hmd_handle = open_device_idx(SONY_ID, PSVR_HMD, 0, 0, idx);
if(!priv->hmd_handle)
goto cleanup;
if(hid_set_nonblocking(priv->hmd_handle, 1) == -1){
ohmd_set_error(driver->ctx, "failed to set non-blocking on device");
goto cleanup;
}
// Open the HMD Control device
priv->hmd_control = open_device_idx(SONY_ID, PSVR_HMD, 0, 0, 1);
if(!priv->hmd_control)
goto cleanup;
if(hid_set_nonblocking(priv->hmd_control, 1) == -1){
ohmd_set_error(driver->ctx, "failed to set non-blocking on device");
goto cleanup;
}
// turn the display on
hid_write(priv->hmd_control, psvr_power_on, sizeof(psvr_power_on));
// set VR mode for the hmd
hid_write(priv->hmd_control, psvr_vrmode_on, sizeof(psvr_vrmode_on));
// Set default device properties
ohmd_set_default_device_properties(&priv->base.properties);
// Set device properties TODO: Get from device
priv->base.properties.hsize = 0.126; //from calculated specs
priv->base.properties.vsize = 0.071; //from calculated specs
priv->base.properties.hres = 1920;
priv->base.properties.vres = 1080;
priv->base.properties.lens_sep = 0.063500;
priv->base.properties.lens_vpos = 0.049694;
priv->base.properties.fov = DEG_TO_RAD(103.57f); //TODO: Confirm exact mesurements
priv->base.properties.ratio = (1920.0f / 1080.0f) / 2.0f;
// calculate projection eye projection matrices from the device properties
ohmd_calc_default_proj_matrices(&priv->base.properties);
// set up device callbacks
priv->base.update = update_device;
priv->base.close = close_device;
priv->base.getf = getf;
ofusion_init(&priv->sensor_fusion);
return (ohmd_device*)priv;
cleanup:
if(priv)
free(priv);
return NULL;
}
static void get_device_list(ohmd_driver* driver, ohmd_device_list* list)
{
struct hid_device_info* devs = hid_enumerate(SONY_ID, PSVR_HMD);
struct hid_device_info* cur_dev = devs;
int idx = 0;
while (cur_dev) {
ohmd_device_desc* desc = &list->devices[list->num_devices++];
strcpy(desc->driver, "OpenHMD Sony PSVR Driver");
strcpy(desc->vendor, "Sony");
strcpy(desc->product, "PSVR");
desc->revision = 0;
snprintf(desc->path, OHMD_STR_SIZE, "%d", idx);
desc->driver_ptr = driver;
cur_dev = cur_dev->next;
idx++;
}
hid_free_enumeration(devs);
}
static void destroy_driver(ohmd_driver* drv)
{
LOGD("shutting down Sony PSVR driver");
free(drv);
}
ohmd_driver* ohmd_create_psvr_drv(ohmd_context* ctx)
{
ohmd_driver* drv = ohmd_alloc(ctx, sizeof(ohmd_driver));
if(!drv)
return NULL;
drv->get_device_list = get_device_list;
drv->open_device = open_device;
drv->destroy = destroy_driver;
drv->ctx = ctx;
return drv;
}

48
extern/openhmd/src/drv_psvr/psvr.h vendored Normal file
View File

@@ -0,0 +1,48 @@
#ifndef PSVR_H
#define PSVR_H
#include <stdint.h>
#include <stdbool.h>
#include "../openhmdi.h"
typedef enum
{
PSVR_IRQ_SENSORS = 0,
PSVR_IRQ_VOLUME_PLUS = 2,
PSVR_IRQ_VOLUME_MINUS = 4,
PSVR_IRQ_MIC_MUTE = 8
} psvr_irq_cmd;
typedef struct
{
int16_t accel[3];
int16_t gyro[3];
uint32_t tick;
uint8_t seq;
uint8_t volume;
uint8_t proximity;
uint8_t proximity_state;
} psvr_sensor_sample;
typedef struct
{
uint8_t report_id;
uint32_t tick;
psvr_sensor_sample samples[1];
} psvr_sensor_packet;
static const unsigned char psvr_vrmode_on[12] = {
0x11, 0x00, 0xaa, 0x08, 0x00, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00
};
static const unsigned char psvr_power_on[8] = {
0x17, 0x76, 0xaa, 0x04, 0x01, 0x00, 0x00, 0x00
};
void vec3f_from_psvr_vec(const int16_t* smp, vec3f* out_vec);
bool psvr_decode_sensor_packet(psvr_sensor_packet* pkt, const unsigned char* buffer, int size);
#endif

126
extern/openhmd/src/fusion.c vendored Normal file
View File

@@ -0,0 +1,126 @@
/*
* OpenHMD - Free and Open Source API and drivers for immersive technology.
* Copyright (C) 2013 Fredrik Hultin.
* Copyright (C) 2013 Jakob Bornecrantz.
* Distributed under the Boost 1.0 licence, see LICENSE for full text.
*/
/* Sensor Fusion Implementation */
#include <string.h>
#include "openhmdi.h"
void ofusion_init(fusion* me)
{
memset(me, 0, sizeof(fusion));
me->orient.w = 1.0f;
ofq_init(&me->mag_fq, 20);
ofq_init(&me->accel_fq, 20);
ofq_init(&me->ang_vel_fq, 20);
me->flags = FF_USE_GRAVITY;
me->grav_gain = 0.05f;
}
void ofusion_update(fusion* me, float dt, const vec3f* ang_vel, const vec3f* accel, const vec3f* mag)
{
me->ang_vel = *ang_vel;
me->accel = *accel;
me->raw_mag = *mag;
me->mag = *mag;
vec3f world_accel;
oquatf_get_rotated(&me->orient, accel, &world_accel);
me->iterations += 1;
me->time += dt;
ofq_add(&me->mag_fq, mag);
ofq_add(&me->accel_fq, &world_accel);
ofq_add(&me->ang_vel_fq, ang_vel);
float ang_vel_length = ovec3f_get_length(ang_vel);
if(ang_vel_length > 0.0001f){
vec3f rot_axis =
{{ ang_vel->x / ang_vel_length, ang_vel->y / ang_vel_length, ang_vel->z / ang_vel_length }};
float rot_angle = ang_vel_length * dt;
quatf delta_orient;
oquatf_init_axis(&delta_orient, &rot_axis, rot_angle);
oquatf_mult_me(&me->orient, &delta_orient);
}
// gravity correction
if(me->flags & FF_USE_GRAVITY){
const float gravity_tolerance = .4f, ang_vel_tolerance = .1f;
const float min_tilt_error = 0.05f, max_tilt_error = 0.01f;
// if the device is within tolerance levels, count this as the device is level and add to the counter
// otherwise reset the counter and start over
me->device_level_count =
fabsf(ovec3f_get_length(accel) - 9.82f) < gravity_tolerance * 2.0f && ang_vel_length < ang_vel_tolerance
? me->device_level_count + 1 : 0;
// device has been level for long enough, grab mean from the accelerometer filter queue (last n values)
// and use for correction
if(me->device_level_count > 50){
me->device_level_count = 0;
vec3f accel_mean;
ofq_get_mean(&me->accel_fq, &accel_mean);
if (ovec3f_get_length(&accel_mean) - 9.82f < gravity_tolerance)
{
// Calculate a cross product between what the device
// thinks is up and what gravity indicates is down.
// The values are optimized of what we would get out
// from the cross product.
vec3f tilt = {{accel_mean.z, 0, -accel_mean.x}};
ovec3f_normalize_me(&tilt);
ovec3f_normalize_me(&accel_mean);
vec3f up = {{0, 1.0f, 0}};
float tilt_angle = ovec3f_get_angle(&up, &accel_mean);
if(tilt_angle > max_tilt_error){
me->grav_error_angle = tilt_angle;
me->grav_error_axis = tilt;
}
}
}
// preform gravity tilt correction
if(me->grav_error_angle > min_tilt_error){
float use_angle;
// if less than 2000 iterations have passed, set the up axis to the correction value outright
if(me->iterations < 2000){
use_angle = -me->grav_error_angle;
me->grav_error_angle = 0;
}
// otherwise try to correct
else {
use_angle = -me->grav_gain * me->grav_error_angle * 0.005f * (5.0f * ang_vel_length + 1.0f);
me->grav_error_angle += use_angle;
}
// perform the correction
quatf corr_quat, old_orient;
oquatf_init_axis(&corr_quat, &me->grav_error_axis, use_angle);
old_orient = me->orient;
oquatf_mult(&corr_quat, &old_orient, &me->orient);
}
}
// mitigate drift due to floating point
// inprecision with quat multiplication.
oquatf_normalize_me(&me->orient);
}

44
extern/openhmd/src/fusion.h vendored Normal file
View File

@@ -0,0 +1,44 @@
/*
* OpenHMD - Free and Open Source API and drivers for immersive technology.
* Copyright (C) 2013 Fredrik Hultin.
* Copyright (C) 2013 Jakob Bornecrantz.
* Distributed under the Boost 1.0 licence, see LICENSE for full text.
*/
/* Sensor Fusion */
#ifndef FUSION_H
#define FUSION_H
#include "omath.h"
#define FF_USE_GRAVITY 1
typedef struct {
int state;
quatf orient; // orientation
vec3f accel; // acceleration
vec3f ang_vel; // angular velocity
vec3f mag; // magnetometer
vec3f raw_mag; // raw magnetometer values
int iterations;
float time;
int flags;
// filter queues for magnetometer, accelerometers and angular velocity
filter_queue mag_fq, accel_fq, ang_vel_fq;
// gravity correction
int device_level_count;
float grav_error_angle;
vec3f grav_error_axis;
float grav_gain; // amount of correction
} fusion;
void ofusion_init(fusion* me);
void ofusion_update(fusion* me, float dt, const vec3f* ang_vel, const vec3f* accel, const vec3f* mag_field);
#endif

39
extern/openhmd/src/log.h vendored Normal file
View File

@@ -0,0 +1,39 @@
/*
* OpenHMD - Free and Open Source API and drivers for immersive technology.
* Copyright (C) 2013 Fredrik Hultin.
* Copyright (C) 2013 Jakob Bornecrantz.
* Distributed under the Boost 1.0 licence, see LICENSE for full text.
*/
/* Logging and Error Handling */
#ifndef LOG_H
#define LOG_H
void* ohmd_allocfn(ohmd_context* ctx, const char* e_msg, size_t size);
#define ohmd_alloc(_ctx, _size) ohmd_allocfn(_ctx, "could not allocate " #_size " bytes of RAM @ " __FILE__ ":" OHMD_STRINGIFY(__LINE__), _size)
#ifndef LOGLEVEL
#define LOGLEVEL 2
#endif
#define LOG(_level, _levelstr, ...) do{ if(_level >= LOGLEVEL){ printf("[%s] ", (_levelstr)); printf(__VA_ARGS__); puts(""); } } while(0)
#if LOGLEVEL == 0
#define LOGD(...) LOG(0, "DD", __VA_ARGS__)
#else
#define LOGD(...)
#endif
#define LOGV(...) LOG(1, "VV", __VA_ARGS__)
#define LOGI(...) LOG(2, "II", __VA_ARGS__)
#define LOGW(...) LOG(3, "WW", __VA_ARGS__)
#define LOGE(...) LOG(4, "EE", __VA_ARGS__)
#ifdef _MSC_VER
#define snprintf _snprintf
#endif
#define ohmd_set_error(_ctx, ...) { snprintf((_ctx)->error_msg, OHMD_STR_SIZE, __VA_ARGS__); LOGE(__VA_ARGS__); }
#endif

395
extern/openhmd/src/omath.c vendored Normal file
View File

@@ -0,0 +1,395 @@
/*
* OpenHMD - Free and Open Source API and drivers for immersive technology.
* Copyright (C) 2013 Fredrik Hultin.
* Copyright (C) 2013 Jakob Bornecrantz.
* Distributed under the Boost 1.0 licence, see LICENSE for full text.
*/
/* Math Code Implementation */
#include <string.h>
#include "openhmdi.h"
// vector
float ovec3f_get_length(const vec3f* me)
{
return sqrtf(POW2(me->x) + POW2(me->y) + POW2(me->z));
}
void ovec3f_normalize_me(vec3f* me)
{
if(me->x == 0 && me->y == 0 && me->z == 0)
return;
float len = ovec3f_get_length(me);
me->x /= len;
me->y /= len;
me->z /= len;
}
void ovec3f_subtract(const vec3f* a, const vec3f* b, vec3f* out)
{
for(int i = 0; i < 3; i++)
out->arr[i] = a->arr[i] - b->arr[i];
}
float ovec3f_get_dot(const vec3f* me, const vec3f* vec)
{
return me->x * vec->x + me->y * vec->y + me->z * vec->z;
}
float ovec3f_get_angle(const vec3f* me, const vec3f* vec)
{
float dot = ovec3f_get_dot(me, vec);
float lengths = ovec3f_get_length(me) * ovec3f_get_length(vec);
if(lengths == 0)
return 0;
return acosf(dot / lengths);
}
// quaternion
void oquatf_init_axis(quatf* me, const vec3f* vec, float angle)
{
vec3f norm = *vec;
ovec3f_normalize_me(&norm);
me->x = norm.x * sinf(angle / 2.0f);
me->y = norm.y * sinf(angle / 2.0f);
me->z = norm.z * sinf(angle / 2.0f);
me->w = cosf(angle / 2.0f);
}
void oquatf_get_rotated(const quatf* me, const vec3f* vec, vec3f* out_vec)
{
quatf q = {{vec->x * me->w + vec->z * me->y - vec->y * me->z,
vec->y * me->w + vec->x * me->z - vec->z * me->x,
vec->z * me->w + vec->y * me->x - vec->x * me->y,
vec->x * me->x + vec->y * me->y + vec->z * me->z}};
out_vec->x = me->w * q.x + me->x * q.w + me->y * q.z - me->z * q.y;
out_vec->y = me->w * q.y + me->y * q.w + me->z * q.x - me->x * q.z;
out_vec->z = me->w * q.z + me->z * q.w + me->x * q.y - me->y * q.x;
}
void oquatf_mult(const quatf* me, const quatf* q, quatf* out_q)
{
out_q->x = me->w * q->x + me->x * q->w + me->y * q->z - me->z * q->y;
out_q->y = me->w * q->y - me->x * q->z + me->y * q->w + me->z * q->x;
out_q->z = me->w * q->z + me->x * q->y - me->y * q->x + me->z * q->w;
out_q->w = me->w * q->w - me->x * q->x - me->y * q->y - me->z * q->z;
}
void oquatf_mult_me(quatf* me, const quatf* q)
{
quatf tmp = *me;
oquatf_mult(&tmp, q, me);
}
void oquatf_normalize_me(quatf* me)
{
float len = oquatf_get_length(me);
me->x /= len;
me->y /= len;
me->z /= len;
me->w /= len;
}
float oquatf_get_length(const quatf* me)
{
return sqrtf(me->x * me->x + me->y * me->y + me->z * me->z + me->w * me->w);
}
float oquatf_get_dot(const quatf* me, const quatf* q)
{
return me->x * q->x + me->y * q->y + me->z * q->z + me->w * q->w;
}
void oquatf_inverse(quatf* me)
{
float dot = oquatf_get_dot(me, me);
// conjugate
for(int i = 0; i < 3; i++)
me->arr[i] = -me->arr[i];
for(int i = 0; i < 4; i++)
me->arr[i] /= dot;
}
void oquatf_diff(const quatf* me, const quatf* q, quatf* out_q)
{
quatf inv = *me;
oquatf_inverse(&inv);
oquatf_mult(&inv, q, out_q);
}
void oquatf_slerp (float fT, const quatf* rkP, const quatf* rkQ, bool shortestPath, quatf* out_q)
{
float fCos = oquatf_get_dot(rkP, rkQ);
quatf rkT;
// Do we need to invert rotation?
if (fCos < 0.0f && shortestPath)
{
fCos = -fCos;
rkT = *rkQ;
oquatf_inverse(&rkT);
}
else
{
rkT = *rkQ;
}
if (fabsf(fCos) < 1 - 0.001f)
{
// Standard case (slerp)
float fSin = sqrtf(1 - (fCos*fCos));
float fAngle = atan2f(fSin, fCos);
float fInvSin = 1.0f / fSin;
float fCoeff0 = sin((1.0f - fT) * fAngle) * fInvSin;
float fCoeff1 = sin(fT * fAngle) * fInvSin;
out_q->x = fCoeff0 * rkP->x + fCoeff1 * rkT.x;
out_q->y = fCoeff0 * rkP->y + fCoeff1 * rkT.y;
out_q->z = fCoeff0 * rkP->z + fCoeff1 * rkT.z;
out_q->w = fCoeff0 * rkP->w + fCoeff1 * rkT.w;
//return fCoeff0 * rkP + fCoeff1 * rkT;
}
else
{
// There are two situations:
// 1. "rkP" and "rkQ" are very close (fCos ~= +1), so we can do a linear
// interpolation safely.
// 2. "rkP" and "rkQ" are almost inverse of each other (fCos ~= -1), there
// are an infinite number of possibilities interpolation. but we haven't
// have method to fix this case, so just use linear interpolation here.
//Quaternion t = (1.0f - fT) * rkP + fT * rkT;
out_q->x = (1.0f - fT) * rkP->x + fT * rkT.x;
out_q->y = (1.0f - fT) * rkP->y + fT * rkT.y;
out_q->z = (1.0f - fT) * rkP->z + fT * rkT.z;
out_q->w = (1.0f - fT) * rkP->w + fT * rkT.w;
oquatf_normalize_me(out_q);
// taking the complement requires renormalisation
//t.normalise();
//return t;
}
}
void oquatf_get_mat4x4(const quatf* me, const vec3f* point, float mat[4][4])
{
mat[0][0] = 1 - 2 * me->y * me->y - 2 * me->z * me->z;
mat[0][1] = 2 * me->x * me->y - 2 * me->w * me->z;
mat[0][2] = 2 * me->x * me->z + 2 * me->w * me->y;
mat[0][3] = point->x;
mat[1][0] = 2 * me->x * me->y + 2 * me->w * me->z;
mat[1][1] = 1 - 2 * me->x * me->x - 2 * me->z * me->z;
mat[1][2] = 2 * me->y * me->z - 2 * me->w * me->x;
mat[1][3] = point->y;
mat[2][0] = 2 * me->x * me->z - 2 * me->w * me->y;
mat[2][1] = 2 * me->y * me->z + 2 * me->w * me->x;
mat[2][2] = 1 - 2 * me->x * me->x - 2 * me->y * me->y;
mat[2][3] = point->z;
mat[3][0] = 0;
mat[3][1] = 0;
mat[3][2] = 0;
mat[3][3] = 1;
}
// matrix
void omat4x4f_init_ident(mat4x4f* me)
{
memset(me, 0, sizeof(*me));
me->m[0][0] = 1.0f;
me->m[1][1] = 1.0f;
me->m[2][2] = 1.0f;
me->m[3][3] = 1.0f;
}
void omat4x4f_init_perspective(mat4x4f* me, float fovy_rad, float aspect, float znear, float zfar)
{
float sine, cotangent, delta, half_fov;
half_fov = fovy_rad / 2.0f;
delta = zfar - znear;
sine = sinf(half_fov);
if ((delta == 0.0f) || (sine == 0.0f) || (aspect == 0.0f)) {
omat4x4f_init_ident(me);
return;
}
cotangent = cosf(half_fov) / sine;
me->m[0][0] = cotangent / aspect;
me->m[0][1] = 0;
me->m[0][2] = 0;
me->m[0][3] = 0;
me->m[1][0] = 0;
me->m[1][1] = cotangent;
me->m[1][2] = 0;
me->m[1][3] = 0;
me->m[2][0] = 0;
me->m[2][1] = 0;
me->m[2][2] = -(zfar + znear) / delta;
me->m[2][3] = -2.0f * znear * zfar / delta;
me->m[3][0] = 0;
me->m[3][1] = 0;
me->m[3][2] = -1.0f;
me->m[3][3] = 0;
}
void omat4x4f_init_frustum(mat4x4f* me, float left, float right, float bottom, float top, float znear, float zfar)
{
omat4x4f_init_ident(me);
float delta_x = right - left;
float delta_y = top - bottom;
float delta_z = zfar - znear;
if ((delta_x == 0.0f) || (delta_y == 0.0f) || (delta_z == 0.0f)) {
/* can't divide by zero, so just give back identity */
return;
}
me->m[0][0] = 2.0f * znear / delta_x;
me->m[0][1] = 0;
me->m[0][2] = (right + left) / delta_x;
me->m[0][3] = 0;
me->m[1][0] = 0;
me->m[1][1] = 2.0f * znear / delta_y;
me->m[1][2] = (top + bottom) / delta_y;
me->m[1][3] = 0;
me->m[2][0] = 0;
me->m[2][1] = 0;
me->m[2][2] = -(zfar + znear) / delta_z;
me->m[2][3] = -2.0f * zfar * znear / delta_z;
me->m[3][0] = 0;
me->m[3][1] = 0;
me->m[3][2] = -1.0f;
me->m[3][3] = 0;
}
void omat4x4f_init_look_at(mat4x4f* me, const quatf* rot, const vec3f* eye)
{
quatf q;
vec3f p;
q.x = -rot->x;
q.y = -rot->y;
q.z = -rot->z;
q.w = rot->w;
p.x = -eye->x;
p.y = -eye->y;
p.z = -eye->z;
me->m[0][0] = 1 - 2 * q.y * q.y - 2 * q.z * q.z;
me->m[0][1] = 2 * q.x * q.y - 2 * q.w * q.z;
me->m[0][2] = 2 * q.x * q.z + 2 * q.w * q.y;
me->m[0][3] = p.x * me->m[0][0] + p.y * me->m[0][1] + p.z * me->m[0][2];
me->m[1][0] = 2 * q.x * q.y + 2 * q.w * q.z;
me->m[1][1] = 1 - 2 * q.x * q.x - 2 * q.z * q.z;
me->m[1][2] = 2 * q.y * q.z - 2 * q.w * q.x;
me->m[1][3] = p.x * me->m[1][0] + p.y * me->m[1][1] + p.z * me->m[1][2];
me->m[2][0] = 2 * q.x * q.z - 2 * q.w * q.y;
me->m[2][1] = 2 * q.y * q.z + 2 * q.w * q.x;
me->m[2][2] = 1 - 2 * q.x * q.x - 2 * q.y * q.y;
me->m[2][3] = p.x * me->m[2][0] + p.y * me->m[2][1] + p.z * me->m[2][2];
me->m[3][0] = 0;
me->m[3][1] = 0;
me->m[3][2] = 0;
me->m[3][3] = 1;
}
void omat4x4f_init_translate(mat4x4f* me, float x, float y, float z)
{
omat4x4f_init_ident(me);
me->m[0][3] = x;
me->m[1][3] = y;
me->m[2][3] = z;
}
void omat4x4f_transpose(const mat4x4f* m, mat4x4f* o)
{
o->m[0][0] = m->m[0][0];
o->m[1][0] = m->m[0][1];
o->m[2][0] = m->m[0][2];
o->m[3][0] = m->m[0][3];
o->m[0][1] = m->m[1][0];
o->m[1][1] = m->m[1][1];
o->m[2][1] = m->m[1][2];
o->m[3][1] = m->m[1][3];
o->m[0][2] = m->m[2][0];
o->m[1][2] = m->m[2][1];
o->m[2][2] = m->m[2][2];
o->m[3][2] = m->m[2][3];
o->m[0][3] = m->m[3][0];
o->m[1][3] = m->m[3][1];
o->m[2][3] = m->m[3][2];
o->m[3][3] = m->m[3][3];
}
void omat4x4f_mult(const mat4x4f* l, const mat4x4f* r, mat4x4f *o)
{
for(int i = 0; i < 4; i++){
float a0 = l->m[i][0], a1 = l->m[i][1], a2 = l->m[i][2], a3 = l->m[i][3];
o->m[i][0] = a0 * r->m[0][0] + a1 * r->m[1][0] + a2 * r->m[2][0] + a3 * r->m[3][0];
o->m[i][1] = a0 * r->m[0][1] + a1 * r->m[1][1] + a2 * r->m[2][1] + a3 * r->m[3][1];
o->m[i][2] = a0 * r->m[0][2] + a1 * r->m[1][2] + a2 * r->m[2][2] + a3 * r->m[3][2];
o->m[i][3] = a0 * r->m[0][3] + a1 * r->m[1][3] + a2 * r->m[2][3] + a3 * r->m[3][3];
}
}
// filter queue
void ofq_init(filter_queue* me, int size)
{
memset(me, 0, sizeof(filter_queue));
me->size = size;
}
void ofq_add(filter_queue* me, const vec3f* vec)
{
me->elems[me->at] = *vec;
me->at = ((me->at + 1) % me->size);
}
void ofq_get_mean(const filter_queue* me, vec3f* vec)
{
vec->x = vec->y = vec->z = 0;
for(int i = 0; i < me->size; i++){
vec->x += me->elems[i].x;
vec->y += me->elems[i].y;
vec->z += me->elems[i].z;
}
vec->x /= (float)me->size;
vec->y /= (float)me->size;
vec->z /= (float)me->size;
}

90
extern/openhmd/src/omath.h vendored Normal file
View File

@@ -0,0 +1,90 @@
/*
* OpenHMD - Free and Open Source API and drivers for immersive technology.
* Copyright (C) 2013 Fredrik Hultin.
* Copyright (C) 2013 Jakob Bornecrantz.
* Distributed under the Boost 1.0 licence, see LICENSE for full text.
*/
/* Math */
#ifndef OMATH_H
#define OMATH_H
#include <math.h>
#ifndef M_PI
#define M_PI 3.14159265358979323846
#endif
#define POW2(_x) ((_x) * (_x))
#define RAD_TO_DEG(_r) ((_r) * 360.0f / (2.0f * (float)M_PI))
#define DEG_TO_RAD(_d) ((_d) * (2.0f * (float)M_PI) / 360.0f)
// vector
typedef union {
struct {
float x, y, z;
};
float arr[3];
} vec3f;
void ovec3f_normalize_me(vec3f* me);
float ovec3f_get_length(const vec3f* me);
float ovec3f_get_angle(const vec3f* me, const vec3f* vec);
float ovec3f_get_dot(const vec3f* me, const vec3f* vec);
void ovec3f_subtract(const vec3f* a, const vec3f* b, vec3f* out);
// quaternion
typedef union {
struct {
float x, y, z, w;
};
float arr[4];
} quatf;
void oquatf_init_axis(quatf* me, const vec3f* vec, float angle);
void oquatf_get_rotated(const quatf* me, const vec3f* vec, vec3f* out_vec);
void oquatf_mult_me(quatf* me, const quatf* q);
void oquatf_mult(const quatf* me, const quatf* q, quatf* out_q);
void oquatf_diff(const quatf* me, const quatf* q, quatf* out_q);
void oquatf_normalize_me(quatf* me);
float oquatf_get_length(const quatf* me);
float oquatf_get_dot(const quatf* me, const quatf* q);
void oquatf_inverse(quatf* me);
void oquatf_get_mat4x4(const quatf* me, const vec3f* point, float mat[4][4]);
// matrix
typedef union {
float m[4][4];
float arr[16];
} mat4x4f;
void omat4x4f_init_ident(mat4x4f* me);
void omat4x4f_init_perspective(mat4x4f* me, float fov_rad, float aspect, float znear, float zfar);
void omat4x4f_init_frustum(mat4x4f* me, float left, float right, float bottom, float top, float znear, float zfar);
void omat4x4f_init_look_at(mat4x4f* me, const quatf* ret, const vec3f* eye);
void omat4x4f_init_translate(mat4x4f* me, float x, float y, float z);
void omat4x4f_mult(const mat4x4f* left, const mat4x4f* right, mat4x4f* out_mat);
void omat4x4f_transpose(const mat4x4f* me, mat4x4f* out_mat);
// filter queue
#define FILTER_QUEUE_MAX_SIZE 256
typedef struct {
int at, size;
vec3f elems[FILTER_QUEUE_MAX_SIZE];
} filter_queue;
void ofq_init(filter_queue* me, int size);
void ofq_add(filter_queue* me, const vec3f* vec);
void ofq_get_mean(const filter_queue* me, vec3f* vec);
#endif

572
extern/openhmd/src/openhmd.c vendored Normal file
View File

@@ -0,0 +1,572 @@
/*
* OpenHMD - Free and Open Source API and drivers for immersive technology.
* Copyright (C) 2013 Fredrik Hultin.
* Copyright (C) 2013 Jakob Bornecrantz.
* Distributed under the Boost 1.0 licence, see LICENSE for full text.
*/
/* Main Lib Implemenation */
#include "openhmdi.h"
#include "shaders.h"
#include <stdlib.h>
#include <string.h>
#include <stdio.h>
#define DIGITAL_INPUT_EVENT_QUEUE_SIZE 1024
// Running automatic updates at 1000 Hz
#define AUTOMATIC_UPDATE_SLEEP (1.0 / 1000.0)
ohmd_context* OHMD_APIENTRY ohmd_ctx_create(void)
{
ohmd_context* ctx = calloc(1, sizeof(ohmd_context));
if(!ctx){
LOGE("could not allocate RAM for context");
return NULL;
}
#if DRIVER_OCULUS_RIFT
ctx->drivers[ctx->num_drivers++] = ohmd_create_oculus_rift_drv(ctx);
#endif
#if DRIVER_DEEPOON
ctx->drivers[ctx->num_drivers++] = ohmd_create_deepoon_drv(ctx);
#endif
#if DRIVER_PSVR
ctx->drivers[ctx->num_drivers++] = ohmd_create_psvr_drv(ctx);
#endif
#if DRIVER_HTC_VIVE
ctx->drivers[ctx->num_drivers++] = ohmd_create_htc_vive_drv(ctx);
#endif
#if DRIVER_EXTERNAL
ctx->drivers[ctx->num_drivers++] = ohmd_create_external_drv(ctx);
#endif
#if DRIVER_ANDROID
ctx->drivers[ctx->num_drivers++] = ohmd_create_android_drv(ctx);
#endif
// add dummy driver last to make it the lowest priority
ctx->drivers[ctx->num_drivers++] = ohmd_create_dummy_drv(ctx);
ctx->update_request_quit = false;
return ctx;
}
void OHMD_APIENTRY ohmd_ctx_destroy(ohmd_context* ctx)
{
ctx->update_request_quit = true;
for(int i = 0; i < ctx->num_active_devices; i++){
ctx->active_devices[i]->close(ctx->active_devices[i]);
}
for(int i = 0; i < ctx->num_drivers; i++){
ctx->drivers[i]->destroy(ctx->drivers[i]);
}
if(ctx->update_thread){
ohmd_destroy_thread(ctx->update_thread);
ohmd_destroy_mutex(ctx->update_mutex);
}
free(ctx);
}
void OHMD_APIENTRY ohmd_ctx_update(ohmd_context* ctx)
{
for(int i = 0; i < ctx->num_active_devices; i++){
ohmd_device* dev = ctx->active_devices[i];
if(!dev->settings.automatic_update && dev->update)
dev->update(dev);
ohmd_lock_mutex(ctx->update_mutex);
dev->getf(dev, OHMD_POSITION_VECTOR, (float*)&dev->position);
dev->getf(dev, OHMD_ROTATION_QUAT, (float*)&dev->rotation);
ohmd_unlock_mutex(ctx->update_mutex);
}
}
const char* OHMD_APIENTRY ohmd_ctx_get_error(ohmd_context* ctx)
{
return ctx->error_msg;
}
int OHMD_APIENTRY ohmd_ctx_probe(ohmd_context* ctx)
{
memset(&ctx->list, 0, sizeof(ohmd_device_list));
for(int i = 0; i < ctx->num_drivers; i++){
ctx->drivers[i]->get_device_list(ctx->drivers[i], &ctx->list);
}
return ctx->list.num_devices;
}
const char* OHMD_APIENTRY ohmd_gets(ohmd_string_description type)
{
switch(type){
case OHMD_GLSL_DISTORTION_VERT_SRC:
return distortion_vert;
case OHMD_GLSL_DISTORTION_FRAG_SRC:
return distortion_frag;
default:
return NULL;
}
}
const char* OHMD_APIENTRY ohmd_list_gets(ohmd_context* ctx, int index, ohmd_string_value type)
{
if(index >= ctx->list.num_devices)
return NULL;
switch(type){
case OHMD_VENDOR:
return ctx->list.devices[index].vendor;
case OHMD_PRODUCT:
return ctx->list.devices[index].product;
case OHMD_PATH:
return ctx->list.devices[index].path;
default:
return NULL;
}
}
static unsigned int ohmd_update_thread(void* arg)
{
ohmd_context* ctx = (ohmd_context*)arg;
while(!ctx->update_request_quit)
{
ohmd_lock_mutex(ctx->update_mutex);
for(int i = 0; i < ctx->num_active_devices; i++){
if(ctx->active_devices[i]->settings.automatic_update && ctx->active_devices[i]->update)
ctx->active_devices[i]->update(ctx->active_devices[i]);
}
ohmd_unlock_mutex(ctx->update_mutex);
ohmd_sleep(AUTOMATIC_UPDATE_SLEEP);
}
return 0;
}
static void ohmd_set_up_update_thread(ohmd_context* ctx)
{
if(!ctx->update_thread){
ctx->update_mutex = ohmd_create_mutex(ctx);
ctx->update_thread = ohmd_create_thread(ctx, ohmd_update_thread, ctx);
}
}
ohmd_device* OHMD_APIENTRY ohmd_list_open_device_s(ohmd_context* ctx, int index, ohmd_device_settings* settings)
{
ohmd_lock_mutex(ctx->update_mutex);
if(index >= 0 && index < ctx->list.num_devices){
ohmd_device_desc* desc = &ctx->list.devices[index];
ohmd_driver* driver = (ohmd_driver*)desc->driver_ptr;
ohmd_device* device = driver->open_device(driver, desc);
if (device == NULL)
return NULL;
device->rotation_correction.w = 1;
device->settings = *settings;
device->ctx = ctx;
device->active_device_idx = ctx->num_active_devices;
ctx->active_devices[ctx->num_active_devices++] = device;
if(device->properties.digital_button_count > 0)
device->digital_input_event_queue = ohmdq_create(ctx, sizeof(ohmd_digital_input_event), DIGITAL_INPUT_EVENT_QUEUE_SIZE);
ohmd_unlock_mutex(ctx->update_mutex);
if(device->settings.automatic_update)
ohmd_set_up_update_thread(ctx);
return device;
}
ohmd_unlock_mutex(ctx->update_mutex);
ohmd_set_error(ctx, "no device with index: %d", index);
return NULL;
}
ohmd_device* OHMD_APIENTRY ohmd_list_open_device(ohmd_context* ctx, int index)
{
ohmd_device_settings settings;
settings.automatic_update = true;
return ohmd_list_open_device_s(ctx, index, &settings);
}
int OHMD_APIENTRY ohmd_close_device(ohmd_device* device)
{
ohmd_lock_mutex(device->ctx->update_mutex);
ohmd_context* ctx = device->ctx;
int idx = device->active_device_idx;
ohmdq* dinq = device->digital_input_event_queue;
memmove(ctx->active_devices + idx, ctx->active_devices + idx + 1,
sizeof(ohmd_device*) * (ctx->num_active_devices - idx - 1));
device->close(device);
if(dinq)
ohmdq_destroy(dinq);
ctx->num_active_devices--;
for(int i = idx; i < ctx->num_active_devices; i++)
ctx->active_devices[i]->active_device_idx--;
ohmd_unlock_mutex(ctx->update_mutex);
return OHMD_S_OK;
}
static int ohmd_device_getf_unp(ohmd_device* device, ohmd_float_value type, float* out)
{
switch(type){
case OHMD_LEFT_EYE_GL_MODELVIEW_MATRIX: {
vec3f point = {{0, 0, 0}};
quatf rot = device->rotation;
quatf tmp = device->rotation_correction;
oquatf_mult_me(&tmp, &rot);
rot = tmp;
mat4x4f orient, world_shift, result;
omat4x4f_init_look_at(&orient, &rot, &point);
omat4x4f_init_translate(&world_shift, +(device->properties.ipd / 2.0f), 0, 0);
omat4x4f_mult(&world_shift, &orient, &result);
omat4x4f_transpose(&result, (mat4x4f*)out);
return OHMD_S_OK;
}
case OHMD_RIGHT_EYE_GL_MODELVIEW_MATRIX: {
vec3f point = {{0, 0, 0}};
quatf rot = device->rotation;
oquatf_mult_me(&rot, &device->rotation_correction);
mat4x4f orient, world_shift, result;
omat4x4f_init_look_at(&orient, &rot, &point);
omat4x4f_init_translate(&world_shift, -(device->properties.ipd / 2.0f), 0, 0);
omat4x4f_mult(&world_shift, &orient, &result);
omat4x4f_transpose(&result, (mat4x4f*)out);
return OHMD_S_OK;
}
case OHMD_LEFT_EYE_GL_PROJECTION_MATRIX:
omat4x4f_transpose(&device->properties.proj_left, (mat4x4f*)out);
return OHMD_S_OK;
case OHMD_RIGHT_EYE_GL_PROJECTION_MATRIX:
omat4x4f_transpose(&device->properties.proj_right, (mat4x4f*)out);
return OHMD_S_OK;
case OHMD_SCREEN_HORIZONTAL_SIZE:
*out = device->properties.hsize;
return OHMD_S_OK;
case OHMD_SCREEN_VERTICAL_SIZE:
*out = device->properties.vsize;
return OHMD_S_OK;
case OHMD_LENS_HORIZONTAL_SEPARATION:
*out = device->properties.lens_sep;
return OHMD_S_OK;
case OHMD_LENS_VERTICAL_POSITION:
*out = device->properties.lens_vpos;
return OHMD_S_OK;
case OHMD_RIGHT_EYE_FOV:
case OHMD_LEFT_EYE_FOV:
*out = device->properties.fov;
return OHMD_S_OK;
case OHMD_RIGHT_EYE_ASPECT_RATIO:
case OHMD_LEFT_EYE_ASPECT_RATIO:
*out = device->properties.ratio;
return OHMD_S_OK;
case OHMD_EYE_IPD:
*out = device->properties.ipd;
return OHMD_S_OK;
case OHMD_PROJECTION_ZFAR:
*out = device->properties.zfar;
return OHMD_S_OK;
case OHMD_PROJECTION_ZNEAR:
*out = device->properties.znear;
return OHMD_S_OK;
case OHMD_ROTATION_QUAT:
{
*(quatf*)out = device->rotation;
oquatf_mult_me((quatf*)out, &device->rotation_correction);
quatf tmp = device->rotation_correction;
oquatf_mult_me(&tmp, (quatf*)out);
*(quatf*)out = tmp;
return OHMD_S_OK;
}
case OHMD_POSITION_VECTOR:
{
*(vec3f*)out = device->position;
for(int i = 0; i < 3; i++)
out[i] += device->position_correction.arr[i];
return OHMD_S_OK;
}
case OHMD_UNIVERSAL_DISTORTION_K: {
for (int i = 0; i < 4; i++) {
out[i] = device->properties.universal_distortion_k[i];
}
return OHMD_S_OK;
}
case OHMD_UNIVERSAL_ABERRATION_K: {
for (int i = 0; i < 3; i++) {
out[i] = device->properties.universal_aberration_k[i];
}
return OHMD_S_OK;
}
default:
return device->getf(device, type, out);
}
}
int OHMD_APIENTRY ohmd_device_getf(ohmd_device* device, ohmd_float_value type, float* out)
{
ohmd_lock_mutex(device->ctx->update_mutex);
int ret = ohmd_device_getf_unp(device, type, out);
ohmd_unlock_mutex(device->ctx->update_mutex);
return ret;
}
int ohmd_device_setf_unp(ohmd_device* device, ohmd_float_value type, const float* in)
{
switch(type){
case OHMD_EYE_IPD:
device->properties.ipd = *in;
return OHMD_S_OK;
case OHMD_PROJECTION_ZFAR:
device->properties.zfar = *in;
return OHMD_S_OK;
case OHMD_PROJECTION_ZNEAR:
device->properties.znear = *in;
return OHMD_S_OK;
case OHMD_ROTATION_QUAT:
{
// adjust rotation correction
quatf q;
int ret = device->getf(device, OHMD_ROTATION_QUAT, (float*)&q);
if(ret != 0){
return ret;
}
oquatf_diff(&q, (quatf*)in, &device->rotation_correction);
return OHMD_S_OK;
}
case OHMD_POSITION_VECTOR:
{
// adjust position correction
vec3f v;
int ret = device->getf(device, OHMD_POSITION_VECTOR, (float*)&v);
if(ret != 0){
return ret;
}
for(int i = 0; i < 3; i++)
device->position_correction.arr[i] = in[i] - v.arr[i];
return OHMD_S_OK;
}
case OHMD_EXTERNAL_SENSOR_FUSION:
{
if(device->setf == NULL)
return OHMD_S_UNSUPPORTED;
return device->setf(device, type, in);
}
default:
return OHMD_S_INVALID_PARAMETER;
}
}
int OHMD_APIENTRY ohmd_device_setf(ohmd_device* device, ohmd_float_value type, const float* in)
{
ohmd_lock_mutex(device->ctx->update_mutex);
int ret = ohmd_device_setf_unp(device, type, in);
ohmd_unlock_mutex(device->ctx->update_mutex);
return ret;
}
int OHMD_APIENTRY ohmd_device_geti(ohmd_device* device, ohmd_int_value type, int* out)
{
ohmdq* dinq = device->digital_input_event_queue;
switch(type){
case OHMD_SCREEN_HORIZONTAL_RESOLUTION:
*out = device->properties.hres;
return OHMD_S_OK;
case OHMD_SCREEN_VERTICAL_RESOLUTION:
*out = device->properties.vres;
return OHMD_S_OK;
case OHMD_BUTTON_EVENT_COUNT:
*out = dinq ? (int)ohmdq_get_size(dinq) : 0;
return OHMD_S_OK;
case OHMD_BUTTON_EVENT_OVERFLOW:
*out = dinq ? (ohmdq_get_size(dinq) == ohmdq_get_max(dinq)) : 0;
return OHMD_S_OK;
case OHMD_BUTTON_COUNT:
*out = device->properties.digital_button_count;
return OHMD_S_OK;
case OHMD_BUTTON_POP_EVENT: {
ohmd_digital_input_event event;
if(!ohmdq_pop(dinq, &event)){
return OHMD_S_INVALID_OPERATION;
}
out[0] = event.idx;
out[1] = event.state;
return OHMD_S_OK;
}
default:
return OHMD_S_INVALID_PARAMETER;
}
}
int OHMD_APIENTRY ohmd_device_seti(ohmd_device* device, ohmd_int_value type, const int* in)
{
switch(type){
default:
return OHMD_S_INVALID_PARAMETER;
}
}
int ohmd_device_set_data_unp(ohmd_device* device, ohmd_data_value type, const void* in)
{
switch(type){
case OHMD_DRIVER_DATA:
device->set_data(device, OHMD_DRIVER_DATA, in);
return OHMD_S_OK;
case OHMD_DRIVER_PROPERTIES:
device->set_data(device, OHMD_DRIVER_PROPERTIES, in);
return OHMD_S_OK;
default:
return OHMD_S_INVALID_PARAMETER;
}
}
int OHMD_APIENTRY ohmd_device_set_data(ohmd_device* device, ohmd_data_value type, const void* in)
{
ohmd_lock_mutex(device->ctx->update_mutex);
int ret = ohmd_device_set_data_unp(device, type, in);
ohmd_unlock_mutex(device->ctx->update_mutex);
return ret;
}
ohmd_status OHMD_APIENTRY ohmd_device_settings_seti(ohmd_device_settings* settings, ohmd_int_settings key, const int* val)
{
switch(key){
case OHMD_IDS_AUTOMATIC_UPDATE:
settings->automatic_update = val[0] == 0 ? false : true;
return OHMD_S_OK;
default:
return OHMD_S_INVALID_PARAMETER;
}
}
ohmd_device_settings* OHMD_APIENTRY ohmd_device_settings_create(ohmd_context* ctx)
{
return ohmd_alloc(ctx, sizeof(ohmd_device_settings));
}
void OHMD_APIENTRY ohmd_device_settings_destroy(ohmd_device_settings* settings)
{
free(settings);
}
void* ohmd_allocfn(ohmd_context* ctx, const char* e_msg, size_t size)
{
void* ret = calloc(1, size);
if(!ret)
ohmd_set_error(ctx, "%s", e_msg);
return ret;
}
void ohmd_set_default_device_properties(ohmd_device_properties* props)
{
props->ipd = 0.061f;
props->znear = 0.1f;
props->zfar = 1000.0f;
ohmd_set_universal_distortion_k(props, 0, 0, 0, 1);
ohmd_set_universal_aberration_k(props, 1.0, 1.0, 1.0);
}
void ohmd_calc_default_proj_matrices(ohmd_device_properties* props)
{
mat4x4f proj_base; // base projection matrix
// Calculate where the lens is on each screen,
// and with the given value offset the projection matrix.
float screen_center = props->hsize / 4.0f;
float lens_shift = screen_center - props->lens_sep / 2.0f;
// XXX: on CV1, props->hsize > props->lens_sep / 2.0,
// I am not sure about the implications, but just taking the absolute
// value of the offset seems to work.
float proj_offset = fabs(4.0f * lens_shift / props->hsize);
// Setup the base projection matrix. Each eye mostly have the
// same projection matrix with the exception of the offset.
omat4x4f_init_perspective(&proj_base, props->fov, props->ratio, props->znear, props->zfar);
// Setup the two adjusted projection matricies. Each is setup to deal
// with the fact that the lens is not in the center of the screen.
// These matrices only change of the hardware changes, so static.
mat4x4f translate;
omat4x4f_init_translate(&translate, proj_offset, 0, 0);
omat4x4f_mult(&translate, &proj_base, &props->proj_left);
omat4x4f_init_translate(&translate, -proj_offset, 0, 0);
omat4x4f_mult(&translate, &proj_base, &props->proj_right);
}
void ohmd_set_universal_distortion_k(ohmd_device_properties* props, float a, float b, float c, float d)
{
props->universal_distortion_k[0] = a;
props->universal_distortion_k[1] = b;
props->universal_distortion_k[2] = c;
props->universal_distortion_k[3] = d;
}
void ohmd_set_universal_aberration_k(ohmd_device_properties* props, float r, float g, float b)
{
props->universal_aberration_k[0] = r;
props->universal_aberration_k[1] = g;
props->universal_aberration_k[2] = b;
}

152
extern/openhmd/src/openhmdi.h vendored Normal file
View File

@@ -0,0 +1,152 @@
/*
* OpenHMD - Free and Open Source API and drivers for immersive technology.
* Copyright (C) 2013 Fredrik Hultin.
* Copyright (C) 2013 Jakob Bornecrantz.
* Distributed under the Boost 1.0 licence, see LICENSE for full text.
*/
/* Internal interface */
#ifndef OPENHMDI_H
#define OPENHMDI_H
#include <stdbool.h>
#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
#include "openhmd.h"
#include "omath.h"
#include "platform.h"
#include "queue.h"
#define OHMD_MAX_DEVICES 16
#define OHMD_MAX(_a, _b) ((_a) > (_b) ? (_a) : (_b))
#define OHMD_MIN(_a, _b) ((_a) < (_b) ? (_a) : (_b))
#define OHMD_STRINGIFY(_what) #_what
typedef struct ohmd_driver ohmd_driver;
typedef struct {
char driver[OHMD_STR_SIZE];
char vendor[OHMD_STR_SIZE];
char product[OHMD_STR_SIZE];
char path[OHMD_STR_SIZE];
int revision;
ohmd_driver* driver_ptr;
} ohmd_device_desc;
typedef struct {
int num_devices;
ohmd_device_desc devices[OHMD_MAX_DEVICES];
} ohmd_device_list;
typedef struct {
int idx;
ohmd_button_state state;
} ohmd_digital_input_event;
struct ohmd_driver {
void (*get_device_list)(ohmd_driver* driver, ohmd_device_list* list);
ohmd_device* (*open_device)(ohmd_driver* driver, ohmd_device_desc* desc);
void (*destroy)(ohmd_driver* driver);
ohmd_context* ctx;
};
typedef struct {
int hres;
int vres;
int digital_button_count;
float hsize;
float vsize;
float lens_sep;
float lens_vpos;
float fov;
float ratio;
float ipd;
float zfar;
float znear;
int accel_only; //bool-like for setting acceleration only fallback (android driver)
mat4x4f proj_left; // adjusted projection matrix for left screen
mat4x4f proj_right; // adjusted projection matrix for right screen
float universal_distortion_k[4]; //PanoTools lens distiorion model [a,b,c,d]
float universal_aberration_k[3]; //post-warp per channel scaling [r,g,b]
} ohmd_device_properties;
struct ohmd_device_settings
{
bool automatic_update;
};
struct ohmd_device {
ohmd_device_properties properties;
quatf rotation_correction;
vec3f position_correction;
int (*getf)(ohmd_device* device, ohmd_float_value type, float* out);
int (*setf)(ohmd_device* device, ohmd_float_value type, const float* in);
int (*seti)(ohmd_device* device, ohmd_int_value type, const int* in);
int (*set_data)(ohmd_device* device, ohmd_data_value type, const void* in);
void (*update)(ohmd_device* device);
void (*close)(ohmd_device* device);
ohmd_context* ctx;
ohmd_device_settings settings;
int active_device_idx; // index into ohmd_device->active_devices[]
quatf rotation;
vec3f position;
ohmdq* digital_input_event_queue;
};
struct ohmd_context {
ohmd_driver* drivers[16];
int num_drivers;
ohmd_device_list list;
ohmd_device* active_devices[256];
int num_active_devices;
ohmd_thread* update_thread;
ohmd_mutex* update_mutex;
bool update_request_quit;
char error_msg[OHMD_STR_SIZE];
};
// helper functions
void ohmd_set_default_device_properties(ohmd_device_properties* props);
void ohmd_calc_default_proj_matrices(ohmd_device_properties* props);
void ohmd_set_universal_distortion_k(ohmd_device_properties* props, float a, float b, float c, float d);
void ohmd_set_universal_aberration_k(ohmd_device_properties* props, float r, float g, float b);
// drivers
ohmd_driver* ohmd_create_dummy_drv(ohmd_context* ctx);
ohmd_driver* ohmd_create_oculus_rift_drv(ohmd_context* ctx);
ohmd_driver* ohmd_create_deepoon_drv(ohmd_context* ctx);
ohmd_driver* ohmd_create_psvr_drv(ohmd_context* ctx);
ohmd_driver* ohmd_create_htc_vive_drv(ohmd_context* ctx);
ohmd_driver* ohmd_create_external_drv(ohmd_context* ctx);
ohmd_driver* ohmd_create_android_drv(ohmd_context* ctx);
#include "log.h"
#include "omath.h"
#include "fusion.h"
#endif

132
extern/openhmd/src/platform-posix.c vendored Normal file
View File

@@ -0,0 +1,132 @@
/*
* OpenHMD - Free and Open Source API and drivers for immersive technology.
* Copyright (C) 2013 Fredrik Hultin.
* Copyright (C) 2013 Jakob Bornecrantz.
* Distributed under the Boost 1.0 licence, see LICENSE for full text.
*/
/* Platform Specific Functions, Unix/Posix Implementation */
#if defined(__unix__) || defined(__unix) || defined(__APPLE__) || defined(__MACH__)
#ifdef __CYGWIN__
#define CLOCK_MONOTONIC (clockid_t)4
#endif
#define _POSIX_C_SOURCE 199309L
#include <time.h>
#include <sys/time.h>
#include <stdio.h>
#include <pthread.h>
#include "platform.h"
#include "openhmdi.h"
// Use clock_gettime if the system implements posix realtime timers
#ifndef CLOCK_MONOTONIC
double ohmd_get_tick()
{
struct timeval now;
gettimeofday(&now, NULL);
return (double)now.tv_sec * 1.0 + (double)now.tv_usec / 1000000.0;
}
#else
double ohmd_get_tick()
{
struct timespec now;
clock_gettime(CLOCK_MONOTONIC, &now);
return (double)now.tv_sec * 1.0 + (double)now.tv_nsec / 1000000000.0;
}
#endif
void ohmd_sleep(double seconds)
{
struct timespec sleepfor;
sleepfor.tv_sec = (time_t)seconds;
sleepfor.tv_nsec = (long)((seconds - sleepfor.tv_sec) * 1000000000.0);
nanosleep(&sleepfor, NULL);
}
// threads
struct ohmd_thread
{
pthread_t thread;
unsigned int (*routine)(void* arg);
void* arg;
};
static void* pthread_wrapper(void* arg)
{
ohmd_thread* my_thread = (ohmd_thread*)arg;
my_thread->routine(my_thread->arg);
return NULL;
}
ohmd_thread* ohmd_create_thread(ohmd_context* ctx, unsigned int (*routine)(void* arg), void* arg)
{
ohmd_thread* thread = ohmd_alloc(ctx, sizeof(ohmd_thread));
if(thread == NULL)
return NULL;
thread->arg = arg;
thread->routine = routine;
int ret = pthread_create(&thread->thread, NULL, pthread_wrapper, thread);
if(ret != 0){
free(thread);
thread = NULL;
}
return thread;
}
ohmd_mutex* ohmd_create_mutex(ohmd_context* ctx)
{
pthread_mutex_t* mutex = ohmd_alloc(ctx, sizeof(pthread_mutex_t));
if(mutex == NULL)
return NULL;
int ret = pthread_mutex_init(mutex, NULL);
if(ret != 0){
free(mutex);
mutex = NULL;
}
return (ohmd_mutex*)mutex;
}
void ohmd_destroy_thread(ohmd_thread* thread)
{
pthread_join(thread->thread, NULL);
free(thread);
}
void ohmd_destroy_mutex(ohmd_mutex* mutex)
{
pthread_mutex_destroy((pthread_mutex_t*)mutex);
free(mutex);
}
void ohmd_lock_mutex(ohmd_mutex* mutex)
{
if(mutex)
pthread_mutex_lock((pthread_mutex_t*)mutex);
}
void ohmd_unlock_mutex(ohmd_mutex* mutex)
{
if(mutex)
pthread_mutex_unlock((pthread_mutex_t*)mutex);
}
/// Handling ovr service
void ohmd_toggle_ovr_service(int state) //State is 0 for Disable, 1 for Enable
{
//Empty implementation
}
#endif

144
extern/openhmd/src/platform-win32.c vendored Normal file
View File

@@ -0,0 +1,144 @@
/*
* OpenHMD - Free and Open Source API and drivers for immersive technology.
* Copyright (C) 2013 Fredrik Hultin.
* Copyright (C) 2013 Jakob Bornecrantz.
* Distributed under the Boost 1.0 licence, see LICENSE for full text.
*/
/* Platform Specific Functions, Win32 Implementation */
#ifdef _WIN32
#define WIN32_LEAN_AND_MEAN
#define WIN32_EXTRA_LEAN
#include <windows.h>
#include "platform.h"
#include "openhmdi.h"
double ohmd_get_tick()
{
double high, low;
FILETIME filetime;
GetSystemTimeAsFileTime(&filetime);
high = filetime.dwHighDateTime;
low = filetime.dwLowDateTime;
return (high * 4294967296.0 + low) / 10000000;
}
// TODO higher resolution
void ohmd_sleep(double seconds)
{
Sleep((DWORD)(seconds * 1000));
}
// threads
struct ohmd_thread {
HANDLE handle;
void* arg;
unsigned int (*routine)(void* arg);
};
struct ohmd_mutex {
HANDLE handle;
};
DWORD __stdcall ohmd_thread_wrapper(void* t)
{
ohmd_thread* thread = (ohmd_thread*)t;
return thread->routine(thread->arg);
}
ohmd_thread* ohmd_create_thread(ohmd_context* ctx, unsigned int (*routine)(void* arg), void* arg)
{
ohmd_thread* thread = ohmd_alloc(ctx, sizeof(ohmd_thread));
if(!thread)
return NULL;
thread->routine = routine;
thread->arg = arg;
thread->handle = CreateThread(NULL, 0, ohmd_thread_wrapper, thread, 0, NULL);
return thread;
}
void ohmd_destroy_thread(ohmd_thread* thread)
{
ohmd_sleep(3);
WaitForSingleObject(thread->handle, INFINITE);
CloseHandle(thread->handle);
free(thread);
}
ohmd_mutex* ohmd_create_mutex(ohmd_context* ctx)
{
ohmd_mutex* mutex = ohmd_alloc(ctx, sizeof(ohmd_mutex));
if(!mutex)
return NULL;
mutex->handle = CreateMutex(NULL, FALSE, NULL);
return mutex;
}
void ohmd_destroy_mutex(ohmd_mutex* mutex)
{
CloseHandle(mutex->handle);
free(mutex);
}
void ohmd_lock_mutex(ohmd_mutex* mutex)
{
if(mutex)
WaitForSingleObject(mutex->handle, INFINITE);
}
void ohmd_unlock_mutex(ohmd_mutex* mutex)
{
if(mutex)
ReleaseMutex(mutex->handle);
}
/// Handling ovr service
static int _enable_ovr_service = 0;
void ohmd_toggle_ovr_service(int state) //State is 0 for Disable, 1 for Enable
{
SC_HANDLE serviceDbHandle = OpenSCManager(NULL,NULL,SC_MANAGER_ALL_ACCESS);
SC_HANDLE serviceHandle = OpenService(serviceDbHandle, "OVRService", SC_MANAGER_ALL_ACCESS);
SERVICE_STATUS_PROCESS status;
DWORD bytesNeeded;
QueryServiceStatusEx(serviceHandle, SC_STATUS_PROCESS_INFO,(LPBYTE) &status,sizeof(SERVICE_STATUS_PROCESS), &bytesNeeded);
if (state == 0 || status.dwCurrentState == SERVICE_RUNNING)
{
// Stop it
BOOL b = ControlService(serviceHandle, SERVICE_CONTROL_STOP, (LPSERVICE_STATUS) &status);
if (b)
{
printf("OVRService stopped\n");
_enable_ovr_service = 1;
}
else
printf("Error: OVRService failed to stop, please try running with Administrator rights\n");
}
else if (state == 1 && _enable_ovr_service)
{
// Start it
BOOL b = StartService(serviceHandle, NULL, NULL);
if (b)
printf("OVRService started\n");
else
printf("Error: OVRService failed to start, please try running with Administrator rights\n");
}
CloseServiceHandle(serviceHandle);
CloseServiceHandle(serviceDbHandle);
}
#endif

32
extern/openhmd/src/platform.h vendored Normal file
View File

@@ -0,0 +1,32 @@
/*
* OpenHMD - Free and Open Source API and drivers for immersive technology.
* Copyright (C) 2013 Fredrik Hultin.
* Copyright (C) 2013 Jakob Bornecrantz.
* Distributed under the Boost 1.0 licence, see LICENSE for full text.
*/
/* Internal Interface for Platform Specific Functions */
#ifndef PLATFORM_H
#define PLATFORM_H
#include "openhmd.h"
double ohmd_get_tick();
void ohmd_sleep(double seconds);
void ohmd_toggle_ovr_service(int state);
typedef struct ohmd_thread ohmd_thread;
typedef struct ohmd_mutex ohmd_mutex;
ohmd_mutex* ohmd_create_mutex(ohmd_context* ctx);
void ohmd_destroy_mutex(ohmd_mutex* mutex);
void ohmd_lock_mutex(ohmd_mutex* mutex);
void ohmd_unlock_mutex(ohmd_mutex* mutex);
ohmd_thread* ohmd_create_thread(ohmd_context* ctx, unsigned int (*routine)(void* arg), void* arg);
void ohmd_destroy_thread(ohmd_thread* thread);
#endif

97
extern/openhmd/src/queue.c vendored Normal file
View File

@@ -0,0 +1,97 @@
/*
* OpenHMD - Free and Open Source API and drivers for immersive technology.
* Copyright (C) 2016 Fredrik Hultin.
* Distributed under the Boost 1.0 licence, see LICENSE for full text.
*/
/* Naive Thread Safe Circular Queue Implementation */
#include <stdlib.h>
#include <string.h>
#include "queue.h"
#include "openhmdi.h"
struct ohmdq {
unsigned read_pos;
unsigned write_pos;
unsigned size;
unsigned max;
unsigned elem_size;
char* elems;
ohmd_mutex* mutex;
};
ohmdq* ohmdq_create(ohmd_context* ctx, unsigned elem_size, unsigned max)
{
ohmdq* me = ohmd_alloc(ctx, sizeof(ohmdq));
me->elems = ohmd_alloc(ctx, elem_size * max);
me->max = max;
me->elem_size = elem_size;
me->read_pos = 0;
me->write_pos = 0;
me->size = 0;
me->mutex = ohmd_create_mutex(ctx);
return me;
}
bool ohmdq_push(ohmdq* me, const void* elem)
{
bool ret = false;
ohmd_lock_mutex(me->mutex);
if(me->size < me->max){
memcpy(me->elems + me->write_pos, elem, me->elem_size);
me->write_pos = (me->write_pos + me->elem_size) % (me->max * me->elem_size);
me->size++;
ret = true;
}
ohmd_unlock_mutex(me->mutex);
return ret;
}
bool ohmdq_pop(ohmdq* me, void* out_elem)
{
bool ret = false;
ohmd_lock_mutex(me->mutex);
if(me->size > 0){
memcpy(out_elem, me->elems + me->read_pos, me->elem_size);
me->read_pos = (me->read_pos + me->elem_size) % (me->max * me->elem_size);
me->size--;
ret = true;
}
ohmd_unlock_mutex(me->mutex);
return ret;
}
unsigned ohmdq_get_size(ohmdq* me)
{
unsigned ret;
ohmd_lock_mutex(me->mutex);
ret = me->size;
ohmd_unlock_mutex(me->mutex);
return ret;
}
unsigned ohmdq_get_max(ohmdq* me)
{
return me->max;
}
void ohmdq_destroy(ohmdq* me)
{
free(me->elems);
ohmd_destroy_mutex(me->mutex);
free(me);
}

25
extern/openhmd/src/queue.h vendored Normal file
View File

@@ -0,0 +1,25 @@
/*
* OpenHMD - Free and Open Source API and drivers for immersive technology.
* Copyright (C) 2016 Fredrik Hultin.
* Distributed under the Boost 1.0 licence, see LICENSE for full text.
*/
/* Naive Thread Safe Circular Queue */
#ifndef OHMDQUEUE_H
#define OHMDQUEUE_H
#include <stdbool.h>
typedef struct ohmdq ohmdq;
typedef struct ohmd_context ohmd_context;
ohmdq* ohmdq_create(ohmd_context* ctx, unsigned elem_size, unsigned max);
void ohmdq_destroy(ohmdq* me);
bool ohmdq_push(ohmdq* me, const void* elem);
bool ohmdq_pop(ohmdq* me, void* out_elem);
unsigned ohmdq_get_size(ohmdq* me);
unsigned ohmdq_get_max(ohmdq* me);
#endif

55
extern/openhmd/src/shaders.c vendored Normal file
View File

@@ -0,0 +1,55 @@
const char * distortion_vert =
"#version 120\n"
"void main(void)\n"
"{\n"
"gl_TexCoord[0] = gl_MultiTexCoord0;\n"
"gl_Position = gl_ProjectionMatrix * gl_ModelViewMatrix * gl_Vertex;\n"
"}";
const char * distortion_frag =
"#version 120\n"
"\n"
"//per eye texture to warp for lens distortion\n"
"uniform sampler2D warpTexture;\n"
"\n"
"//Position of lens center in m (usually eye_w/2, eye_h/2)\n"
"uniform vec2 LensCenter;\n"
"//Scale from texture co-ords to m (usually eye_w, eye_h)\n"
"uniform vec2 ViewportScale;\n"
"//Distortion overall scale in m (usually ~eye_w/2)\n"
"uniform float WarpScale;\n"
"//Distoriton coefficients (PanoTools model) [a,b,c,d]\n"
"uniform vec4 HmdWarpParam;\n"
"\n"
"//chromatic distortion post scaling\n"
"uniform vec3 aberr;\n"
"\n"
"void main()\n"
"{\n"
"//output_loc is the fragment location on screen from [0,1]x[0,1]\n"
"vec2 output_loc = vec2(gl_TexCoord[0].s, gl_TexCoord[0].t);\n"
"//Compute fragment location in lens-centered co-ordinates at world scale\n"
"vec2 r = output_loc * ViewportScale - LensCenter;\n"
"//scale for distortion model\n"
"//distortion model has r=1 being the largest circle inscribed (e.g. eye_w/2)\n"
"r /= WarpScale;\n"
"\n"
"//|r|**2\n"
"float r_mag = length(r);\n"
"//offset for which fragment is sourced\n"
"vec2 r_displaced = r * (HmdWarpParam.w + HmdWarpParam.z * r_mag +\n"
"HmdWarpParam.y * r_mag * r_mag +\n"
"HmdWarpParam.x * r_mag * r_mag * r_mag);\n"
"//back to world scale\n"
"r_displaced *= WarpScale;\n"
"//back to viewport co-ord\n"
"vec2 tc_r = (LensCenter + aberr.r * r_displaced) / ViewportScale;\n"
"vec2 tc_g = (LensCenter + aberr.g * r_displaced) / ViewportScale;\n"
"vec2 tc_b = (LensCenter + aberr.b * r_displaced) / ViewportScale;\n"
"\n"
"float red = texture2D(warpTexture, tc_r).r;\n"
"float green = texture2D(warpTexture, tc_g).g;\n"
"float blue = texture2D(warpTexture, tc_b).b;\n"
"//Black edges off the texture\n"
"gl_FragColor = ((tc_g.x < 0.0) || (tc_g.x > 1.0) || (tc_g.y < 0.0) || (tc_g.y > 1.0)) ? vec4(0.0, 0.0, 0.0, 1.0) : vec4(red, green, blue, 1.0);\n"
"}";

6
extern/openhmd/src/shaders.h vendored Normal file
View File

@@ -0,0 +1,6 @@
#ifndef SHADERS_H
#define SHADERS_H
const char * distortion_vert;
const char * distortion_frag;
#endif /* SHADERS_H */

38
extern/udew/CMakeLists.txt vendored Normal file
View File

@@ -0,0 +1,38 @@
# ***** BEGIN GPL LICENSE BLOCK *****
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; either version 2
# of the License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software Foundation,
# Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
#
# The Original Code is Copyright (C) 2016, Blender Foundation
# All rights reserved.
#
# Contributor(s): Sergey Sharybin.
#
# ***** END GPL LICENSE BLOCK *****
set(INC
.
include
)
set(INC_SYS
)
set(SRC
include/udew.h
src/udew.c
)
blender_add_lib(extern_udew "${SRC}" "${INC}" "${INC_SYS}")

174
extern/udew/LICENSE vendored Normal file
View File

@@ -0,0 +1,174 @@
Modified Apache 2.0 License
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
and its affiliates, except as required to comply with Section 4(c) of
the License and to reproduce 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.

14
extern/udew/README vendored Normal file
View File

@@ -0,0 +1,14 @@
The udev Extension Wrangler Library (UDEW) is a cross-platform open-source
C/C++ extension loading library. UDEW provides efficient run-time mechanisms
for determining which udev functions and extensions extensions are supported
on the target platform.
LICENSE
UDEW library is released under the Apache 2.0 license.
LIMITATIONS
- udev_device_get_parent_with_subsystem_devtype() need to be merged to a single
line in the geader before generating the wrangler with stubs support
- udev_set_log_fn() is not included into the stubs at all.

205
extern/udew/auto/libudev.h vendored Normal file
View File

@@ -0,0 +1,205 @@
/***
This file is part of systemd.
Copyright 2008-2012 Kay Sievers <kay@vrfy.org>
systemd is free software; you can redistribute it and/or modify it
under the terms of the GNU Lesser General Public License as published by
the Free Software Foundation; either version 2.1 of the License, or
(at your option) any later version.
systemd 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
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public License
along with systemd; If not, see <http://www.gnu.org/licenses/>.
***/
#ifndef _LIBUDEV_H_
#define _LIBUDEV_H_
#include <stdarg.h>
#include <sys/types.h>
#ifdef __cplusplus
extern "C" {
#endif
/*
* udev - library context
*
* reads the udev config and system environment
* allows custom logging
*/
struct udev;
struct udev *udev_ref(struct udev *udev);
struct udev *udev_unref(struct udev *udev);
struct udev *udev_new(void);
void udev_set_log_fn(struct udev *udev,
void (*log_fn)(struct udev *udev,
int priority, const char *file, int line, const char *fn,
const char *format, va_list args)) __attribute__ ((deprecated));
int udev_get_log_priority(struct udev *udev) __attribute__ ((deprecated));
void udev_set_log_priority(struct udev *udev, int priority) __attribute__ ((deprecated));
void *udev_get_userdata(struct udev *udev);
void udev_set_userdata(struct udev *udev, void *userdata);
/*
* udev_list
*
* access to libudev generated lists
*/
struct udev_list_entry;
struct udev_list_entry *udev_list_entry_get_next(struct udev_list_entry *list_entry);
struct udev_list_entry *udev_list_entry_get_by_name(struct udev_list_entry *list_entry, const char *name);
const char *udev_list_entry_get_name(struct udev_list_entry *list_entry);
const char *udev_list_entry_get_value(struct udev_list_entry *list_entry);
/**
* udev_list_entry_foreach:
* @list_entry: entry to store the current position
* @first_entry: first entry to start with
*
* Helper to iterate over all entries of a list.
*/
#define udev_list_entry_foreach(list_entry, first_entry) \
for (list_entry = first_entry; \
list_entry != NULL; \
list_entry = udev_list_entry_get_next(list_entry))
/*
* udev_device
*
* access to sysfs/kernel devices
*/
struct udev_device;
struct udev_device *udev_device_ref(struct udev_device *udev_device);
struct udev_device *udev_device_unref(struct udev_device *udev_device);
struct udev *udev_device_get_udev(struct udev_device *udev_device);
struct udev_device *udev_device_new_from_syspath(struct udev *udev, const char *syspath);
struct udev_device *udev_device_new_from_devnum(struct udev *udev, char type, dev_t devnum);
struct udev_device *udev_device_new_from_subsystem_sysname(struct udev *udev, const char *subsystem, const char *sysname);
struct udev_device *udev_device_new_from_device_id(struct udev *udev, const char *id);
struct udev_device *udev_device_new_from_environment(struct udev *udev);
/* udev_device_get_parent_*() does not take a reference on the returned device, it is automatically unref'd with the parent */
struct udev_device *udev_device_get_parent(struct udev_device *udev_device);
struct udev_device *udev_device_get_parent_with_subsystem_devtype(struct udev_device *udev_device, const char *subsystem, const char *devtype);
/* retrieve device properties */
const char *udev_device_get_devpath(struct udev_device *udev_device);
const char *udev_device_get_subsystem(struct udev_device *udev_device);
const char *udev_device_get_devtype(struct udev_device *udev_device);
const char *udev_device_get_syspath(struct udev_device *udev_device);
const char *udev_device_get_sysname(struct udev_device *udev_device);
const char *udev_device_get_sysnum(struct udev_device *udev_device);
const char *udev_device_get_devnode(struct udev_device *udev_device);
int udev_device_get_is_initialized(struct udev_device *udev_device);
struct udev_list_entry *udev_device_get_devlinks_list_entry(struct udev_device *udev_device);
struct udev_list_entry *udev_device_get_properties_list_entry(struct udev_device *udev_device);
struct udev_list_entry *udev_device_get_tags_list_entry(struct udev_device *udev_device);
struct udev_list_entry *udev_device_get_sysattr_list_entry(struct udev_device *udev_device);
const char *udev_device_get_property_value(struct udev_device *udev_device, const char *key);
const char *udev_device_get_driver(struct udev_device *udev_device);
dev_t udev_device_get_devnum(struct udev_device *udev_device);
const char *udev_device_get_action(struct udev_device *udev_device);
unsigned long long int udev_device_get_seqnum(struct udev_device *udev_device);
unsigned long long int udev_device_get_usec_since_initialized(struct udev_device *udev_device);
const char *udev_device_get_sysattr_value(struct udev_device *udev_device, const char *sysattr);
int udev_device_set_sysattr_value(struct udev_device *udev_device, const char *sysattr, char *value);
int udev_device_has_tag(struct udev_device *udev_device, const char *tag);
/*
* udev_monitor
*
* access to kernel uevents and udev events
*/
struct udev_monitor;
struct udev_monitor *udev_monitor_ref(struct udev_monitor *udev_monitor);
struct udev_monitor *udev_monitor_unref(struct udev_monitor *udev_monitor);
struct udev *udev_monitor_get_udev(struct udev_monitor *udev_monitor);
/* kernel and udev generated events over netlink */
struct udev_monitor *udev_monitor_new_from_netlink(struct udev *udev, const char *name);
/* bind socket */
int udev_monitor_enable_receiving(struct udev_monitor *udev_monitor);
int udev_monitor_set_receive_buffer_size(struct udev_monitor *udev_monitor, int size);
int udev_monitor_get_fd(struct udev_monitor *udev_monitor);
struct udev_device *udev_monitor_receive_device(struct udev_monitor *udev_monitor);
/* in-kernel socket filters to select messages that get delivered to a listener */
int udev_monitor_filter_add_match_subsystem_devtype(struct udev_monitor *udev_monitor,
const char *subsystem, const char *devtype);
int udev_monitor_filter_add_match_tag(struct udev_monitor *udev_monitor, const char *tag);
int udev_monitor_filter_update(struct udev_monitor *udev_monitor);
int udev_monitor_filter_remove(struct udev_monitor *udev_monitor);
/*
* udev_enumerate
*
* search sysfs for specific devices and provide a sorted list
*/
struct udev_enumerate;
struct udev_enumerate *udev_enumerate_ref(struct udev_enumerate *udev_enumerate);
struct udev_enumerate *udev_enumerate_unref(struct udev_enumerate *udev_enumerate);
struct udev *udev_enumerate_get_udev(struct udev_enumerate *udev_enumerate);
struct udev_enumerate *udev_enumerate_new(struct udev *udev);
/* device properties filter */
int udev_enumerate_add_match_subsystem(struct udev_enumerate *udev_enumerate, const char *subsystem);
int udev_enumerate_add_nomatch_subsystem(struct udev_enumerate *udev_enumerate, const char *subsystem);
int udev_enumerate_add_match_sysattr(struct udev_enumerate *udev_enumerate, const char *sysattr, const char *value);
int udev_enumerate_add_nomatch_sysattr(struct udev_enumerate *udev_enumerate, const char *sysattr, const char *value);
int udev_enumerate_add_match_property(struct udev_enumerate *udev_enumerate, const char *property, const char *value);
int udev_enumerate_add_match_sysname(struct udev_enumerate *udev_enumerate, const char *sysname);
int udev_enumerate_add_match_tag(struct udev_enumerate *udev_enumerate, const char *tag);
int udev_enumerate_add_match_parent(struct udev_enumerate *udev_enumerate, struct udev_device *parent);
int udev_enumerate_add_match_is_initialized(struct udev_enumerate *udev_enumerate);
int udev_enumerate_add_syspath(struct udev_enumerate *udev_enumerate, const char *syspath);
/* run enumeration with active filters */
int udev_enumerate_scan_devices(struct udev_enumerate *udev_enumerate);
int udev_enumerate_scan_subsystems(struct udev_enumerate *udev_enumerate);
/* return device list */
struct udev_list_entry *udev_enumerate_get_list_entry(struct udev_enumerate *udev_enumerate);
/*
* udev_queue
*
* access to the currently running udev events
*/
struct udev_queue;
struct udev_queue *udev_queue_ref(struct udev_queue *udev_queue);
struct udev_queue *udev_queue_unref(struct udev_queue *udev_queue);
struct udev *udev_queue_get_udev(struct udev_queue *udev_queue);
struct udev_queue *udev_queue_new(struct udev *udev);
unsigned long long int udev_queue_get_kernel_seqnum(struct udev_queue *udev_queue) __attribute__ ((deprecated));
unsigned long long int udev_queue_get_udev_seqnum(struct udev_queue *udev_queue) __attribute__ ((deprecated));
int udev_queue_get_udev_is_active(struct udev_queue *udev_queue);
int udev_queue_get_queue_is_empty(struct udev_queue *udev_queue);
int udev_queue_get_seqnum_is_finished(struct udev_queue *udev_queue, unsigned long long int seqnum) __attribute__ ((deprecated));
int udev_queue_get_seqnum_sequence_is_finished(struct udev_queue *udev_queue,
unsigned long long int start, unsigned long long int end) __attribute__ ((deprecated));
int udev_queue_get_fd(struct udev_queue *udev_queue);
int udev_queue_flush(struct udev_queue *udev_queue);
struct udev_list_entry *udev_queue_get_queued_list_entry(struct udev_queue *udev_queue) __attribute__ ((deprecated));
/*
* udev_hwdb
*
* access to the static hardware properties database
*/
struct udev_hwdb;
struct udev_hwdb *udev_hwdb_new(struct udev *udev);
struct udev_hwdb *udev_hwdb_ref(struct udev_hwdb *hwdb);
struct udev_hwdb *udev_hwdb_unref(struct udev_hwdb *hwdb);
struct udev_list_entry *udev_hwdb_get_properties_list_entry(struct udev_hwdb *hwdb, const char *modalias, unsigned int flags);
/*
* udev_util
*
* udev specific utilities
*/
int udev_util_encode_string(const char *str, char *str_enc, size_t len);
#ifdef __cplusplus
} /* extern "C" */
#endif
#endif

245
extern/udew/auto/udew_gen.sh vendored Executable file
View File

@@ -0,0 +1,245 @@
#!/bin/bash
#HEADER="/usr/include/libudev.h"
HEADER="libudev.h"
SCRIPT=`realpath -s $0`
DIR=`dirname $SCRIPT`
DIR=`dirname $DIR`
H="$DIR/include/udew.h"
C=$DIR/src/udew.c
STUBS=true
mkdir -p $DIR/include
mkdir -p $DIR/src
rm -rf $DIR/include/udew.h
rm -rf $DIR/src/udew.c
echo "Generating udew headers..."
append() {
f=`echo "$1" | sed ':a;N;$!ba;s/\n/\\\\n/g'`
line_num=`grep -n '#ifdef __cplusplus' $H | cut -d : -f 1 | tail -n 1`
gawk -i inplace "NR==$line_num {\$0=\"$f\n\n#ifdef __cplusplus\"} 1" $H
}
cat $HEADER \
| sed -r 's/^((const )?[a-z0-9_]+( [a-z0-9_]+)* \*?)([a-z0-9_]+)\(/typedef \1t\4(/i' \
> $H
if $STUBS; then
fp="_";
fi
f=`grep -E 'typedef ((const )?[a-z0-9_]+( [a-z0-9_]+)* \*?)t([a-z0-9_]+)\(' $H \
| sed -r "s/((const )?[a-z0-9_]+( [a-z0-9_]+)* \*?)t([a-z0-9_]+)\(.*/extern t\4 *$fp\4;/i"`
append "$f"
append "enum {\n\
UDEW_SUCCESS = 0,\n\
UDEW_ERROR_OPEN_FAILED = -1,\n\
UDEW_ERROR_ATEXIT_FAILED = -2,\n\
};\n\
\n\
int udewInit(void);"
if $STUBS; then
decl=`cat $HEADER \
| grep -E '^((const )?[a-z0-9_]+( [a-z0-9_]+)* \*?)([a-z0-9_]+)\(.*\);'`
append "$decl"
fi
sed -i 's/_LIBUDEV_H_/__UDEW_H__/g' $H
sed -i 's/ __attribute__ ((deprecated))//g' $H
line_num=`grep -n '\*\*\*/' $H | cut -d : -f 1`
for x in `seq $line_num`; do
sed -i '1d' $H
done
mv $H $H.tmp
cat << EOF > $H
/*
* Copyright 2016 Blender Foundation
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License
*/
EOF
cat $H.tmp >> $H
rm $H.tmp
echo "Generating udew source..."
cat << EOF > $C
/*
* Copyright 2016 Blender Foundation
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License
*/
#ifdef _MSC_VER
# define snprintf _snprintf
# define popen _popen
# define pclose _pclose
# define _CRT_SECURE_NO_WARNINGS
#endif
#include "udew.h"
#include <assert.h>
#include <stdio.h>
#include <string.h>
#include <sys/stat.h>
#include <stdlib.h>
#ifdef _WIN32
# define WIN32_LEAN_AND_MEAN
# define VC_EXTRALEAN
# include <windows.h>
/* Utility macros. */
typedef HMODULE DynamicLibrary;
# define dynamic_library_open(path) LoadLibrary(path)
# define dynamic_library_close(lib) FreeLibrary(lib)
# define dynamic_library_find(lib, symbol) GetProcAddress(lib, symbol)
#else
# include <dlfcn.h>
typedef void* DynamicLibrary;
# define dynamic_library_open(path) dlopen(path, RTLD_NOW)
# define dynamic_library_close(lib) dlclose(lib)
# define dynamic_library_find(lib, symbol) dlsym(lib, symbol)
#endif
#define GLUE(a, b) a ## b
#define UDEV_LIBRARY_FIND_CHECKED(name) \
GLUE(${fp}, name) = (t##name *)dynamic_library_find(lib, #name); \
assert(GLUE(${fp}, name));
#define UDEV_LIBRARY_FIND(name) \
GLUE(${fp}, name) = (t##name *)dynamic_library_find(lib, #name);
static DynamicLibrary lib;
EOF
content=`grep --no-filename -ER "extern t" $DIR/include/udew.h`
echo "$content" | sed -r "s/extern t([a-z0-9_]+).*/t\1 *$fp\1;/gi" >> $C
cat << EOF >> $C
static DynamicLibrary dynamic_library_open_find(const char **paths) {
int i = 0;
while (paths[i] != NULL) {
DynamicLibrary lib = dynamic_library_open(paths[i]);
if (lib != NULL) {
return lib;
}
++i;
}
return NULL;
}
static void udewExit(void) {
if(lib != NULL) {
/* Ignore errors. */
dynamic_library_close(lib);
lib = NULL;
}
}
/* Implementation function. */
int udewInit(void) {
/* Library paths. */
#ifdef _WIN32
/* Expected in c:/windows/system or similar, no path needed. */
const char *paths[] = {"udev.dll", NULL};
#elif defined(__APPLE__)
/* Default installation path. */
const char *paths[] = {"libudev.dylib", NULL};
#else
const char *paths[] = {"libudev.so",
"libudev.so.0",
"libudev.so.1",
"libudev.so.2",
NULL};
#endif
static int initialized = 0;
static int result = 0;
int error;
if (initialized) {
return result;
}
initialized = 1;
error = atexit(udewExit);
if (error) {
result = UDEW_ERROR_ATEXIT_FAILED;
return result;
}
/* Load library. */
lib = dynamic_library_open_find(paths);
if (lib == NULL) {
result = UDEW_ERROR_OPEN_FAILED;
return result;
}
EOF
echo "$content" | sed -r 's/extern t([a-z0-9_]+).*/ UDEV_LIBRARY_FIND(\1);/gi' >> $C
cat << EOF >> $C
result = UDEW_SUCCESS;
return result;
}
EOF
if $STUBS; then
echo "" >> $C
echo "$decl" | while read l; do
h=`echo "$l" | sed -r 's/;//' | sed 's/ __attribute__ ((deprecated))//'`
echo "$h {" >> $C
f=`echo $h | sed -r 's/^((const )?[a-z0-9_]+( [a-z0-9_]+)* \*?)([a-z0-9_]+)\(.*/\4/i'`
args=`echo $h | sed -r 's/^((const )?[a-z0-9_]+( [a-z0-9_]+)* \*?)([a-z0-9_]+)\((.*)\).*?/\5/i'`
args=`echo $args | python -c "import sys; l=sys.stdin.readline(); l=l.strip(); print(', '.join([x.split(' ')[-1].replace('*', '') for x in l.split(',')]))"`
if [ "$args" = "void" ]; then
args=""
fi
echo " return $fp$f($args);" >> $C
echo -e "}\n" >> $C
done
fi

389
extern/udew/include/udew.h vendored Normal file
View File

@@ -0,0 +1,389 @@
/*
* Copyright 2016 Blender Foundation
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License
*/
#ifndef __UDEW_H__
#define __UDEW_H__
#include <stdarg.h>
#include <sys/types.h>
#ifdef __cplusplus
extern "C" {
#endif
/*
* udev - library context
*
* reads the udev config and system environment
* allows custom logging
*/
struct udev;
typedef struct udev *tudev_ref(struct udev *udev);
typedef struct udev *tudev_unref(struct udev *udev);
typedef struct udev *tudev_new(void);
typedef void tudev_set_log_fn(struct udev *udev,
void (*log_fn)(struct udev *udev,
int priority, const char *file, int line, const char *fn,
const char *format, va_list args));
typedef int tudev_get_log_priority(struct udev *udev);
typedef void tudev_set_log_priority(struct udev *udev, int priority);
typedef void *tudev_get_userdata(struct udev *udev);
typedef void tudev_set_userdata(struct udev *udev, void *userdata);
/*
* udev_list
*
* access to libudev generated lists
*/
struct udev_list_entry;
typedef struct udev_list_entry *tudev_list_entry_get_next(struct udev_list_entry *list_entry);
typedef struct udev_list_entry *tudev_list_entry_get_by_name(struct udev_list_entry *list_entry, const char *name);
typedef const char *tudev_list_entry_get_name(struct udev_list_entry *list_entry);
typedef const char *tudev_list_entry_get_value(struct udev_list_entry *list_entry);
/**
* udev_list_entry_foreach:
* @list_entry: entry to store the current position
* @first_entry: first entry to start with
*
* Helper to iterate over all entries of a list.
*/
#define udev_list_entry_foreach(list_entry, first_entry) \
for (list_entry = first_entry; \
list_entry != NULL; \
list_entry = udev_list_entry_get_next(list_entry))
/*
* udev_device
*
* access to sysfs/kernel devices
*/
struct udev_device;
typedef struct udev_device *tudev_device_ref(struct udev_device *udev_device);
typedef struct udev_device *tudev_device_unref(struct udev_device *udev_device);
typedef struct udev *tudev_device_get_udev(struct udev_device *udev_device);
typedef struct udev_device *tudev_device_new_from_syspath(struct udev *udev, const char *syspath);
typedef struct udev_device *tudev_device_new_from_devnum(struct udev *udev, char type, dev_t devnum);
typedef struct udev_device *tudev_device_new_from_subsystem_sysname(struct udev *udev, const char *subsystem, const char *sysname);
typedef struct udev_device *tudev_device_new_from_device_id(struct udev *udev, const char *id);
typedef struct udev_device *tudev_device_new_from_environment(struct udev *udev);
/* udev_device_get_parent_*() does not take a reference on the returned device, it is automatically unref'd with the parent */
typedef struct udev_device *tudev_device_get_parent(struct udev_device *udev_device);
typedef struct udev_device *tudev_device_get_parent_with_subsystem_devtype(struct udev_device *udev_device, const char *subsystem, const char *devtype);
/* retrieve device properties */
typedef const char *tudev_device_get_devpath(struct udev_device *udev_device);
typedef const char *tudev_device_get_subsystem(struct udev_device *udev_device);
typedef const char *tudev_device_get_devtype(struct udev_device *udev_device);
typedef const char *tudev_device_get_syspath(struct udev_device *udev_device);
typedef const char *tudev_device_get_sysname(struct udev_device *udev_device);
typedef const char *tudev_device_get_sysnum(struct udev_device *udev_device);
typedef const char *tudev_device_get_devnode(struct udev_device *udev_device);
typedef int tudev_device_get_is_initialized(struct udev_device *udev_device);
typedef struct udev_list_entry *tudev_device_get_devlinks_list_entry(struct udev_device *udev_device);
typedef struct udev_list_entry *tudev_device_get_properties_list_entry(struct udev_device *udev_device);
typedef struct udev_list_entry *tudev_device_get_tags_list_entry(struct udev_device *udev_device);
typedef struct udev_list_entry *tudev_device_get_sysattr_list_entry(struct udev_device *udev_device);
typedef const char *tudev_device_get_property_value(struct udev_device *udev_device, const char *key);
typedef const char *tudev_device_get_driver(struct udev_device *udev_device);
typedef dev_t tudev_device_get_devnum(struct udev_device *udev_device);
typedef const char *tudev_device_get_action(struct udev_device *udev_device);
typedef unsigned long long int tudev_device_get_seqnum(struct udev_device *udev_device);
typedef unsigned long long int tudev_device_get_usec_since_initialized(struct udev_device *udev_device);
typedef const char *tudev_device_get_sysattr_value(struct udev_device *udev_device, const char *sysattr);
typedef int tudev_device_set_sysattr_value(struct udev_device *udev_device, const char *sysattr, char *value);
typedef int tudev_device_has_tag(struct udev_device *udev_device, const char *tag);
/*
* udev_monitor
*
* access to kernel uevents and udev events
*/
struct udev_monitor;
typedef struct udev_monitor *tudev_monitor_ref(struct udev_monitor *udev_monitor);
typedef struct udev_monitor *tudev_monitor_unref(struct udev_monitor *udev_monitor);
typedef struct udev *tudev_monitor_get_udev(struct udev_monitor *udev_monitor);
/* kernel and udev generated events over netlink */
typedef struct udev_monitor *tudev_monitor_new_from_netlink(struct udev *udev, const char *name);
/* bind socket */
typedef int tudev_monitor_enable_receiving(struct udev_monitor *udev_monitor);
typedef int tudev_monitor_set_receive_buffer_size(struct udev_monitor *udev_monitor, int size);
typedef int tudev_monitor_get_fd(struct udev_monitor *udev_monitor);
typedef struct udev_device *tudev_monitor_receive_device(struct udev_monitor *udev_monitor);
/* in-kernel socket filters to select messages that get delivered to a listener */
typedef int tudev_monitor_filter_add_match_subsystem_devtype(struct udev_monitor *udev_monitor,
const char *subsystem, const char *devtype);
typedef int tudev_monitor_filter_add_match_tag(struct udev_monitor *udev_monitor, const char *tag);
typedef int tudev_monitor_filter_update(struct udev_monitor *udev_monitor);
typedef int tudev_monitor_filter_remove(struct udev_monitor *udev_monitor);
/*
* udev_enumerate
*
* search sysfs for specific devices and provide a sorted list
*/
struct udev_enumerate;
typedef struct udev_enumerate *tudev_enumerate_ref(struct udev_enumerate *udev_enumerate);
typedef struct udev_enumerate *tudev_enumerate_unref(struct udev_enumerate *udev_enumerate);
typedef struct udev *tudev_enumerate_get_udev(struct udev_enumerate *udev_enumerate);
typedef struct udev_enumerate *tudev_enumerate_new(struct udev *udev);
/* device properties filter */
typedef int tudev_enumerate_add_match_subsystem(struct udev_enumerate *udev_enumerate, const char *subsystem);
typedef int tudev_enumerate_add_nomatch_subsystem(struct udev_enumerate *udev_enumerate, const char *subsystem);
typedef int tudev_enumerate_add_match_sysattr(struct udev_enumerate *udev_enumerate, const char *sysattr, const char *value);
typedef int tudev_enumerate_add_nomatch_sysattr(struct udev_enumerate *udev_enumerate, const char *sysattr, const char *value);
typedef int tudev_enumerate_add_match_property(struct udev_enumerate *udev_enumerate, const char *property, const char *value);
typedef int tudev_enumerate_add_match_sysname(struct udev_enumerate *udev_enumerate, const char *sysname);
typedef int tudev_enumerate_add_match_tag(struct udev_enumerate *udev_enumerate, const char *tag);
typedef int tudev_enumerate_add_match_parent(struct udev_enumerate *udev_enumerate, struct udev_device *parent);
typedef int tudev_enumerate_add_match_is_initialized(struct udev_enumerate *udev_enumerate);
typedef int tudev_enumerate_add_syspath(struct udev_enumerate *udev_enumerate, const char *syspath);
/* run enumeration with active filters */
typedef int tudev_enumerate_scan_devices(struct udev_enumerate *udev_enumerate);
typedef int tudev_enumerate_scan_subsystems(struct udev_enumerate *udev_enumerate);
/* return device list */
typedef struct udev_list_entry *tudev_enumerate_get_list_entry(struct udev_enumerate *udev_enumerate);
/*
* udev_queue
*
* access to the currently running udev events
*/
struct udev_queue;
typedef struct udev_queue *tudev_queue_ref(struct udev_queue *udev_queue);
typedef struct udev_queue *tudev_queue_unref(struct udev_queue *udev_queue);
typedef struct udev *tudev_queue_get_udev(struct udev_queue *udev_queue);
typedef struct udev_queue *tudev_queue_new(struct udev *udev);
typedef unsigned long long int tudev_queue_get_kernel_seqnum(struct udev_queue *udev_queue);
typedef unsigned long long int tudev_queue_get_udev_seqnum(struct udev_queue *udev_queue);
typedef int tudev_queue_get_udev_is_active(struct udev_queue *udev_queue);
typedef int tudev_queue_get_queue_is_empty(struct udev_queue *udev_queue);
typedef int tudev_queue_get_seqnum_is_finished(struct udev_queue *udev_queue, unsigned long long int seqnum);
typedef int tudev_queue_get_seqnum_sequence_is_finished(struct udev_queue *udev_queue,
unsigned long long int start, unsigned long long int end);
typedef int tudev_queue_get_fd(struct udev_queue *udev_queue);
typedef int tudev_queue_flush(struct udev_queue *udev_queue);
typedef struct udev_list_entry *tudev_queue_get_queued_list_entry(struct udev_queue *udev_queue);
/*
* udev_hwdb
*
* access to the static hardware properties database
*/
struct udev_hwdb;
typedef struct udev_hwdb *tudev_hwdb_new(struct udev *udev);
typedef struct udev_hwdb *tudev_hwdb_ref(struct udev_hwdb *hwdb);
typedef struct udev_hwdb *tudev_hwdb_unref(struct udev_hwdb *hwdb);
typedef struct udev_list_entry *tudev_hwdb_get_properties_list_entry(struct udev_hwdb *hwdb, const char *modalias, unsigned int flags);
/*
* udev_util
*
* udev specific utilities
*/
typedef int tudev_util_encode_string(const char *str, char *str_enc, size_t len);
extern tudev_ref *_udev_ref;
extern tudev_unref *_udev_unref;
extern tudev_new *_udev_new;
extern tudev_set_log_fn *_udev_set_log_fn;
extern tudev_get_log_priority *_udev_get_log_priority;
extern tudev_set_log_priority *_udev_set_log_priority;
extern tudev_get_userdata *_udev_get_userdata;
extern tudev_set_userdata *_udev_set_userdata;
extern tudev_list_entry_get_next *_udev_list_entry_get_next;
extern tudev_list_entry_get_by_name *_udev_list_entry_get_by_name;
extern tudev_list_entry_get_name *_udev_list_entry_get_name;
extern tudev_list_entry_get_value *_udev_list_entry_get_value;
extern tudev_device_ref *_udev_device_ref;
extern tudev_device_unref *_udev_device_unref;
extern tudev_device_get_udev *_udev_device_get_udev;
extern tudev_device_new_from_syspath *_udev_device_new_from_syspath;
extern tudev_device_new_from_devnum *_udev_device_new_from_devnum;
extern tudev_device_new_from_subsystem_sysname *_udev_device_new_from_subsystem_sysname;
extern tudev_device_new_from_device_id *_udev_device_new_from_device_id;
extern tudev_device_new_from_environment *_udev_device_new_from_environment;
extern tudev_device_get_parent *_udev_device_get_parent;
extern tudev_device_get_parent_with_subsystem_devtype *_udev_device_get_parent_with_subsystem_devtype;
extern tudev_device_get_devpath *_udev_device_get_devpath;
extern tudev_device_get_subsystem *_udev_device_get_subsystem;
extern tudev_device_get_devtype *_udev_device_get_devtype;
extern tudev_device_get_syspath *_udev_device_get_syspath;
extern tudev_device_get_sysname *_udev_device_get_sysname;
extern tudev_device_get_sysnum *_udev_device_get_sysnum;
extern tudev_device_get_devnode *_udev_device_get_devnode;
extern tudev_device_get_is_initialized *_udev_device_get_is_initialized;
extern tudev_device_get_devlinks_list_entry *_udev_device_get_devlinks_list_entry;
extern tudev_device_get_properties_list_entry *_udev_device_get_properties_list_entry;
extern tudev_device_get_tags_list_entry *_udev_device_get_tags_list_entry;
extern tudev_device_get_sysattr_list_entry *_udev_device_get_sysattr_list_entry;
extern tudev_device_get_property_value *_udev_device_get_property_value;
extern tudev_device_get_driver *_udev_device_get_driver;
extern tudev_device_get_devnum *_udev_device_get_devnum;
extern tudev_device_get_action *_udev_device_get_action;
extern tudev_device_get_seqnum *_udev_device_get_seqnum;
extern tudev_device_get_usec_since_initialized *_udev_device_get_usec_since_initialized;
extern tudev_device_get_sysattr_value *_udev_device_get_sysattr_value;
extern tudev_device_set_sysattr_value *_udev_device_set_sysattr_value;
extern tudev_device_has_tag *_udev_device_has_tag;
extern tudev_monitor_ref *_udev_monitor_ref;
extern tudev_monitor_unref *_udev_monitor_unref;
extern tudev_monitor_get_udev *_udev_monitor_get_udev;
extern tudev_monitor_new_from_netlink *_udev_monitor_new_from_netlink;
extern tudev_monitor_enable_receiving *_udev_monitor_enable_receiving;
extern tudev_monitor_set_receive_buffer_size *_udev_monitor_set_receive_buffer_size;
extern tudev_monitor_get_fd *_udev_monitor_get_fd;
extern tudev_monitor_receive_device *_udev_monitor_receive_device;
extern tudev_monitor_filter_add_match_subsystem_devtype *_udev_monitor_filter_add_match_subsystem_devtype;
extern tudev_monitor_filter_add_match_tag *_udev_monitor_filter_add_match_tag;
extern tudev_monitor_filter_update *_udev_monitor_filter_update;
extern tudev_monitor_filter_remove *_udev_monitor_filter_remove;
extern tudev_enumerate_ref *_udev_enumerate_ref;
extern tudev_enumerate_unref *_udev_enumerate_unref;
extern tudev_enumerate_get_udev *_udev_enumerate_get_udev;
extern tudev_enumerate_new *_udev_enumerate_new;
extern tudev_enumerate_add_match_subsystem *_udev_enumerate_add_match_subsystem;
extern tudev_enumerate_add_nomatch_subsystem *_udev_enumerate_add_nomatch_subsystem;
extern tudev_enumerate_add_match_sysattr *_udev_enumerate_add_match_sysattr;
extern tudev_enumerate_add_nomatch_sysattr *_udev_enumerate_add_nomatch_sysattr;
extern tudev_enumerate_add_match_property *_udev_enumerate_add_match_property;
extern tudev_enumerate_add_match_sysname *_udev_enumerate_add_match_sysname;
extern tudev_enumerate_add_match_tag *_udev_enumerate_add_match_tag;
extern tudev_enumerate_add_match_parent *_udev_enumerate_add_match_parent;
extern tudev_enumerate_add_match_is_initialized *_udev_enumerate_add_match_is_initialized;
extern tudev_enumerate_add_syspath *_udev_enumerate_add_syspath;
extern tudev_enumerate_scan_devices *_udev_enumerate_scan_devices;
extern tudev_enumerate_scan_subsystems *_udev_enumerate_scan_subsystems;
extern tudev_enumerate_get_list_entry *_udev_enumerate_get_list_entry;
extern tudev_queue_ref *_udev_queue_ref;
extern tudev_queue_unref *_udev_queue_unref;
extern tudev_queue_get_udev *_udev_queue_get_udev;
extern tudev_queue_new *_udev_queue_new;
extern tudev_queue_get_kernel_seqnum *_udev_queue_get_kernel_seqnum;
extern tudev_queue_get_udev_seqnum *_udev_queue_get_udev_seqnum;
extern tudev_queue_get_udev_is_active *_udev_queue_get_udev_is_active;
extern tudev_queue_get_queue_is_empty *_udev_queue_get_queue_is_empty;
extern tudev_queue_get_seqnum_is_finished *_udev_queue_get_seqnum_is_finished;
extern tudev_queue_get_seqnum_sequence_is_finished *_udev_queue_get_seqnum_sequence_is_finished;
extern tudev_queue_get_fd *_udev_queue_get_fd;
extern tudev_queue_flush *_udev_queue_flush;
extern tudev_queue_get_queued_list_entry *_udev_queue_get_queued_list_entry;
extern tudev_hwdb_new *_udev_hwdb_new;
extern tudev_hwdb_ref *_udev_hwdb_ref;
extern tudev_hwdb_unref *_udev_hwdb_unref;
extern tudev_hwdb_get_properties_list_entry *_udev_hwdb_get_properties_list_entry;
extern tudev_util_encode_string *_udev_util_encode_string;
enum {
UDEW_SUCCESS = 0,
UDEW_ERROR_OPEN_FAILED = -1,
UDEW_ERROR_ATEXIT_FAILED = -2,
};
int udewInit(void);
struct udev *udev_ref(struct udev *udev);
struct udev *udev_unref(struct udev *udev);
struct udev *udev_new(void);
int udev_get_log_priority(struct udev *udev);
void udev_set_log_priority(struct udev *udev, int priority);
void *udev_get_userdata(struct udev *udev);
void udev_set_userdata(struct udev *udev, void *userdata);
struct udev_list_entry *udev_list_entry_get_next(struct udev_list_entry *list_entry);
struct udev_list_entry *udev_list_entry_get_by_name(struct udev_list_entry *list_entry, const char *name);
const char *udev_list_entry_get_name(struct udev_list_entry *list_entry);
const char *udev_list_entry_get_value(struct udev_list_entry *list_entry);
struct udev_device *udev_device_ref(struct udev_device *udev_device);
struct udev_device *udev_device_unref(struct udev_device *udev_device);
struct udev *udev_device_get_udev(struct udev_device *udev_device);
struct udev_device *udev_device_new_from_syspath(struct udev *udev, const char *syspath);
struct udev_device *udev_device_new_from_devnum(struct udev *udev, char type, dev_t devnum);
struct udev_device *udev_device_new_from_subsystem_sysname(struct udev *udev, const char *subsystem, const char *sysname);
struct udev_device *udev_device_new_from_device_id(struct udev *udev, const char *id);
struct udev_device *udev_device_new_from_environment(struct udev *udev);
struct udev_device *udev_device_get_parent(struct udev_device *udev_device);
struct udev_device *udev_device_get_parent_with_subsystem_devtype(struct udev_device *udev_device, const char *subsystem, const char *devtype);
const char *udev_device_get_devpath(struct udev_device *udev_device);
const char *udev_device_get_subsystem(struct udev_device *udev_device);
const char *udev_device_get_devtype(struct udev_device *udev_device);
const char *udev_device_get_syspath(struct udev_device *udev_device);
const char *udev_device_get_sysname(struct udev_device *udev_device);
const char *udev_device_get_sysnum(struct udev_device *udev_device);
const char *udev_device_get_devnode(struct udev_device *udev_device);
int udev_device_get_is_initialized(struct udev_device *udev_device);
struct udev_list_entry *udev_device_get_devlinks_list_entry(struct udev_device *udev_device);
struct udev_list_entry *udev_device_get_properties_list_entry(struct udev_device *udev_device);
struct udev_list_entry *udev_device_get_tags_list_entry(struct udev_device *udev_device);
struct udev_list_entry *udev_device_get_sysattr_list_entry(struct udev_device *udev_device);
const char *udev_device_get_property_value(struct udev_device *udev_device, const char *key);
const char *udev_device_get_driver(struct udev_device *udev_device);
dev_t udev_device_get_devnum(struct udev_device *udev_device);
const char *udev_device_get_action(struct udev_device *udev_device);
unsigned long long int udev_device_get_seqnum(struct udev_device *udev_device);
unsigned long long int udev_device_get_usec_since_initialized(struct udev_device *udev_device);
const char *udev_device_get_sysattr_value(struct udev_device *udev_device, const char *sysattr);
int udev_device_set_sysattr_value(struct udev_device *udev_device, const char *sysattr, char *value);
int udev_device_has_tag(struct udev_device *udev_device, const char *tag);
struct udev_monitor *udev_monitor_ref(struct udev_monitor *udev_monitor);
struct udev_monitor *udev_monitor_unref(struct udev_monitor *udev_monitor);
struct udev *udev_monitor_get_udev(struct udev_monitor *udev_monitor);
struct udev_monitor *udev_monitor_new_from_netlink(struct udev *udev, const char *name);
int udev_monitor_enable_receiving(struct udev_monitor *udev_monitor);
int udev_monitor_set_receive_buffer_size(struct udev_monitor *udev_monitor, int size);
int udev_monitor_get_fd(struct udev_monitor *udev_monitor);
struct udev_device *udev_monitor_receive_device(struct udev_monitor *udev_monitor);
int udev_monitor_filter_add_match_tag(struct udev_monitor *udev_monitor, const char *tag);
int udev_monitor_filter_update(struct udev_monitor *udev_monitor);
int udev_monitor_filter_remove(struct udev_monitor *udev_monitor);
struct udev_enumerate *udev_enumerate_ref(struct udev_enumerate *udev_enumerate);
struct udev_enumerate *udev_enumerate_unref(struct udev_enumerate *udev_enumerate);
struct udev *udev_enumerate_get_udev(struct udev_enumerate *udev_enumerate);
struct udev_enumerate *udev_enumerate_new(struct udev *udev);
int udev_enumerate_add_match_subsystem(struct udev_enumerate *udev_enumerate, const char *subsystem);
int udev_enumerate_add_nomatch_subsystem(struct udev_enumerate *udev_enumerate, const char *subsystem);
int udev_enumerate_add_match_sysattr(struct udev_enumerate *udev_enumerate, const char *sysattr, const char *value);
int udev_enumerate_add_nomatch_sysattr(struct udev_enumerate *udev_enumerate, const char *sysattr, const char *value);
int udev_enumerate_add_match_property(struct udev_enumerate *udev_enumerate, const char *property, const char *value);
int udev_enumerate_add_match_sysname(struct udev_enumerate *udev_enumerate, const char *sysname);
int udev_enumerate_add_match_tag(struct udev_enumerate *udev_enumerate, const char *tag);
int udev_enumerate_add_match_parent(struct udev_enumerate *udev_enumerate, struct udev_device *parent);
int udev_enumerate_add_match_is_initialized(struct udev_enumerate *udev_enumerate);
int udev_enumerate_add_syspath(struct udev_enumerate *udev_enumerate, const char *syspath);
int udev_enumerate_scan_devices(struct udev_enumerate *udev_enumerate);
int udev_enumerate_scan_subsystems(struct udev_enumerate *udev_enumerate);
struct udev_list_entry *udev_enumerate_get_list_entry(struct udev_enumerate *udev_enumerate);
struct udev_queue *udev_queue_ref(struct udev_queue *udev_queue);
struct udev_queue *udev_queue_unref(struct udev_queue *udev_queue);
struct udev *udev_queue_get_udev(struct udev_queue *udev_queue);
struct udev_queue *udev_queue_new(struct udev *udev);
unsigned long long int udev_queue_get_kernel_seqnum(struct udev_queue *udev_queue);
unsigned long long int udev_queue_get_udev_seqnum(struct udev_queue *udev_queue);
int udev_queue_get_udev_is_active(struct udev_queue *udev_queue);
int udev_queue_get_queue_is_empty(struct udev_queue *udev_queue);
int udev_queue_get_seqnum_is_finished(struct udev_queue *udev_queue, unsigned long long int seqnum);
int udev_queue_get_fd(struct udev_queue *udev_queue);
int udev_queue_flush(struct udev_queue *udev_queue);
struct udev_list_entry *udev_queue_get_queued_list_entry(struct udev_queue *udev_queue);
struct udev_hwdb *udev_hwdb_new(struct udev *udev);
struct udev_hwdb *udev_hwdb_ref(struct udev_hwdb *hwdb);
struct udev_hwdb *udev_hwdb_unref(struct udev_hwdb *hwdb);
struct udev_list_entry *udev_hwdb_get_properties_list_entry(struct udev_hwdb *hwdb, const char *modalias, unsigned int flags);
int udev_util_encode_string(const char *str, char *str_enc, size_t len);
#ifdef __cplusplus
} /* extern "C" */
#endif
#endif

656
extern/udew/src/udew.c vendored Normal file
View File

@@ -0,0 +1,656 @@
/*
* Copyright 2016 Blender Foundation
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License
*/
#ifdef _MSC_VER
# define snprintf _snprintf
# define popen _popen
# define pclose _pclose
# define _CRT_SECURE_NO_WARNINGS
#endif
#include "udew.h"
#include <assert.h>
#include <stdio.h>
#include <string.h>
#include <sys/stat.h>
#include <stdlib.h>
#ifdef _WIN32
# define WIN32_LEAN_AND_MEAN
# define VC_EXTRALEAN
# include <windows.h>
/* Utility macros. */
typedef HMODULE DynamicLibrary;
# define dynamic_library_open(path) LoadLibrary(path)
# define dynamic_library_close(lib) FreeLibrary(lib)
# define dynamic_library_find(lib, symbol) GetProcAddress(lib, symbol)
#else
# include <dlfcn.h>
typedef void* DynamicLibrary;
# define dynamic_library_open(path) dlopen(path, RTLD_NOW)
# define dynamic_library_close(lib) dlclose(lib)
# define dynamic_library_find(lib, symbol) dlsym(lib, symbol)
#endif
#define GLUE(a, b) a ## b
#define UDEV_LIBRARY_FIND_CHECKED(name) GLUE(_, name) = (t##name *)dynamic_library_find(lib, #name); assert(GLUE(_, name));
#define UDEV_LIBRARY_FIND(name) GLUE(_, name) = (t##name *)dynamic_library_find(lib, #name);
static DynamicLibrary lib;
tudev_ref *_udev_ref;
tudev_unref *_udev_unref;
tudev_new *_udev_new;
tudev_set_log_fn *_udev_set_log_fn;
tudev_get_log_priority *_udev_get_log_priority;
tudev_set_log_priority *_udev_set_log_priority;
tudev_get_userdata *_udev_get_userdata;
tudev_set_userdata *_udev_set_userdata;
tudev_list_entry_get_next *_udev_list_entry_get_next;
tudev_list_entry_get_by_name *_udev_list_entry_get_by_name;
tudev_list_entry_get_name *_udev_list_entry_get_name;
tudev_list_entry_get_value *_udev_list_entry_get_value;
tudev_device_ref *_udev_device_ref;
tudev_device_unref *_udev_device_unref;
tudev_device_get_udev *_udev_device_get_udev;
tudev_device_new_from_syspath *_udev_device_new_from_syspath;
tudev_device_new_from_devnum *_udev_device_new_from_devnum;
tudev_device_new_from_subsystem_sysname *_udev_device_new_from_subsystem_sysname;
tudev_device_new_from_device_id *_udev_device_new_from_device_id;
tudev_device_new_from_environment *_udev_device_new_from_environment;
tudev_device_get_parent *_udev_device_get_parent;
tudev_device_get_parent_with_subsystem_devtype *_udev_device_get_parent_with_subsystem_devtype;
tudev_device_get_devpath *_udev_device_get_devpath;
tudev_device_get_subsystem *_udev_device_get_subsystem;
tudev_device_get_devtype *_udev_device_get_devtype;
tudev_device_get_syspath *_udev_device_get_syspath;
tudev_device_get_sysname *_udev_device_get_sysname;
tudev_device_get_sysnum *_udev_device_get_sysnum;
tudev_device_get_devnode *_udev_device_get_devnode;
tudev_device_get_is_initialized *_udev_device_get_is_initialized;
tudev_device_get_devlinks_list_entry *_udev_device_get_devlinks_list_entry;
tudev_device_get_properties_list_entry *_udev_device_get_properties_list_entry;
tudev_device_get_tags_list_entry *_udev_device_get_tags_list_entry;
tudev_device_get_sysattr_list_entry *_udev_device_get_sysattr_list_entry;
tudev_device_get_property_value *_udev_device_get_property_value;
tudev_device_get_driver *_udev_device_get_driver;
tudev_device_get_devnum *_udev_device_get_devnum;
tudev_device_get_action *_udev_device_get_action;
tudev_device_get_seqnum *_udev_device_get_seqnum;
tudev_device_get_usec_since_initialized *_udev_device_get_usec_since_initialized;
tudev_device_get_sysattr_value *_udev_device_get_sysattr_value;
tudev_device_set_sysattr_value *_udev_device_set_sysattr_value;
tudev_device_has_tag *_udev_device_has_tag;
tudev_monitor_ref *_udev_monitor_ref;
tudev_monitor_unref *_udev_monitor_unref;
tudev_monitor_get_udev *_udev_monitor_get_udev;
tudev_monitor_new_from_netlink *_udev_monitor_new_from_netlink;
tudev_monitor_enable_receiving *_udev_monitor_enable_receiving;
tudev_monitor_set_receive_buffer_size *_udev_monitor_set_receive_buffer_size;
tudev_monitor_get_fd *_udev_monitor_get_fd;
tudev_monitor_receive_device *_udev_monitor_receive_device;
tudev_monitor_filter_add_match_subsystem_devtype *_udev_monitor_filter_add_match_subsystem_devtype;
tudev_monitor_filter_add_match_tag *_udev_monitor_filter_add_match_tag;
tudev_monitor_filter_update *_udev_monitor_filter_update;
tudev_monitor_filter_remove *_udev_monitor_filter_remove;
tudev_enumerate_ref *_udev_enumerate_ref;
tudev_enumerate_unref *_udev_enumerate_unref;
tudev_enumerate_get_udev *_udev_enumerate_get_udev;
tudev_enumerate_new *_udev_enumerate_new;
tudev_enumerate_add_match_subsystem *_udev_enumerate_add_match_subsystem;
tudev_enumerate_add_nomatch_subsystem *_udev_enumerate_add_nomatch_subsystem;
tudev_enumerate_add_match_sysattr *_udev_enumerate_add_match_sysattr;
tudev_enumerate_add_nomatch_sysattr *_udev_enumerate_add_nomatch_sysattr;
tudev_enumerate_add_match_property *_udev_enumerate_add_match_property;
tudev_enumerate_add_match_sysname *_udev_enumerate_add_match_sysname;
tudev_enumerate_add_match_tag *_udev_enumerate_add_match_tag;
tudev_enumerate_add_match_parent *_udev_enumerate_add_match_parent;
tudev_enumerate_add_match_is_initialized *_udev_enumerate_add_match_is_initialized;
tudev_enumerate_add_syspath *_udev_enumerate_add_syspath;
tudev_enumerate_scan_devices *_udev_enumerate_scan_devices;
tudev_enumerate_scan_subsystems *_udev_enumerate_scan_subsystems;
tudev_enumerate_get_list_entry *_udev_enumerate_get_list_entry;
tudev_queue_ref *_udev_queue_ref;
tudev_queue_unref *_udev_queue_unref;
tudev_queue_get_udev *_udev_queue_get_udev;
tudev_queue_new *_udev_queue_new;
tudev_queue_get_kernel_seqnum *_udev_queue_get_kernel_seqnum;
tudev_queue_get_udev_seqnum *_udev_queue_get_udev_seqnum;
tudev_queue_get_udev_is_active *_udev_queue_get_udev_is_active;
tudev_queue_get_queue_is_empty *_udev_queue_get_queue_is_empty;
tudev_queue_get_seqnum_is_finished *_udev_queue_get_seqnum_is_finished;
tudev_queue_get_seqnum_sequence_is_finished *_udev_queue_get_seqnum_sequence_is_finished;
tudev_queue_get_fd *_udev_queue_get_fd;
tudev_queue_flush *_udev_queue_flush;
tudev_queue_get_queued_list_entry *_udev_queue_get_queued_list_entry;
tudev_hwdb_new *_udev_hwdb_new;
tudev_hwdb_ref *_udev_hwdb_ref;
tudev_hwdb_unref *_udev_hwdb_unref;
tudev_hwdb_get_properties_list_entry *_udev_hwdb_get_properties_list_entry;
tudev_util_encode_string *_udev_util_encode_string;
static DynamicLibrary dynamic_library_open_find(const char **paths) {
int i = 0;
while (paths[i] != NULL) {
DynamicLibrary lib = dynamic_library_open(paths[i]);
if (lib != NULL) {
return lib;
}
++i;
}
return NULL;
}
static void udewExit(void) {
if(lib != NULL) {
/* Ignore errors. */
dynamic_library_close(lib);
lib = NULL;
}
}
/* Implementation function. */
int udewInit(void) {
/* Library paths. */
#ifdef _WIN32
/* Expected in c:/windows/system or similar, no path needed. */
const char *paths[] = {"udev.dll", NULL};
#elif defined(__APPLE__)
/* Default installation path. */
const char *paths[] = {"libudev.dylib", NULL};
#else
const char *paths[] = {"libudev.so",
"libudev.so.0",
"libudev.so.1",
"libudev.so.2",
NULL};
#endif
static int initialized = 0;
static int result = 0;
int error;
if (initialized) {
return result;
}
initialized = 1;
error = atexit(udewExit);
if (error) {
result = UDEW_ERROR_ATEXIT_FAILED;
return result;
}
/* Load library. */
lib = dynamic_library_open_find(paths);
if (lib == NULL) {
result = UDEW_ERROR_OPEN_FAILED;
return result;
}
UDEV_LIBRARY_FIND(udev_ref);
UDEV_LIBRARY_FIND(udev_unref);
UDEV_LIBRARY_FIND(udev_new);
UDEV_LIBRARY_FIND(udev_set_log_fn);
UDEV_LIBRARY_FIND(udev_get_log_priority);
UDEV_LIBRARY_FIND(udev_set_log_priority);
UDEV_LIBRARY_FIND(udev_get_userdata);
UDEV_LIBRARY_FIND(udev_set_userdata);
UDEV_LIBRARY_FIND(udev_list_entry_get_next);
UDEV_LIBRARY_FIND(udev_list_entry_get_by_name);
UDEV_LIBRARY_FIND(udev_list_entry_get_name);
UDEV_LIBRARY_FIND(udev_list_entry_get_value);
UDEV_LIBRARY_FIND(udev_device_ref);
UDEV_LIBRARY_FIND(udev_device_unref);
UDEV_LIBRARY_FIND(udev_device_get_udev);
UDEV_LIBRARY_FIND(udev_device_new_from_syspath);
UDEV_LIBRARY_FIND(udev_device_new_from_devnum);
UDEV_LIBRARY_FIND(udev_device_new_from_subsystem_sysname);
UDEV_LIBRARY_FIND(udev_device_new_from_device_id);
UDEV_LIBRARY_FIND(udev_device_new_from_environment);
UDEV_LIBRARY_FIND(udev_device_get_parent);
UDEV_LIBRARY_FIND(udev_device_get_parent_with_subsystem_devtype);
UDEV_LIBRARY_FIND(udev_device_get_devpath);
UDEV_LIBRARY_FIND(udev_device_get_subsystem);
UDEV_LIBRARY_FIND(udev_device_get_devtype);
UDEV_LIBRARY_FIND(udev_device_get_syspath);
UDEV_LIBRARY_FIND(udev_device_get_sysname);
UDEV_LIBRARY_FIND(udev_device_get_sysnum);
UDEV_LIBRARY_FIND(udev_device_get_devnode);
UDEV_LIBRARY_FIND(udev_device_get_is_initialized);
UDEV_LIBRARY_FIND(udev_device_get_devlinks_list_entry);
UDEV_LIBRARY_FIND(udev_device_get_properties_list_entry);
UDEV_LIBRARY_FIND(udev_device_get_tags_list_entry);
UDEV_LIBRARY_FIND(udev_device_get_sysattr_list_entry);
UDEV_LIBRARY_FIND(udev_device_get_property_value);
UDEV_LIBRARY_FIND(udev_device_get_driver);
UDEV_LIBRARY_FIND(udev_device_get_devnum);
UDEV_LIBRARY_FIND(udev_device_get_action);
UDEV_LIBRARY_FIND(udev_device_get_seqnum);
UDEV_LIBRARY_FIND(udev_device_get_usec_since_initialized);
UDEV_LIBRARY_FIND(udev_device_get_sysattr_value);
UDEV_LIBRARY_FIND(udev_device_set_sysattr_value);
UDEV_LIBRARY_FIND(udev_device_has_tag);
UDEV_LIBRARY_FIND(udev_monitor_ref);
UDEV_LIBRARY_FIND(udev_monitor_unref);
UDEV_LIBRARY_FIND(udev_monitor_get_udev);
UDEV_LIBRARY_FIND(udev_monitor_new_from_netlink);
UDEV_LIBRARY_FIND(udev_monitor_enable_receiving);
UDEV_LIBRARY_FIND(udev_monitor_set_receive_buffer_size);
UDEV_LIBRARY_FIND(udev_monitor_get_fd);
UDEV_LIBRARY_FIND(udev_monitor_receive_device);
UDEV_LIBRARY_FIND(udev_monitor_filter_add_match_subsystem_devtype);
UDEV_LIBRARY_FIND(udev_monitor_filter_add_match_tag);
UDEV_LIBRARY_FIND(udev_monitor_filter_update);
UDEV_LIBRARY_FIND(udev_monitor_filter_remove);
UDEV_LIBRARY_FIND(udev_enumerate_ref);
UDEV_LIBRARY_FIND(udev_enumerate_unref);
UDEV_LIBRARY_FIND(udev_enumerate_get_udev);
UDEV_LIBRARY_FIND(udev_enumerate_new);
UDEV_LIBRARY_FIND(udev_enumerate_add_match_subsystem);
UDEV_LIBRARY_FIND(udev_enumerate_add_nomatch_subsystem);
UDEV_LIBRARY_FIND(udev_enumerate_add_match_sysattr);
UDEV_LIBRARY_FIND(udev_enumerate_add_nomatch_sysattr);
UDEV_LIBRARY_FIND(udev_enumerate_add_match_property);
UDEV_LIBRARY_FIND(udev_enumerate_add_match_sysname);
UDEV_LIBRARY_FIND(udev_enumerate_add_match_tag);
UDEV_LIBRARY_FIND(udev_enumerate_add_match_parent);
UDEV_LIBRARY_FIND(udev_enumerate_add_match_is_initialized);
UDEV_LIBRARY_FIND(udev_enumerate_add_syspath);
UDEV_LIBRARY_FIND(udev_enumerate_scan_devices);
UDEV_LIBRARY_FIND(udev_enumerate_scan_subsystems);
UDEV_LIBRARY_FIND(udev_enumerate_get_list_entry);
UDEV_LIBRARY_FIND(udev_queue_ref);
UDEV_LIBRARY_FIND(udev_queue_unref);
UDEV_LIBRARY_FIND(udev_queue_get_udev);
UDEV_LIBRARY_FIND(udev_queue_new);
UDEV_LIBRARY_FIND(udev_queue_get_kernel_seqnum);
UDEV_LIBRARY_FIND(udev_queue_get_udev_seqnum);
UDEV_LIBRARY_FIND(udev_queue_get_udev_is_active);
UDEV_LIBRARY_FIND(udev_queue_get_queue_is_empty);
UDEV_LIBRARY_FIND(udev_queue_get_seqnum_is_finished);
UDEV_LIBRARY_FIND(udev_queue_get_seqnum_sequence_is_finished);
UDEV_LIBRARY_FIND(udev_queue_get_fd);
UDEV_LIBRARY_FIND(udev_queue_flush);
UDEV_LIBRARY_FIND(udev_queue_get_queued_list_entry);
UDEV_LIBRARY_FIND(udev_hwdb_new);
UDEV_LIBRARY_FIND(udev_hwdb_ref);
UDEV_LIBRARY_FIND(udev_hwdb_unref);
UDEV_LIBRARY_FIND(udev_hwdb_get_properties_list_entry);
UDEV_LIBRARY_FIND(udev_util_encode_string);
result = UDEW_SUCCESS;
return result;
}
struct udev *udev_ref(struct udev *udev) {
return _udev_ref(udev);
}
struct udev *udev_unref(struct udev *udev) {
return _udev_unref(udev);
}
struct udev *udev_new(void) {
return _udev_new();
}
int udev_get_log_priority(struct udev *udev) {
return _udev_get_log_priority(udev);
}
void udev_set_log_priority(struct udev *udev, int priority) {
return _udev_set_log_priority(udev, priority);
}
void *udev_get_userdata(struct udev *udev) {
return _udev_get_userdata(udev);
}
void udev_set_userdata(struct udev *udev, void *userdata) {
return _udev_set_userdata(udev, userdata);
}
struct udev_list_entry *udev_list_entry_get_next(struct udev_list_entry *list_entry) {
return _udev_list_entry_get_next(list_entry);
}
struct udev_list_entry *udev_list_entry_get_by_name(struct udev_list_entry *list_entry, const char *name) {
return _udev_list_entry_get_by_name(list_entry, name);
}
const char *udev_list_entry_get_name(struct udev_list_entry *list_entry) {
return _udev_list_entry_get_name(list_entry);
}
const char *udev_list_entry_get_value(struct udev_list_entry *list_entry) {
return _udev_list_entry_get_value(list_entry);
}
struct udev_device *udev_device_ref(struct udev_device *udev_device) {
return _udev_device_ref(udev_device);
}
struct udev_device *udev_device_unref(struct udev_device *udev_device) {
return _udev_device_unref(udev_device);
}
struct udev *udev_device_get_udev(struct udev_device *udev_device) {
return _udev_device_get_udev(udev_device);
}
struct udev_device *udev_device_new_from_syspath(struct udev *udev, const char *syspath) {
return _udev_device_new_from_syspath(udev, syspath);
}
struct udev_device *udev_device_new_from_devnum(struct udev *udev, char type, dev_t devnum) {
return _udev_device_new_from_devnum(udev, type, devnum);
}
struct udev_device *udev_device_new_from_subsystem_sysname(struct udev *udev, const char *subsystem, const char *sysname) {
return _udev_device_new_from_subsystem_sysname(udev, subsystem, sysname);
}
struct udev_device *udev_device_new_from_device_id(struct udev *udev, const char *id) {
return _udev_device_new_from_device_id(udev, id);
}
struct udev_device *udev_device_new_from_environment(struct udev *udev) {
return _udev_device_new_from_environment(udev);
}
struct udev_device *udev_device_get_parent(struct udev_device *udev_device) {
return _udev_device_get_parent(udev_device);
}
struct udev_device *udev_device_get_parent_with_subsystem_devtype(struct udev_device *udev_device, const char *subsystem, const char *devtype) {
return _udev_device_get_parent_with_subsystem_devtype(udev_device, subsystem, devtype);
}
const char *udev_device_get_devpath(struct udev_device *udev_device) {
return _udev_device_get_devpath(udev_device);
}
const char *udev_device_get_subsystem(struct udev_device *udev_device) {
return _udev_device_get_subsystem(udev_device);
}
const char *udev_device_get_devtype(struct udev_device *udev_device) {
return _udev_device_get_devtype(udev_device);
}
const char *udev_device_get_syspath(struct udev_device *udev_device) {
return _udev_device_get_syspath(udev_device);
}
const char *udev_device_get_sysname(struct udev_device *udev_device) {
return _udev_device_get_sysname(udev_device);
}
const char *udev_device_get_sysnum(struct udev_device *udev_device) {
return _udev_device_get_sysnum(udev_device);
}
const char *udev_device_get_devnode(struct udev_device *udev_device) {
return _udev_device_get_devnode(udev_device);
}
int udev_device_get_is_initialized(struct udev_device *udev_device) {
return _udev_device_get_is_initialized(udev_device);
}
struct udev_list_entry *udev_device_get_devlinks_list_entry(struct udev_device *udev_device) {
return _udev_device_get_devlinks_list_entry(udev_device);
}
struct udev_list_entry *udev_device_get_properties_list_entry(struct udev_device *udev_device) {
return _udev_device_get_properties_list_entry(udev_device);
}
struct udev_list_entry *udev_device_get_tags_list_entry(struct udev_device *udev_device) {
return _udev_device_get_tags_list_entry(udev_device);
}
struct udev_list_entry *udev_device_get_sysattr_list_entry(struct udev_device *udev_device) {
return _udev_device_get_sysattr_list_entry(udev_device);
}
const char *udev_device_get_property_value(struct udev_device *udev_device, const char *key) {
return _udev_device_get_property_value(udev_device, key);
}
const char *udev_device_get_driver(struct udev_device *udev_device) {
return _udev_device_get_driver(udev_device);
}
dev_t udev_device_get_devnum(struct udev_device *udev_device) {
return _udev_device_get_devnum(udev_device);
}
const char *udev_device_get_action(struct udev_device *udev_device) {
return _udev_device_get_action(udev_device);
}
unsigned long long int udev_device_get_seqnum(struct udev_device *udev_device) {
return _udev_device_get_seqnum(udev_device);
}
unsigned long long int udev_device_get_usec_since_initialized(struct udev_device *udev_device) {
return _udev_device_get_usec_since_initialized(udev_device);
}
const char *udev_device_get_sysattr_value(struct udev_device *udev_device, const char *sysattr) {
return _udev_device_get_sysattr_value(udev_device, sysattr);
}
int udev_device_set_sysattr_value(struct udev_device *udev_device, const char *sysattr, char *value) {
return _udev_device_set_sysattr_value(udev_device, sysattr, value);
}
int udev_device_has_tag(struct udev_device *udev_device, const char *tag) {
return _udev_device_has_tag(udev_device, tag);
}
struct udev_monitor *udev_monitor_ref(struct udev_monitor *udev_monitor) {
return _udev_monitor_ref(udev_monitor);
}
struct udev_monitor *udev_monitor_unref(struct udev_monitor *udev_monitor) {
return _udev_monitor_unref(udev_monitor);
}
struct udev *udev_monitor_get_udev(struct udev_monitor *udev_monitor) {
return _udev_monitor_get_udev(udev_monitor);
}
struct udev_monitor *udev_monitor_new_from_netlink(struct udev *udev, const char *name) {
return _udev_monitor_new_from_netlink(udev, name);
}
int udev_monitor_enable_receiving(struct udev_monitor *udev_monitor) {
return _udev_monitor_enable_receiving(udev_monitor);
}
int udev_monitor_set_receive_buffer_size(struct udev_monitor *udev_monitor, int size) {
return _udev_monitor_set_receive_buffer_size(udev_monitor, size);
}
int udev_monitor_get_fd(struct udev_monitor *udev_monitor) {
return _udev_monitor_get_fd(udev_monitor);
}
struct udev_device *udev_monitor_receive_device(struct udev_monitor *udev_monitor) {
return _udev_monitor_receive_device(udev_monitor);
}
int udev_monitor_filter_add_match_tag(struct udev_monitor *udev_monitor, const char *tag) {
return _udev_monitor_filter_add_match_tag(udev_monitor, tag);
}
int udev_monitor_filter_update(struct udev_monitor *udev_monitor) {
return _udev_monitor_filter_update(udev_monitor);
}
int udev_monitor_filter_remove(struct udev_monitor *udev_monitor) {
return _udev_monitor_filter_remove(udev_monitor);
}
struct udev_enumerate *udev_enumerate_ref(struct udev_enumerate *udev_enumerate) {
return _udev_enumerate_ref(udev_enumerate);
}
struct udev_enumerate *udev_enumerate_unref(struct udev_enumerate *udev_enumerate) {
return _udev_enumerate_unref(udev_enumerate);
}
struct udev *udev_enumerate_get_udev(struct udev_enumerate *udev_enumerate) {
return _udev_enumerate_get_udev(udev_enumerate);
}
struct udev_enumerate *udev_enumerate_new(struct udev *udev) {
return _udev_enumerate_new(udev);
}
int udev_enumerate_add_match_subsystem(struct udev_enumerate *udev_enumerate, const char *subsystem) {
return _udev_enumerate_add_match_subsystem(udev_enumerate, subsystem);
}
int udev_enumerate_add_nomatch_subsystem(struct udev_enumerate *udev_enumerate, const char *subsystem) {
return _udev_enumerate_add_nomatch_subsystem(udev_enumerate, subsystem);
}
int udev_enumerate_add_match_sysattr(struct udev_enumerate *udev_enumerate, const char *sysattr, const char *value) {
return _udev_enumerate_add_match_sysattr(udev_enumerate, sysattr, value);
}
int udev_enumerate_add_nomatch_sysattr(struct udev_enumerate *udev_enumerate, const char *sysattr, const char *value) {
return _udev_enumerate_add_nomatch_sysattr(udev_enumerate, sysattr, value);
}
int udev_enumerate_add_match_property(struct udev_enumerate *udev_enumerate, const char *property, const char *value) {
return _udev_enumerate_add_match_property(udev_enumerate, property, value);
}
int udev_enumerate_add_match_sysname(struct udev_enumerate *udev_enumerate, const char *sysname) {
return _udev_enumerate_add_match_sysname(udev_enumerate, sysname);
}
int udev_enumerate_add_match_tag(struct udev_enumerate *udev_enumerate, const char *tag) {
return _udev_enumerate_add_match_tag(udev_enumerate, tag);
}
int udev_enumerate_add_match_parent(struct udev_enumerate *udev_enumerate, struct udev_device *parent) {
return _udev_enumerate_add_match_parent(udev_enumerate, parent);
}
int udev_enumerate_add_match_is_initialized(struct udev_enumerate *udev_enumerate) {
return _udev_enumerate_add_match_is_initialized(udev_enumerate);
}
int udev_enumerate_add_syspath(struct udev_enumerate *udev_enumerate, const char *syspath) {
return _udev_enumerate_add_syspath(udev_enumerate, syspath);
}
int udev_enumerate_scan_devices(struct udev_enumerate *udev_enumerate) {
return _udev_enumerate_scan_devices(udev_enumerate);
}
int udev_enumerate_scan_subsystems(struct udev_enumerate *udev_enumerate) {
return _udev_enumerate_scan_subsystems(udev_enumerate);
}
struct udev_list_entry *udev_enumerate_get_list_entry(struct udev_enumerate *udev_enumerate) {
return _udev_enumerate_get_list_entry(udev_enumerate);
}
struct udev_queue *udev_queue_ref(struct udev_queue *udev_queue) {
return _udev_queue_ref(udev_queue);
}
struct udev_queue *udev_queue_unref(struct udev_queue *udev_queue) {
return _udev_queue_unref(udev_queue);
}
struct udev *udev_queue_get_udev(struct udev_queue *udev_queue) {
return _udev_queue_get_udev(udev_queue);
}
struct udev_queue *udev_queue_new(struct udev *udev) {
return _udev_queue_new(udev);
}
unsigned long long int udev_queue_get_kernel_seqnum(struct udev_queue *udev_queue) {
return _udev_queue_get_kernel_seqnum(udev_queue);
}
unsigned long long int udev_queue_get_udev_seqnum(struct udev_queue *udev_queue) {
return _udev_queue_get_udev_seqnum(udev_queue);
}
int udev_queue_get_udev_is_active(struct udev_queue *udev_queue) {
return _udev_queue_get_udev_is_active(udev_queue);
}
int udev_queue_get_queue_is_empty(struct udev_queue *udev_queue) {
return _udev_queue_get_queue_is_empty(udev_queue);
}
int udev_queue_get_seqnum_is_finished(struct udev_queue *udev_queue, unsigned long long int seqnum) {
return _udev_queue_get_seqnum_is_finished(udev_queue, seqnum);
}
int udev_queue_get_fd(struct udev_queue *udev_queue) {
return _udev_queue_get_fd(udev_queue);
}
int udev_queue_flush(struct udev_queue *udev_queue) {
return _udev_queue_flush(udev_queue);
}
struct udev_list_entry *udev_queue_get_queued_list_entry(struct udev_queue *udev_queue) {
return _udev_queue_get_queued_list_entry(udev_queue);
}
struct udev_hwdb *udev_hwdb_new(struct udev *udev) {
return _udev_hwdb_new(udev);
}
struct udev_hwdb *udev_hwdb_ref(struct udev_hwdb *hwdb) {
return _udev_hwdb_ref(hwdb);
}
struct udev_hwdb *udev_hwdb_unref(struct udev_hwdb *hwdb) {
return _udev_hwdb_unref(hwdb);
}
struct udev_list_entry *udev_hwdb_get_properties_list_entry(struct udev_hwdb *hwdb, const char *modalias, unsigned int flags) {
return _udev_hwdb_get_properties_list_entry(hwdb, modalias, flags);
}
int udev_util_encode_string(const char *str, char *str_enc, size_t len) {
return _udev_util_encode_string(str, str_enc, len);
}

View File

@@ -34,7 +34,7 @@ add_subdirectory(mikktspace)
add_subdirectory(glew-mx)
add_subdirectory(eigen)
if (WITH_GAMEENGINE_DECKLINK)
if(WITH_GAMEENGINE_DECKLINK)
add_subdirectory(decklink)
endif()
@@ -62,7 +62,7 @@ if(WITH_IK_ITASC)
add_subdirectory(itasc)
endif()
if(WITH_IK_SOLVER OR WITH_GAMEENGINE OR WITH_MOD_BOOLEAN)
if(WITH_GAMEENGINE)
add_subdirectory(moto)
endif()

View File

@@ -101,11 +101,11 @@ ATOMIC_INLINE size_t atomic_fetch_and_add_z(size_t *p, size_t x);
ATOMIC_INLINE size_t atomic_fetch_and_sub_z(size_t *p, size_t x);
ATOMIC_INLINE size_t atomic_cas_z(size_t *v, size_t old, size_t _new);
ATOMIC_INLINE unsigned atomic_add_and_fetch_u(unsigned *p, unsigned x);
ATOMIC_INLINE unsigned atomic_sub_and_fetch_u(unsigned *p, unsigned x);
ATOMIC_INLINE unsigned atomic_fetch_and_add_u(unsigned *p, unsigned x);
ATOMIC_INLINE unsigned atomic_fetch_and_sub_u(unsigned *p, unsigned x);
ATOMIC_INLINE unsigned atomic_cas_u(unsigned *v, unsigned old, unsigned _new);
ATOMIC_INLINE unsigned int atomic_add_and_fetch_u(unsigned int *p, unsigned int x);
ATOMIC_INLINE unsigned int atomic_sub_and_fetch_u(unsigned int *p, unsigned int x);
ATOMIC_INLINE unsigned int atomic_fetch_and_add_u(unsigned int *p, unsigned int x);
ATOMIC_INLINE unsigned int atomic_fetch_and_sub_u(unsigned int *p, unsigned int x);
ATOMIC_INLINE unsigned int atomic_cas_u(unsigned int *v, unsigned int old, unsigned int _new);
/* WARNING! Float 'atomics' are really faked ones, those are actually closer to some kind of spinlock-sync'ed operation,
* which means they are only efficient if collisions are highly unlikely (i.e. if probability of two threads

View File

@@ -113,58 +113,58 @@ ATOMIC_INLINE size_t atomic_cas_z(size_t *v, size_t old, size_t _new)
/******************************************************************************/
/* unsigned operations. */
ATOMIC_INLINE unsigned atomic_add_and_fetch_u(unsigned *p, unsigned x)
ATOMIC_INLINE unsigned int atomic_add_and_fetch_u(unsigned int *p, unsigned int x)
{
assert(sizeof(unsigned) == LG_SIZEOF_INT);
assert(sizeof(unsigned int) == LG_SIZEOF_INT);
#if (LG_SIZEOF_INT == 8)
return (unsigned)atomic_add_and_fetch_uint64((uint64_t *)p, (uint64_t)x);
return (unsigned int)atomic_add_and_fetch_uint64((uint64_t *)p, (uint64_t)x);
#elif (LG_SIZEOF_INT == 4)
return (unsigned)atomic_add_and_fetch_uint32((uint32_t *)p, (uint32_t)x);
return (unsigned int)atomic_add_and_fetch_uint32((uint32_t *)p, (uint32_t)x);
#endif
}
ATOMIC_INLINE unsigned atomic_sub_and_fetch_u(unsigned *p, unsigned x)
ATOMIC_INLINE unsigned int atomic_sub_and_fetch_u(unsigned int *p, unsigned int x)
{
assert(sizeof(unsigned) == LG_SIZEOF_INT);
assert(sizeof(unsigned int) == LG_SIZEOF_INT);
#if (LG_SIZEOF_INT == 8)
return (unsigned)atomic_add_and_fetch_uint64((uint64_t *)p, (uint64_t)-((int64_t)x));
return (unsigned int)atomic_add_and_fetch_uint64((uint64_t *)p, (uint64_t)-((int64_t)x));
#elif (LG_SIZEOF_INT == 4)
return (unsigned)atomic_add_and_fetch_uint32((uint32_t *)p, (uint32_t)-((int32_t)x));
return (unsigned int)atomic_add_and_fetch_uint32((uint32_t *)p, (uint32_t)-((int32_t)x));
#endif
}
ATOMIC_INLINE unsigned atomic_fetch_and_add_u(unsigned *p, unsigned x)
ATOMIC_INLINE unsigned int atomic_fetch_and_add_u(unsigned int *p, unsigned int x)
{
assert(sizeof(unsigned) == LG_SIZEOF_INT);
assert(sizeof(unsigned int) == LG_SIZEOF_INT);
#if (LG_SIZEOF_INT == 8)
return (unsigned)atomic_fetch_and_add_uint64((uint64_t *)p, (uint64_t)x);
return (unsigned int)atomic_fetch_and_add_uint64((uint64_t *)p, (uint64_t)x);
#elif (LG_SIZEOF_INT == 4)
return (unsigned)atomic_fetch_and_add_uint32((uint32_t *)p, (uint32_t)x);
return (unsigned int)atomic_fetch_and_add_uint32((uint32_t *)p, (uint32_t)x);
#endif
}
ATOMIC_INLINE unsigned atomic_fetch_and_sub_u(unsigned *p, unsigned x)
ATOMIC_INLINE unsigned int atomic_fetch_and_sub_u(unsigned int *p, unsigned int x)
{
assert(sizeof(unsigned) == LG_SIZEOF_INT);
assert(sizeof(unsigned int) == LG_SIZEOF_INT);
#if (LG_SIZEOF_INT == 8)
return (unsigned)atomic_fetch_and_add_uint64((uint64_t *)p, (uint64_t)-((int64_t)x));
return (unsigned int)atomic_fetch_and_add_uint64((uint64_t *)p, (uint64_t)-((int64_t)x));
#elif (LG_SIZEOF_INT == 4)
return (unsigned)atomic_fetch_and_add_uint32((uint32_t *)p, (uint32_t)-((int32_t)x));
return (unsigned int)atomic_fetch_and_add_uint32((uint32_t *)p, (uint32_t)-((int32_t)x));
#endif
}
ATOMIC_INLINE unsigned atomic_cas_u(unsigned *v, unsigned old, unsigned _new)
ATOMIC_INLINE unsigned int atomic_cas_u(unsigned int *v, unsigned int old, unsigned int _new)
{
assert(sizeof(unsigned) == LG_SIZEOF_INT);
assert(sizeof(unsigned int) == LG_SIZEOF_INT);
#if (LG_SIZEOF_INT == 8)
return (unsigned)atomic_cas_uint64((uint64_t *)v, (uint64_t)old, (uint64_t)_new);
return (unsigned int)atomic_cas_uint64((uint64_t *)v, (uint64_t)old, (uint64_t)_new);
#elif (LG_SIZEOF_INT == 4)
return (unsigned)atomic_cas_uint32((uint32_t *)v, (uint32_t)old, (uint32_t)_new);
return (unsigned int)atomic_cas_uint32((uint32_t *)v, (uint32_t)old, (uint32_t)_new);
#endif
}

View File

@@ -365,6 +365,7 @@ bool AUD_SoftwareDevice::AUD_SoftwareHandle::seek(float position)
if(!m_status)
return false;
m_pitch->setPitch(m_user_pitch);
m_reader->seek((int)(position * m_reader->getSpecs().rate));
if(m_status == AUD_STATUS_STOPPED)

View File

@@ -22,6 +22,7 @@ if(WITH_CYCLES_NATIVE_ONLY)
-DWITH_KERNEL_NATIVE
)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -march=native")
set(CYCLES_KERNEL_FLAGS "-march=native")
elseif(NOT WITH_CPU_SSE)
set(CXX_HAS_SSE FALSE)
set(CXX_HAS_AVX FALSE)
@@ -59,10 +60,13 @@ elseif(WIN32 AND MSVC)
set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} /Ox")
set(CMAKE_CXX_FLAGS_RELWITHDEBINFO "${CMAKE_CXX_FLAGS_RELWITHDEBINFO} /Ox")
set(CMAKE_CXX_FLAGS_MINSIZEREL "${CMAKE_CXX_FLAGS_MINSIZEREL} /Ox")
set(CYCLES_KERNEL_FLAGS "/fp:fast -D_CRT_SECURE_NO_WARNINGS /GS-")
elseif(CMAKE_COMPILER_IS_GNUCC)
check_cxx_compiler_flag(-msse CXX_HAS_SSE)
check_cxx_compiler_flag(-mavx CXX_HAS_AVX)
check_cxx_compiler_flag(-mavx2 CXX_HAS_AVX2)
set(CYCLES_KERNEL_FLAGS "-ffast-math")
if(CXX_HAS_SSE)
set(CYCLES_SSE2_KERNEL_FLAGS "-ffast-math -msse -msse2 -mfpmath=sse")
set(CYCLES_SSE3_KERNEL_FLAGS "-ffast-math -msse -msse2 -msse3 -mssse3 -mfpmath=sse")
@@ -74,10 +78,12 @@ elseif(CMAKE_COMPILER_IS_GNUCC)
if(CXX_HAS_AVX2)
set(CYCLES_AVX2_KERNEL_FLAGS "-ffast-math -msse -msse2 -msse3 -mssse3 -msse4.1 -mavx -mavx2 -mfma -mlzcnt -mbmi -mbmi2 -mf16c -mfpmath=sse")
endif()
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -ffast-math -fno-finite-math-only")
elseif(CMAKE_CXX_COMPILER_ID MATCHES "Clang")
check_cxx_compiler_flag(-msse CXX_HAS_SSE)
check_cxx_compiler_flag(-mavx CXX_HAS_AVX)
check_cxx_compiler_flag(-mavx2 CXX_HAS_AVX2)
set(CYCLES_KERNEL_FLAGS "-ffast-math")
if(CXX_HAS_SSE)
set(CYCLES_SSE2_KERNEL_FLAGS "-ffast-math -msse -msse2")
set(CYCLES_SSE3_KERNEL_FLAGS "-ffast-math -msse -msse2 -msse3 -mssse3")
@@ -89,6 +95,7 @@ elseif(CMAKE_CXX_COMPILER_ID MATCHES "Clang")
if(CXX_HAS_AVX2)
set(CYCLES_AVX2_KERNEL_FLAGS "-ffast-math -msse -msse2 -msse3 -mssse3 -msse4.1 -mavx -mavx2 -mfma -mlzcnt -mbmi -mbmi2 -mf16c")
endif()
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -ffast-math -fno-finite-math-only")
endif()
if(CXX_HAS_SSE)

View File

@@ -1,14 +1,6 @@
set(INC
.
../bvh
../device
../graph
../kernel
../kernel/svm
../render
../subd
../util
..
)
set(INC_SYS
)

View File

@@ -16,15 +16,15 @@
#include <stdio.h>
#include "device.h"
#include "device/device.h"
#include "util_args.h"
#include "util_foreach.h"
#include "util_path.h"
#include "util_stats.h"
#include "util_string.h"
#include "util_task.h"
#include "util_logging.h"
#include "util/util_args.h"
#include "util/util_foreach.h"
#include "util/util_path.h"
#include "util/util_stats.h"
#include "util/util_string.h"
#include "util/util_task.h"
#include "util/util_logging.h"
using namespace ccl;

View File

@@ -16,29 +16,29 @@
#include <stdio.h>
#include "buffers.h"
#include "camera.h"
#include "device.h"
#include "scene.h"
#include "session.h"
#include "integrator.h"
#include "render/buffers.h"
#include "render/camera.h"
#include "device/device.h"
#include "render/scene.h"
#include "render/session.h"
#include "render/integrator.h"
#include "util_args.h"
#include "util_foreach.h"
#include "util_function.h"
#include "util_logging.h"
#include "util_path.h"
#include "util_progress.h"
#include "util_string.h"
#include "util_time.h"
#include "util_transform.h"
#include "util_version.h"
#include "util/util_args.h"
#include "util/util_foreach.h"
#include "util/util_function.h"
#include "util/util_logging.h"
#include "util/util_path.h"
#include "util/util_progress.h"
#include "util/util_string.h"
#include "util/util_time.h"
#include "util/util_transform.h"
#include "util/util_version.h"
#ifdef WITH_CYCLES_STANDALONE_GUI
#include "util_view.h"
#include "util/util_view.h"
#endif
#include "cycles_xml.h"
#include "app/cycles_xml.h"
CCL_NAMESPACE_BEGIN

View File

@@ -20,31 +20,31 @@
#include <algorithm>
#include <iterator>
#include "node_xml.h"
#include "graph/node_xml.h"
#include "background.h"
#include "camera.h"
#include "film.h"
#include "graph.h"
#include "integrator.h"
#include "light.h"
#include "mesh.h"
#include "nodes.h"
#include "object.h"
#include "osl.h"
#include "shader.h"
#include "scene.h"
#include "render/background.h"
#include "render/camera.h"
#include "render/film.h"
#include "render/graph.h"
#include "render/integrator.h"
#include "render/light.h"
#include "render/mesh.h"
#include "render/nodes.h"
#include "render/object.h"
#include "render/osl.h"
#include "render/shader.h"
#include "render/scene.h"
#include "subd_patch.h"
#include "subd_split.h"
#include "subd/subd_patch.h"
#include "subd/subd_split.h"
#include "util_debug.h"
#include "util_foreach.h"
#include "util_path.h"
#include "util_transform.h"
#include "util_xml.h"
#include "util/util_debug.h"
#include "util/util_foreach.h"
#include "util/util_path.h"
#include "util/util_transform.h"
#include "util/util_xml.h"
#include "cycles_xml.h"
#include "app/cycles_xml.h"
CCL_NAMESPACE_BEGIN

View File

@@ -1,12 +1,6 @@
set(INC
../graph
../render
../device
../kernel
../kernel/svm
../util
../subd
..
../../glew-mx
../../guardedalloc
../../mikktspace

View File

@@ -107,7 +107,13 @@ def engine_exit():
engine.exit()
classes = (
CyclesRender,
)
def register():
from bpy.utils import register_class
from . import ui
from . import properties
from . import presets
@@ -122,12 +128,15 @@ def register():
properties.register()
ui.register()
presets.register()
bpy.utils.register_module(__name__)
for cls in classes:
register_class(cls)
bpy.app.handlers.version_update.append(version_update.do_versions)
def unregister():
from bpy.utils import unregister_class
from . import ui
from . import properties
from . import presets
@@ -138,4 +147,6 @@ def unregister():
ui.unregister()
properties.unregister()
presets.unregister()
bpy.utils.unregister_module(__name__)
for cls in classes:
unregister_class(cls)

View File

@@ -50,6 +50,24 @@ def _workaround_buggy_drivers():
_cycles.opencl_disable()
def _configure_argument_parser():
import argparse
parser = argparse.ArgumentParser(description="Cycles Addon argument parser")
parser.add_argument("--cycles-resumable-num-chunks",
help="Number of chunks to split sample range into",
default=None)
parser.add_argument("--cycles-resumable-current-chunk",
help="Current chunk of samples range to render",
default=None)
parser.add_argument("--cycles-resumable-start-chunk",
help="Start chunk to render",
default=None)
parser.add_argument("--cycles-resumable-end-chunk",
help="End chunk to render",
default=None)
return parser
def _parse_command_line():
import sys
@@ -57,25 +75,22 @@ def _parse_command_line():
if "--" not in argv:
return
argv = argv[argv.index("--") + 1:]
parser = _configure_argument_parser()
args, unknown = parser.parse_known_args(argv[argv.index("--") + 1:])
num_resumable_chunks = None
current_resumable_chunk = None
# TODO(sergey): Add some nice error ptins if argument is not used properly.
idx = 0
while idx < len(argv) - 1:
arg = argv[idx]
if arg == '--cycles-resumable-num-chunks':
num_resumable_chunks = int(argv[idx + 1])
elif arg == '--cycles-resumable-current-chunk':
current_resumable_chunk = int(argv[idx + 1])
idx += 1
if num_resumable_chunks is not None and current_resumable_chunk is not None:
import _cycles
_cycles.set_resumable_chunks(num_resumable_chunks,
current_resumable_chunk)
if args.cycles_resumable_num_chunks is not None:
if args.cycles_resumable_current_chunk is not None:
import _cycles
_cycles.set_resumable_chunk(
int(args.cycles_resumable_num_chunks),
int(args.cycles_resumable_current_chunk))
elif args.cycles_resumable_start_chunk is not None and \
args.cycles_resumable_end_chunk:
import _cycles
_cycles.set_resumable_chunk_range(
int(args.cycles_resumable_num_chunks),
int(args.cycles_resumable_start_chunk),
int(args.cycles_resumable_end_chunk))
def init():

View File

@@ -82,12 +82,23 @@ class AddPresetSampling(AddPresetBase, Operator):
preset_subdir = "cycles/sampling"
classes = (
AddPresetIntegrator,
AddPresetSampling,
)
def register():
pass
from bpy.utils import register_class
for cls in classes:
register_class(cls)
def unregister():
pass
from bpy.utils import unregister_class
for cls in classes:
unregister_class(cls)
if __name__ == "__main__":
register()

View File

@@ -638,6 +638,20 @@ class CyclesRenderSettings(bpy.types.PropertyGroup):
items=enum_texture_limit
)
cls.ao_bounces = IntProperty(
name="AO Bounces",
default=0,
description="Approximate indirect light with background tinted ambient occlusion at the specified bounce, 0 disables this feature",
min=0, max=1024,
)
cls.ao_bounces_render = IntProperty(
name="AO Bounces Render",
default=0,
description="Approximate indirect light with background tinted ambient occlusion at the specified bounce, 0 disables this feature",
min=0, max=1024,
)
# Various fine-tuning debug flags
def devices_update_callback(self, context):
@@ -651,8 +665,10 @@ class CyclesRenderSettings(bpy.types.PropertyGroup):
cls.debug_use_cpu_sse3 = BoolProperty(name="SSE3", default=True)
cls.debug_use_cpu_sse2 = BoolProperty(name="SSE2", default=True)
cls.debug_use_qbvh = BoolProperty(name="QBVH", default=True)
cls.debug_use_cpu_split_kernel = BoolProperty(name="Split Kernel", default=False)
cls.debug_use_cuda_adaptive_compile = BoolProperty(name="Adaptive Compile", default=False)
cls.debug_use_cuda_split_kernel = BoolProperty(name="Split Kernel", default=False)
cls.debug_opencl_kernel_type = EnumProperty(
name="OpenCL Kernel Type",
@@ -679,6 +695,8 @@ class CyclesRenderSettings(bpy.types.PropertyGroup):
update=devices_update_callback
)
cls.debug_opencl_kernel_single_program = BoolProperty(name="Single Program", default=False, update=devices_update_callback);
cls.debug_use_opencl_debug = BoolProperty(name="Debug OpenCL", default=False)
@classmethod
@@ -1078,6 +1096,12 @@ class CyclesObjectSettings(bpy.types.PropertyGroup):
default=1.0,
)
cls.is_shadow_catcher = BoolProperty(
name="Shadow Catcher",
description="Only render shadows on this object, for compositing renders into real footage",
default=False,
)
@classmethod
def unregister(cls):
del bpy.types.Object.cycles

View File

@@ -86,12 +86,10 @@ def use_sample_all_lights(context):
return cscene.sample_all_lights_direct or cscene.sample_all_lights_indirect
def show_device_selection(context):
type = get_device_type(context)
if type == 'NETWORK':
def show_device_active(context):
cscene = context.scene.cycles
if cscene.device != 'GPU':
return True
if not type in {'CUDA', 'OPENCL'}:
return False
return context.user_preferences.addons[__package__].preferences.has_active_device()
@@ -186,9 +184,6 @@ class CyclesRender_PT_sampling(CyclesButtonsPanel, Panel):
sub.label(text="AA Samples:")
sub.prop(cscene, "aa_samples", text="Render")
sub.prop(cscene, "preview_aa_samples", text="Preview")
sub.separator()
sub.prop(cscene, "sample_all_lights_direct")
sub.prop(cscene, "sample_all_lights_indirect")
col = split.column()
sub = col.column(align=True)
@@ -205,6 +200,10 @@ class CyclesRender_PT_sampling(CyclesButtonsPanel, Panel):
sub.prop(cscene, "subsurface_samples", text="Subsurface")
sub.prop(cscene, "volume_samples", text="Volume")
col = layout.column(align=True)
col.prop(cscene, "sample_all_lights_direct")
col.prop(cscene, "sample_all_lights_indirect")
if not (use_opencl(context) and cscene.feature_set != 'EXPERIMENTAL'):
layout.row().prop(cscene, "sampling_pattern", text="Pattern")
@@ -270,7 +269,7 @@ class CyclesRender_PT_geometry(CyclesButtonsPanel, Panel):
row = col.row()
row.prop(ccscene, "minimum_width", text="Min Pixels")
row.prop(ccscene, "maximum_width", text="Max Ext.")
row.prop(ccscene, "maximum_width", text="Max Extension")
class CyclesRender_PT_light_paths(CyclesButtonsPanel, Panel):
@@ -564,7 +563,7 @@ class CyclesRender_PT_views(CyclesButtonsPanel, Panel):
row.label(text="File Suffix:")
row.prop(rv, "file_suffix", text="")
else:
elif rd.views_format == 'MULTIVIEW':
row = layout.row()
row.template_list("RENDERLAYER_UL_renderviews", "name", rd, "views", rd.views, "active_index", rows=2)
@@ -575,6 +574,23 @@ class CyclesRender_PT_views(CyclesButtonsPanel, Panel):
row = layout.row()
row.label(text="Camera Suffix:")
row.prop(rv, "camera_suffix", text="")
else:
wm = context.window_manager
running = scene.hmd_running
text_win = "Close HMD Window" if wm.has_hmd_window else "Open HMD Window"
text_run = "Stop Session" if running else "Start Session"
icon = 'PAUSE' if running else 'PLAY'
col = layout.column()
row = col.row(align=True)
row.operator("wm.hmd_view_toggle", text=text_win)
row.operator("wm.hmd_session_run", text=text_run, icon=icon)
col.prop(rd, "hmd_camlock")
col.prop(rd, "use_hmd_view_lensdist", text="Lens Distortion")
col.prop(rd, "hmd_view_shade", text="Shading")
class Cycles_PT_post_processing(CyclesButtonsPanel, Panel):
@@ -788,6 +804,8 @@ class CyclesObject_PT_cycles_settings(CyclesButtonsPanel, Panel):
if ob.type != 'LAMP':
flow.prop(visibility, "shadow")
layout.prop(cob, "is_shadow_catcher")
col = layout.column()
col.label(text="Performance:")
row = col.row()
@@ -1038,10 +1056,11 @@ class CyclesWorld_PT_ambient_occlusion(CyclesButtonsPanel, Panel):
layout = self.layout
light = context.world.light_settings
scene = context.scene
row = layout.row()
sub = row.row()
sub.active = light.use_ambient_occlusion
sub.active = light.use_ambient_occlusion or scene.render.use_simplify
sub.prop(light, "ao_factor", text="Factor")
row.prop(light, "distance", text="Distance")
@@ -1517,15 +1536,18 @@ class CyclesRender_PT_debug(CyclesButtonsPanel, Panel):
row.prop(cscene, "debug_use_cpu_avx", toggle=True)
row.prop(cscene, "debug_use_cpu_avx2", toggle=True)
col.prop(cscene, "debug_use_qbvh")
col.prop(cscene, "debug_use_cpu_split_kernel")
col = layout.column()
col.label('CUDA Flags:')
col.prop(cscene, "debug_use_cuda_adaptive_compile")
col.prop(cscene, "debug_use_cuda_split_kernel")
col = layout.column()
col.label('OpenCL Flags:')
col.prop(cscene, "debug_opencl_kernel_type", text="Kernel")
col.prop(cscene, "debug_opencl_device_type", text="Device")
col.prop(cscene, "debug_opencl_kernel_single_program", text="Single Program")
col.prop(cscene, "debug_use_opencl_debug", text="Debug")
@@ -1612,6 +1634,13 @@ class CyclesScene_PT_simplify(CyclesButtonsPanel, Panel):
row.active = cscene.use_distance_cull
row.prop(cscene, "distance_cull_margin", text="Distance")
split = layout.split()
col = split.column()
col.prop(cscene, "ao_bounces")
col = split.column()
col.prop(cscene, "ao_bounces_render")
def draw_device(self, context):
scene = context.scene
layout = self.layout
@@ -1625,7 +1654,7 @@ def draw_device(self, context):
split = layout.split(percentage=1/3)
split.label("Device:")
row = split.row()
row.active = show_device_selection(context)
row.active = show_device_active(context)
row.prop(cscene, "device", text="")
if engine.with_osl() and use_cpu(context):
@@ -1704,17 +1733,75 @@ def get_panels():
return panels
classes = (
CYCLES_MT_sampling_presets,
CYCLES_MT_integrator_presets,
CyclesRender_PT_sampling,
CyclesRender_PT_geometry,
CyclesRender_PT_light_paths,
CyclesRender_PT_motion_blur,
CyclesRender_PT_film,
CyclesRender_PT_performance,
CyclesRender_PT_layer_options,
CyclesRender_PT_layer_passes,
CyclesRender_PT_views,
Cycles_PT_post_processing,
CyclesCamera_PT_dof,
Cycles_PT_context_material,
CyclesObject_PT_motion_blur,
CyclesObject_PT_cycles_settings,
CYCLES_OT_use_shading_nodes,
CyclesLamp_PT_preview,
CyclesLamp_PT_lamp,
CyclesLamp_PT_nodes,
CyclesLamp_PT_spot,
CyclesWorld_PT_preview,
CyclesWorld_PT_surface,
CyclesWorld_PT_volume,
CyclesWorld_PT_ambient_occlusion,
CyclesWorld_PT_mist,
CyclesWorld_PT_ray_visibility,
CyclesWorld_PT_settings,
CyclesMaterial_PT_preview,
CyclesMaterial_PT_surface,
CyclesMaterial_PT_volume,
CyclesMaterial_PT_displacement,
CyclesMaterial_PT_settings,
CyclesTexture_PT_context,
CyclesTexture_PT_node,
CyclesTexture_PT_mapping,
CyclesTexture_PT_colors,
CyclesParticle_PT_textures,
CyclesRender_PT_bake,
CyclesRender_PT_debug,
CyclesParticle_PT_CurveSettings,
CyclesScene_PT_simplify,
)
def register():
from bpy.utils import register_class
bpy.types.RENDER_PT_render.append(draw_device)
bpy.types.VIEW3D_HT_header.append(draw_pause)
for panel in get_panels():
panel.COMPAT_ENGINES.add('CYCLES')
for cls in classes:
register_class(cls)
def unregister():
from bpy.utils import unregister_class
bpy.types.RENDER_PT_render.remove(draw_device)
bpy.types.VIEW3D_HT_header.remove(draw_pause)
for panel in get_panels():
if 'CYCLES' in panel.COMPAT_ENGINES:
panel.COMPAT_ENGINES.remove('CYCLES')
for cls in classes:
unregister_class(cls)

View File

@@ -14,13 +14,13 @@
* limitations under the License.
*/
#include "camera.h"
#include "scene.h"
#include "render/camera.h"
#include "render/scene.h"
#include "blender_sync.h"
#include "blender_util.h"
#include "blender/blender_sync.h"
#include "blender/blender_util.h"
#include "util_logging.h"
#include "util/util_logging.h"
CCL_NAMESPACE_BEGIN

View File

@@ -14,18 +14,18 @@
* limitations under the License.
*/
#include "attribute.h"
#include "camera.h"
#include "curves.h"
#include "mesh.h"
#include "object.h"
#include "scene.h"
#include "render/attribute.h"
#include "render/camera.h"
#include "render/curves.h"
#include "render/mesh.h"
#include "render/object.h"
#include "render/scene.h"
#include "blender_sync.h"
#include "blender_util.h"
#include "blender/blender_sync.h"
#include "blender/blender_util.h"
#include "util_foreach.h"
#include "util_logging.h"
#include "util/util_foreach.h"
#include "util/util_logging.h"
CCL_NAMESPACE_BEGIN
@@ -411,6 +411,7 @@ static void ExportCurveTrianglePlanes(Mesh *mesh, ParticleCurveData *CData,
}
}
mesh->resize_mesh(mesh->verts.size(), mesh->triangles.size());
mesh->attributes.remove(ATTR_STD_VERTEX_NORMAL);
mesh->attributes.remove(ATTR_STD_FACE_NORMAL);
mesh->add_face_normals();
@@ -434,8 +435,8 @@ static void ExportCurveTriangleGeometry(Mesh *mesh,
if(CData->curve_keynum[curve] <= 1 || CData->curve_length[curve] == 0.0f)
continue;
numverts += (CData->curve_keynum[curve] - 2)*2*resolution + resolution;
numtris += (CData->curve_keynum[curve] - 2)*resolution;
numverts += (CData->curve_keynum[curve] - 1)*resolution + resolution;
numtris += (CData->curve_keynum[curve] - 1)*2*resolution;
}
}
@@ -545,6 +546,7 @@ static void ExportCurveTriangleGeometry(Mesh *mesh,
}
}
mesh->resize_mesh(mesh->verts.size(), mesh->triangles.size());
mesh->attributes.remove(ATTR_STD_VERTEX_NORMAL);
mesh->attributes.remove(ATTR_STD_FACE_NORMAL);
mesh->add_face_normals();
@@ -890,7 +892,7 @@ void BlenderSync::sync_curves(Mesh *mesh,
}
/* obtain general settings */
bool use_curves = scene->curve_system_manager->use_curves;
const bool use_curves = scene->curve_system_manager->use_curves;
if(!(use_curves && b_ob.mode() != b_ob.mode_PARTICLE_EDIT)) {
if(!motion)
@@ -898,11 +900,11 @@ void BlenderSync::sync_curves(Mesh *mesh,
return;
}
int primitive = scene->curve_system_manager->primitive;
int triangle_method = scene->curve_system_manager->triangle_method;
int resolution = scene->curve_system_manager->resolution;
size_t vert_num = mesh->verts.size();
size_t tri_num = mesh->num_triangles();
const int primitive = scene->curve_system_manager->primitive;
const int triangle_method = scene->curve_system_manager->triangle_method;
const int resolution = scene->curve_system_manager->resolution;
const size_t vert_num = mesh->verts.size();
const size_t tri_num = mesh->num_triangles();
int used_res = 1;
/* extract particle hair data - should be combined with connecting to mesh later*/

View File

@@ -14,8 +14,8 @@
* limitations under the License.
*/
#include "CCL_api.h"
#include "util_logging.h"
#include "blender/CCL_api.h"
#include "util/util_logging.h"
void CCL_init_logging(const char *argv0)
{

View File

@@ -15,21 +15,22 @@
*/
#include "mesh.h"
#include "object.h"
#include "scene.h"
#include "camera.h"
#include "render/mesh.h"
#include "render/object.h"
#include "render/scene.h"
#include "render/camera.h"
#include "blender_sync.h"
#include "blender_session.h"
#include "blender_util.h"
#include "blender/blender_sync.h"
#include "blender/blender_session.h"
#include "blender/blender_util.h"
#include "subd_patch.h"
#include "subd_split.h"
#include "subd/subd_patch.h"
#include "subd/subd_split.h"
#include "util_foreach.h"
#include "util_logging.h"
#include "util_math.h"
#include "util/util_algorithm.h"
#include "util/util_foreach.h"
#include "util/util_logging.h"
#include "util/util_math.h"
#include "mikktspace.h"
@@ -525,69 +526,180 @@ static void attr_create_uv_map(Scene *scene,
}
/* Create vertex pointiness attributes. */
/* Compare vertices by sum of their coordinates. */
class VertexAverageComparator {
public:
VertexAverageComparator(const array<float3>& verts)
: verts_(verts) {
}
bool operator()(const int& vert_idx_a, const int& vert_idx_b)
{
const float3 &vert_a = verts_[vert_idx_a];
const float3 &vert_b = verts_[vert_idx_b];
if(vert_a == vert_b) {
/* Special case for doubles, so we ensure ordering. */
return vert_idx_a > vert_idx_b;
}
const float x1 = vert_a.x + vert_a.y + vert_a.z;
const float x2 = vert_b.x + vert_b.y + vert_b.z;
return x1 < x2;
}
protected:
const array<float3>& verts_;
};
static void attr_create_pointiness(Scene *scene,
Mesh *mesh,
BL::Mesh& b_mesh,
bool subdivision)
{
if(mesh->need_attribute(scene, ATTR_STD_POINTINESS)) {
const int numverts = b_mesh.vertices.length();
AttributeSet& attributes = (subdivision)? mesh->subd_attributes: mesh->attributes;
Attribute *attr = attributes.add(ATTR_STD_POINTINESS);
float *data = attr->data_float();
int *counter = new int[numverts];
float *raw_data = new float[numverts];
float3 *edge_accum = new float3[numverts];
/* Calculate pointiness using single ring neighborhood. */
memset(counter, 0, sizeof(int) * numverts);
memset(raw_data, 0, sizeof(float) * numverts);
memset(edge_accum, 0, sizeof(float3) * numverts);
BL::Mesh::edges_iterator e;
int i = 0;
for(b_mesh.edges.begin(e); e != b_mesh.edges.end(); ++e, ++i) {
int v0 = b_mesh.edges[i].vertices()[0],
v1 = b_mesh.edges[i].vertices()[1];
float3 co0 = get_float3(b_mesh.vertices[v0].co()),
co1 = get_float3(b_mesh.vertices[v1].co());
float3 edge = normalize(co1 - co0);
edge_accum[v0] += edge;
edge_accum[v1] += -edge;
++counter[v0];
++counter[v1];
}
i = 0;
BL::Mesh::vertices_iterator v;
for(b_mesh.vertices.begin(v); v != b_mesh.vertices.end(); ++v, ++i) {
if(counter[i] > 0) {
float3 normal = get_float3(b_mesh.vertices[i].normal());
float angle = safe_acosf(dot(normal, edge_accum[i] / counter[i]));
raw_data[i] = angle * M_1_PI_F;
if(!mesh->need_attribute(scene, ATTR_STD_POINTINESS)) {
return;
}
const int num_verts = b_mesh.vertices.length();
if(num_verts == 0) {
return;
}
/* STEP 1: Find out duplicated vertices and point duplicates to a single
* original vertex.
*/
vector<int> sorted_vert_indeices(num_verts);
for(int vert_index = 0; vert_index < num_verts; ++vert_index) {
sorted_vert_indeices[vert_index] = vert_index;
}
VertexAverageComparator compare(mesh->verts);
sort(sorted_vert_indeices.begin(), sorted_vert_indeices.end(), compare);
/* This array stores index of the original vertex for the given vertex
* index.
*/
vector<int> vert_orig_index(num_verts);
for(int sorted_vert_index = 0;
sorted_vert_index < num_verts;
++sorted_vert_index)
{
const int vert_index = sorted_vert_indeices[sorted_vert_index];
const float3 &vert_co = mesh->verts[vert_index];
bool found = false;
for(int other_sorted_vert_index = sorted_vert_index + 1;
other_sorted_vert_index < num_verts;
++other_sorted_vert_index)
{
const int other_vert_index =
sorted_vert_indeices[other_sorted_vert_index];
const float3 &other_vert_co = mesh->verts[other_vert_index];
/* We are too far away now, we wouldn't have duplicate. */
if((other_vert_co.x + other_vert_co.y + other_vert_co.z) -
(vert_co.x + vert_co.y + vert_co.z) > 3 * FLT_EPSILON)
{
break;
}
else {
raw_data[i] = 0.0f;
/* Found duplicate. */
if(len_squared(other_vert_co - vert_co) < FLT_EPSILON) {
found = true;
vert_orig_index[vert_index] = other_vert_index;
break;
}
}
/* Blur vertices to approximate 2 ring neighborhood. */
memset(counter, 0, sizeof(int) * numverts);
memcpy(data, raw_data, sizeof(float) * numverts);
i = 0;
for(b_mesh.edges.begin(e); e != b_mesh.edges.end(); ++e, ++i) {
int v0 = b_mesh.edges[i].vertices()[0],
v1 = b_mesh.edges[i].vertices()[1];
data[v0] += raw_data[v1];
data[v1] += raw_data[v0];
++counter[v0];
++counter[v1];
if(!found) {
vert_orig_index[vert_index] = vert_index;
}
for(i = 0; i < numverts; ++i) {
data[i] /= counter[i] + 1;
}
/* Make sure we always points to the very first orig vertex. */
for(int vert_index = 0; vert_index < num_verts; ++vert_index) {
int orig_index = vert_orig_index[vert_index];
while(orig_index != vert_orig_index[orig_index]) {
orig_index = vert_orig_index[orig_index];
}
delete [] counter;
delete [] raw_data;
delete [] edge_accum;
vert_orig_index[vert_index] = orig_index;
}
sorted_vert_indeices.free_memory();
/* STEP 2: Calculate vertex normals taking into account their possible
* duplicates which gets "welded" together.
*/
vector<float3> vert_normal(num_verts, make_float3(0.0f, 0.0f, 0.0f));
/* First we accumulate all vertex normals in the original index. */
for(int vert_index = 0; vert_index < num_verts; ++vert_index) {
const float3 normal = get_float3(b_mesh.vertices[vert_index].normal());
const int orig_index = vert_orig_index[vert_index];
vert_normal[orig_index] += normal;
}
/* Then we normalize the accumulated result and flush it to all duplicates
* as well.
*/
for(int vert_index = 0; vert_index < num_verts; ++vert_index) {
const int orig_index = vert_orig_index[vert_index];
vert_normal[vert_index] = normalize(vert_normal[orig_index]);
}
/* STEP 3: Calculate pointiness using single ring neighborhood. */
vector<int> counter(num_verts, 0);
vector<float> raw_data(num_verts, 0.0f);
vector<float3> edge_accum(num_verts, make_float3(0.0f, 0.0f, 0.0f));
BL::Mesh::edges_iterator e;
EdgeMap visited_edges;
int edge_index = 0;
memset(&counter[0], 0, sizeof(int) * counter.size());
for(b_mesh.edges.begin(e); e != b_mesh.edges.end(); ++e, ++edge_index) {
const int v0 = vert_orig_index[b_mesh.edges[edge_index].vertices()[0]],
v1 = vert_orig_index[b_mesh.edges[edge_index].vertices()[1]];
if(visited_edges.exists(v0, v1)) {
continue;
}
visited_edges.insert(v0, v1);
float3 co0 = get_float3(b_mesh.vertices[v0].co()),
co1 = get_float3(b_mesh.vertices[v1].co());
float3 edge = normalize(co1 - co0);
edge_accum[v0] += edge;
edge_accum[v1] += -edge;
++counter[v0];
++counter[v1];
}
for(int vert_index = 0; vert_index < num_verts; ++vert_index) {
const int orig_index = vert_orig_index[vert_index];
if(orig_index != vert_index) {
/* Skip duplicates, they'll be overwritten later on. */
continue;
}
if(counter[vert_index] > 0) {
const float3 normal = vert_normal[vert_index];
const float angle =
safe_acosf(dot(normal,
edge_accum[vert_index] / counter[vert_index]));
raw_data[vert_index] = angle * M_1_PI_F;
}
else {
raw_data[vert_index] = 0.0f;
}
}
/* STEP 3: Blur vertices to approximate 2 ring neighborhood. */
AttributeSet& attributes = (subdivision)? mesh->subd_attributes: mesh->attributes;
Attribute *attr = attributes.add(ATTR_STD_POINTINESS);
float *data = attr->data_float();
memcpy(data, &raw_data[0], sizeof(float) * raw_data.size());
memset(&counter[0], 0, sizeof(int) * counter.size());
edge_index = 0;
visited_edges.clear();
for(b_mesh.edges.begin(e); e != b_mesh.edges.end(); ++e, ++edge_index) {
const int v0 = vert_orig_index[b_mesh.edges[edge_index].vertices()[0]],
v1 = vert_orig_index[b_mesh.edges[edge_index].vertices()[1]];
if(visited_edges.exists(v0, v1)) {
continue;
}
visited_edges.insert(v0, v1);
data[v0] += raw_data[v1];
data[v1] += raw_data[v0];
++counter[v0];
++counter[v1];
}
for(int vert_index = 0; vert_index < num_verts; ++vert_index) {
data[vert_index] /= counter[vert_index] + 1;
}
/* STEP 4: Copy attribute to the duplicated vertices. */
for(int vert_index = 0; vert_index < num_verts; ++vert_index) {
const int orig_index = vert_orig_index[vert_index];
data[vert_index] = data[orig_index];
}
}
@@ -656,9 +768,6 @@ static void create_mesh(Scene *scene,
generated[i++] = get_float3(v->undeformed_co())*size - loc;
}
/* Create needed vertex attributes. */
attr_create_pointiness(scene, mesh, b_mesh, subdivision);
/* create faces */
vector<int> nverts(numfaces);
vector<int> face_flags(numfaces, FACE_FLAG_NONE);
@@ -671,6 +780,15 @@ static void create_mesh(Scene *scene,
int shader = clamp(f->material_index(), 0, used_shaders.size()-1);
bool smooth = f->use_smooth() || use_loop_normals;
if(use_loop_normals) {
BL::Array<float, 12> loop_normals = f->split_normals();
for(int i = 0; i < n; i++) {
N[vi[i]] = make_float3(loop_normals[i * 3],
loop_normals[i * 3 + 1],
loop_normals[i * 3 + 2]);
}
}
/* Create triangles.
*
* NOTE: Autosmooth is already taken care about.
@@ -704,7 +822,7 @@ static void create_mesh(Scene *scene,
int shader = clamp(p->material_index(), 0, used_shaders.size()-1);
bool smooth = p->use_smooth() || use_loop_normals;
vi.reserve(n);
vi.resize(n);
for(int i = 0; i < n; i++) {
/* NOTE: Autosmooth is already taken care about. */
vi[i] = b_mesh.loops[p->loop_start() + i].vertex_index();
@@ -718,6 +836,7 @@ static void create_mesh(Scene *scene,
/* Create all needed attributes.
* The calculate functions will check whether they're needed or not.
*/
attr_create_pointiness(scene, mesh, b_mesh, subdivision);
attr_create_vertex_color(scene, mesh, b_mesh, nverts, face_flags, subdivision);
attr_create_uv_map(scene, mesh, b_mesh, nverts, face_flags, subdivision, subdivide_uvs);
@@ -927,6 +1046,13 @@ Mesh *BlenderSync::sync_mesh(BL::Object& b_ob,
mesh->subdivision_type = object_subdivision_type(b_ob, preview, experimental);
/* Disable adaptive subdivision while baking as the baking system
* currently doesnt support the topology and will crash.
*/
if(scene->bake_manager->get_baking()) {
mesh->subdivision_type = Mesh::SUBDIVISION_NONE;
}
BL::Mesh b_mesh = object_to_mesh(b_data,
b_ob,
b_scene,
@@ -1041,8 +1167,8 @@ void BlenderSync::sync_mesh_motion(BL::Object& b_ob,
}
/* skip empty meshes */
size_t numverts = mesh->verts.size();
size_t numkeys = mesh->curve_keys.size();
const size_t numverts = mesh->verts.size();
const size_t numkeys = mesh->curve_keys.size();
if(!numverts && !numkeys)
return;
@@ -1100,13 +1226,12 @@ void BlenderSync::sync_mesh_motion(BL::Object& b_ob,
/* TODO(sergey): Perform preliminary check for number of verticies. */
if(numverts) {
/* find attributes */
/* Find attributes. */
Attribute *attr_mP = mesh->attributes.find(ATTR_STD_MOTION_VERTEX_POSITION);
Attribute *attr_mN = mesh->attributes.find(ATTR_STD_MOTION_VERTEX_NORMAL);
Attribute *attr_N = mesh->attributes.find(ATTR_STD_VERTEX_NORMAL);
bool new_attribute = false;
/* add new attributes if they don't exist already */
/* Add new attributes if they don't exist already. */
if(!attr_mP) {
attr_mP = mesh->attributes.add(ATTR_STD_MOTION_VERTEX_POSITION);
if(attr_N)
@@ -1114,22 +1239,21 @@ void BlenderSync::sync_mesh_motion(BL::Object& b_ob,
new_attribute = true;
}
/* load vertex data from mesh */
/* Load vertex data from mesh. */
float3 *mP = attr_mP->data_float3() + time_index*numverts;
float3 *mN = (attr_mN)? attr_mN->data_float3() + time_index*numverts: NULL;
/* NOTE: We don't copy more that existing amount of vertices to prevent
* possible memory corruption.
*/
BL::Mesh::vertices_iterator v;
int i = 0;
for(b_mesh.vertices.begin(v); v != b_mesh.vertices.end() && i < numverts; ++v, ++i) {
mP[i] = get_float3(v->co());
if(mN)
mN[i] = get_float3(v->normal());
}
/* in case of new attribute, we verify if there really was any motion */
if(new_attribute) {
/* In case of new attribute, we verify if there really was any motion. */
if(b_mesh.vertices.length() != numverts ||
memcmp(mP, &mesh->verts[0], sizeof(float3)*numverts) == 0)
{
@@ -1152,7 +1276,6 @@ void BlenderSync::sync_mesh_motion(BL::Object& b_ob,
* they had no motion, but we need them anyway now */
float3 *P = &mesh->verts[0];
float3 *N = (attr_N)? attr_N->data_float3(): NULL;
for(int step = 0; step < time_index; step++) {
memcpy(attr_mP->data_float3() + step*numverts, P, sizeof(float3)*numverts);
if(attr_mN)
@@ -1160,6 +1283,16 @@ void BlenderSync::sync_mesh_motion(BL::Object& b_ob,
}
}
}
else {
if(b_mesh.vertices.length() != numverts) {
VLOG(1) << "Topology differs, discarding motion blur for object "
<< b_ob.name() << " at time " << time_index;
memcpy(mP, &mesh->verts[0], sizeof(float3)*numverts);
if(mN != NULL) {
memcpy(mN, attr_N->data_float3(), sizeof(float3)*numverts);
}
}
}
}
/* hair motion */
@@ -1171,4 +1304,3 @@ void BlenderSync::sync_mesh_motion(BL::Object& b_ob,
}
CCL_NAMESPACE_END

View File

@@ -14,24 +14,24 @@
* limitations under the License.
*/
#include "camera.h"
#include "integrator.h"
#include "graph.h"
#include "light.h"
#include "mesh.h"
#include "object.h"
#include "scene.h"
#include "nodes.h"
#include "particles.h"
#include "shader.h"
#include "render/camera.h"
#include "render/integrator.h"
#include "render/graph.h"
#include "render/light.h"
#include "render/mesh.h"
#include "render/object.h"
#include "render/scene.h"
#include "render/nodes.h"
#include "render/particles.h"
#include "render/shader.h"
#include "blender_object_cull.h"
#include "blender_sync.h"
#include "blender_util.h"
#include "blender/blender_object_cull.h"
#include "blender/blender_sync.h"
#include "blender/blender_util.h"
#include "util_foreach.h"
#include "util_hash.h"
#include "util_logging.h"
#include "util/util_foreach.h"
#include "util/util_hash.h"
#include "util/util_logging.h"
CCL_NAMESPACE_BEGIN
@@ -343,6 +343,13 @@ Object *BlenderSync::sync_object(BL::Object& b_parent,
object_updated = true;
}
PointerRNA cobject = RNA_pointer_get(&b_ob.ptr, "cycles");
bool is_shadow_catcher = get_boolean(cobject, "is_shadow_catcher");
if(is_shadow_catcher != object->is_shadow_catcher) {
object->is_shadow_catcher = is_shadow_catcher;
object_updated = true;
}
/* object sync
* transform comparison should not be needed, but duplis don't work perfect
* in the depsgraph and may not signal changes, so this is a workaround */
@@ -372,27 +379,16 @@ Object *BlenderSync::sync_object(BL::Object& b_parent,
}
}
/* random number */
object->random_id = hash_string(object->name.c_str());
if(persistent_id) {
for(int i = 0; i < OBJECT_PERSISTENT_ID_SIZE; i++)
object->random_id = hash_int_2d(object->random_id, persistent_id[i]);
}
else
object->random_id = hash_int_2d(object->random_id, 0);
if(b_parent.ptr.data != b_ob.ptr.data)
object->random_id ^= hash_int(hash_string(b_parent.name().c_str()));
/* dupli texture coordinates */
/* dupli texture coordinates and random_id */
if(b_dupli_ob) {
object->dupli_generated = 0.5f*get_float3(b_dupli_ob.orco()) - make_float3(0.5f, 0.5f, 0.5f);
object->dupli_uv = get_float2(b_dupli_ob.uv());
object->random_id = b_dupli_ob.random_id();
}
else {
object->dupli_generated = make_float3(0.0f, 0.0f, 0.0f);
object->dupli_uv = make_float2(0.0f, 0.0f);
object->random_id = hash_int_2d(hash_string(object->name.c_str()), 0);
}
object->tag_update(scene);

View File

@@ -16,9 +16,9 @@
#include <cstdlib>
#include "camera.h"
#include "render/camera.h"
#include "blender_object_cull.h"
#include "blender/blender_object_cull.h"
CCL_NAMESPACE_BEGIN

View File

@@ -17,8 +17,8 @@
#ifndef __BLENDER_OBJECT_CULL_H__
#define __BLENDER_OBJECT_CULL_H__
#include "blender_sync.h"
#include "util_types.h"
#include "blender/blender_sync.h"
#include "util/util_types.h"
CCL_NAMESPACE_BEGIN

View File

@@ -14,14 +14,14 @@
* limitations under the License.
*/
#include "mesh.h"
#include "object.h"
#include "particles.h"
#include "render/mesh.h"
#include "render/object.h"
#include "render/particles.h"
#include "blender_sync.h"
#include "blender_util.h"
#include "blender/blender_sync.h"
#include "blender/blender_util.h"
#include "util_foreach.h"
#include "util/util_foreach.h"
CCL_NAMESPACE_BEGIN

View File

@@ -16,21 +16,21 @@
#include <Python.h>
#include "CCL_api.h"
#include "blender/CCL_api.h"
#include "blender_sync.h"
#include "blender_session.h"
#include "blender/blender_sync.h"
#include "blender/blender_session.h"
#include "util_foreach.h"
#include "util_logging.h"
#include "util_md5.h"
#include "util_opengl.h"
#include "util_path.h"
#include "util_string.h"
#include "util_types.h"
#include "util/util_foreach.h"
#include "util/util_logging.h"
#include "util/util_md5.h"
#include "util/util_opengl.h"
#include "util/util_path.h"
#include "util/util_string.h"
#include "util/util_types.h"
#ifdef WITH_OSL
#include "osl.h"
#include "render/osl.h"
#include <OSL/oslquery.h>
#include <OSL/oslconfig.h>
@@ -67,8 +67,10 @@ bool debug_flags_sync_from_scene(BL::Scene b_scene)
flags.cpu.sse3 = get_boolean(cscene, "debug_use_cpu_sse3");
flags.cpu.sse2 = get_boolean(cscene, "debug_use_cpu_sse2");
flags.cpu.qbvh = get_boolean(cscene, "debug_use_qbvh");
flags.cpu.split_kernel = get_boolean(cscene, "debug_use_cpu_split_kernel");
/* Synchronize CUDA flags. */
flags.cuda.adaptive_compile = get_boolean(cscene, "debug_use_cuda_adaptive_compile");
flags.cuda.split_kernel = get_boolean(cscene, "debug_use_cuda_split_kernel");
/* Synchronize OpenCL kernel type. */
switch(get_enum(cscene, "debug_opencl_kernel_type")) {
case 0:
@@ -104,6 +106,7 @@ bool debug_flags_sync_from_scene(BL::Scene b_scene)
}
/* Synchronize other OpenCL flags. */
flags.opencl.debug = get_boolean(cscene, "debug_use_opencl_debug");
flags.opencl.single_program = get_boolean(cscene, "debug_opencl_kernel_single_program");
return flags.opencl.device_type != opencl_device_type ||
flags.opencl.kernel_type != opencl_kernel_type;
}
@@ -641,7 +644,7 @@ static PyObject *debug_flags_reset_func(PyObject * /*self*/, PyObject * /*args*/
Py_RETURN_NONE;
}
static PyObject *set_resumable_chunks_func(PyObject * /*self*/, PyObject *args)
static PyObject *set_resumable_chunk_func(PyObject * /*self*/, PyObject *args)
{
int num_resumable_chunks, current_resumable_chunk;
if(!PyArg_ParseTuple(args, "ii",
@@ -676,6 +679,53 @@ static PyObject *set_resumable_chunks_func(PyObject * /*self*/, PyObject *args)
Py_RETURN_NONE;
}
static PyObject *set_resumable_chunk_range_func(PyObject * /*self*/, PyObject *args)
{
int num_chunks, start_chunk, end_chunk;
if(!PyArg_ParseTuple(args, "iii",
&num_chunks,
&start_chunk,
&end_chunk)) {
Py_RETURN_NONE;
}
if(num_chunks <= 0) {
fprintf(stderr, "Cycles: Bad value for number of resumable chunks.\n");
abort();
Py_RETURN_NONE;
}
if(start_chunk < 1 || start_chunk > num_chunks) {
fprintf(stderr, "Cycles: Bad value for start chunk number.\n");
abort();
Py_RETURN_NONE;
}
if(end_chunk < 1 || end_chunk > num_chunks) {
fprintf(stderr, "Cycles: Bad value for start chunk number.\n");
abort();
Py_RETURN_NONE;
}
if(start_chunk > end_chunk) {
fprintf(stderr, "Cycles: End chunk should be higher than start one.\n");
abort();
Py_RETURN_NONE;
}
VLOG(1) << "Initialized resumable render: "
<< "num_resumable_chunks=" << num_chunks << ", "
<< "start_resumable_chunk=" << start_chunk
<< "end_resumable_chunk=" << end_chunk;
BlenderSession::num_resumable_chunks = num_chunks;
BlenderSession::start_resumable_chunk = start_chunk;
BlenderSession::end_resumable_chunk = end_chunk;
printf("Cycles: Will render chunks %d to %d of %d\n",
start_chunk,
end_chunk,
num_chunks);
Py_RETURN_NONE;
}
static PyObject *get_device_types_func(PyObject * /*self*/, PyObject * /*args*/)
{
vector<DeviceInfo>& devices = Device::available_devices();
@@ -715,7 +765,8 @@ static PyMethodDef methods[] = {
{"debug_flags_reset", debug_flags_reset_func, METH_NOARGS, ""},
/* Resumable render */
{"set_resumable_chunks", set_resumable_chunks_func, METH_VARARGS, ""},
{"set_resumable_chunk", set_resumable_chunk_func, METH_VARARGS, ""},
{"set_resumable_chunk_range", set_resumable_chunk_range_func, METH_VARARGS, ""},
/* Compute Device selection */
{"get_device_types", get_device_types_func, METH_VARARGS, ""},

View File

@@ -16,36 +16,38 @@
#include <stdlib.h>
#include "background.h"
#include "buffers.h"
#include "camera.h"
#include "device.h"
#include "integrator.h"
#include "film.h"
#include "light.h"
#include "mesh.h"
#include "object.h"
#include "scene.h"
#include "session.h"
#include "shader.h"
#include "render/background.h"
#include "render/buffers.h"
#include "render/camera.h"
#include "device/device.h"
#include "render/integrator.h"
#include "render/film.h"
#include "render/light.h"
#include "render/mesh.h"
#include "render/object.h"
#include "render/scene.h"
#include "render/session.h"
#include "render/shader.h"
#include "util_color.h"
#include "util_foreach.h"
#include "util_function.h"
#include "util_hash.h"
#include "util_logging.h"
#include "util_progress.h"
#include "util_time.h"
#include "util/util_color.h"
#include "util/util_foreach.h"
#include "util/util_function.h"
#include "util/util_hash.h"
#include "util/util_logging.h"
#include "util/util_progress.h"
#include "util/util_time.h"
#include "blender_sync.h"
#include "blender_session.h"
#include "blender_util.h"
#include "blender/blender_sync.h"
#include "blender/blender_session.h"
#include "blender/blender_util.h"
CCL_NAMESPACE_BEGIN
bool BlenderSession::headless = false;
int BlenderSession::num_resumable_chunks = 0;
int BlenderSession::current_resumable_chunk = 0;
int BlenderSession::start_resumable_chunk = 0;
int BlenderSession::end_resumable_chunk = 0;
BlenderSession::BlenderSession(BL::RenderEngine& b_engine,
BL::UserPreferences& b_userpref,
@@ -68,6 +70,7 @@ BlenderSession::BlenderSession(BL::RenderEngine& b_engine,
background = true;
last_redraw_time = 0.0;
start_resize_time = 0.0;
last_status_time = 0.0;
}
BlenderSession::BlenderSession(BL::RenderEngine& b_engine,
@@ -93,6 +96,7 @@ BlenderSession::BlenderSession(BL::RenderEngine& b_engine,
background = false;
last_redraw_time = 0.0;
start_resize_time = 0.0;
last_status_time = 0.0;
}
BlenderSession::~BlenderSession()
@@ -989,10 +993,14 @@ void BlenderSession::update_status_progress()
if(substatus.size() > 0)
status += " | " + substatus;
if(status != last_status) {
double current_time = time_dt();
/* When rendering in a window, redraw the status at least once per second to keep the elapsed and remaining time up-to-date.
* For headless rendering, only report when something significant changes to keep the console output readable. */
if(status != last_status || (!headless && (current_time - last_status_time) > 1.0)) {
b_engine.update_stats("", (timestatus + scene + status).c_str());
b_engine.update_memory_stats(mem_used, mem_peak);
last_status = status;
last_status_time = current_time;
}
if(progress != last_progress) {
b_engine.update_progress(progress);
@@ -1342,9 +1350,21 @@ void BlenderSession::update_resumable_tile_manager(int num_samples)
return;
}
int num_samples_per_chunk = (int)ceilf((float)num_samples / num_resumable_chunks);
int range_start_sample = num_samples_per_chunk * (current_resumable_chunk - 1);
int range_num_samples = num_samples_per_chunk;
const int num_samples_per_chunk = (int)ceilf((float)num_samples / num_resumable_chunks);
int range_start_sample, range_num_samples;
if(current_resumable_chunk != 0) {
/* Single chunk rendering. */
range_start_sample = num_samples_per_chunk * (current_resumable_chunk - 1);
range_num_samples = num_samples_per_chunk;
}
else {
/* Ranged-chunks. */
const int num_chunks = end_resumable_chunk - start_resumable_chunk + 1;
range_start_sample = num_samples_per_chunk * (start_resumable_chunk - 1);
range_num_samples = num_chunks * num_samples_per_chunk;
}
/* Make sure we don't overshoot. */
if(range_start_sample + range_num_samples > num_samples) {
range_num_samples = num_samples - range_num_samples;
}
@@ -1352,6 +1372,9 @@ void BlenderSession::update_resumable_tile_manager(int num_samples)
VLOG(1) << "Samples range start is " << range_start_sample << ", "
<< "number of samples to render is " << range_num_samples;
scene->integrator->start_sample = range_start_sample;
scene->integrator->tag_update(scene);
session->tile_manager.range_start_sample = range_start_sample;
session->tile_manager.range_num_samples = range_num_samples;
}

View File

@@ -17,12 +17,12 @@
#ifndef __BLENDER_SESSION_H__
#define __BLENDER_SESSION_H__
#include "device.h"
#include "scene.h"
#include "session.h"
#include "bake.h"
#include "device/device.h"
#include "render/scene.h"
#include "render/session.h"
#include "render/bake.h"
#include "util_vector.h"
#include "util/util_vector.h"
CCL_NAMESPACE_BEGIN
@@ -113,6 +113,7 @@ public:
string last_status;
string last_error;
float last_progress;
double last_status_time;
int width, height;
double start_resize_time;
@@ -137,6 +138,10 @@ public:
/* Current resumable chunk index to render. */
static int current_resumable_chunk;
/* Alternative to single-chunk rendering to render a range of chunks. */
static int start_resumable_chunk;
static int end_resumable_chunk;
protected:
void do_write_update_render_result(BL::RenderResult& b_rr,
BL::RenderLayer& b_rlay,

View File

@@ -14,20 +14,23 @@
* limitations under the License.
*/
#include "background.h"
#include "graph.h"
#include "light.h"
#include "nodes.h"
#include "osl.h"
#include "scene.h"
#include "shader.h"
#include "render/background.h"
#include "render/graph.h"
#include "render/light.h"
#include "render/nodes.h"
#include "render/osl.h"
#include "render/scene.h"
#include "render/shader.h"
#include "blender_texture.h"
#include "blender_sync.h"
#include "blender_util.h"
#include "blender/blender_texture.h"
#include "blender/blender_sync.h"
#include "blender/blender_util.h"
#include "util_debug.h"
#include "util_string.h"
#include "util/util_debug.h"
#include "util/util_foreach.h"
#include "util/util_string.h"
#include "util/util_set.h"
#include "util/util_task.h"
CCL_NAMESPACE_BEGIN
@@ -518,6 +521,19 @@ static ShaderNode *add_node(Scene *scene,
}
node = hair;
}
else if(b_node.is_a(&RNA_ShaderNodeBsdfPrincipled)) {
BL::ShaderNodeBsdfPrincipled b_principled_node(b_node);
PrincipledBsdfNode *principled = new PrincipledBsdfNode();
switch (b_principled_node.distribution()) {
case BL::ShaderNodeBsdfPrincipled::distribution_GGX:
principled->distribution = CLOSURE_BSDF_MICROFACET_GGX_GLASS_ID;
break;
case BL::ShaderNodeBsdfPrincipled::distribution_MULTI_GGX:
principled->distribution = CLOSURE_BSDF_MICROFACET_MULTI_GGX_GLASS_ID;
break;
}
node = principled;
}
else if(b_node.is_a(&RNA_ShaderNodeBsdfTranslucent)) {
node = new TranslucentBsdfNode();
}
@@ -609,7 +625,8 @@ static ShaderNode *add_node(Scene *scene,
bool is_builtin = b_image.packed_file() ||
b_image.source() == BL::Image::source_GENERATED ||
b_image.source() == BL::Image::source_MOVIE ||
b_engine.is_preview();
(b_engine.is_preview() &&
b_image.source() != BL::Image::source_SEQUENCE);
if(is_builtin) {
/* for builtin images we're using image datablock name to find an image to
@@ -640,7 +657,8 @@ static ShaderNode *add_node(Scene *scene,
image->filename.string(),
image->builtin_data,
get_image_interpolation(b_image_node),
get_image_extension(b_image_node));
get_image_extension(b_image_node),
image->use_alpha);
}
}
image->color_space = (NodeImageColorSpace)b_image_node.color_space();
@@ -661,7 +679,8 @@ static ShaderNode *add_node(Scene *scene,
bool is_builtin = b_image.packed_file() ||
b_image.source() == BL::Image::source_GENERATED ||
b_image.source() == BL::Image::source_MOVIE ||
b_engine.is_preview();
(b_engine.is_preview() &&
b_image.source() != BL::Image::source_SEQUENCE);
if(is_builtin) {
int scene_frame = b_scene.frame_current();
@@ -686,7 +705,8 @@ static ShaderNode *add_node(Scene *scene,
env->filename.string(),
env->builtin_data,
get_image_interpolation(b_env_node),
EXTENSION_REPEAT);
EXTENSION_REPEAT,
env->use_alpha);
}
}
env->color_space = (NodeImageColorSpace)b_env_node.color_space();
@@ -823,7 +843,8 @@ static ShaderNode *add_node(Scene *scene,
point_density->filename.string(),
point_density->builtin_data,
point_density->interpolation,
EXTENSION_CLIP);
EXTENSION_CLIP,
true);
}
node = point_density;
@@ -1159,6 +1180,9 @@ void BlenderSync::sync_materials(bool update_all)
/* material loop */
BL::BlendData::materials_iterator b_mat;
TaskPool pool;
set<Shader*> updated_shaders;
for(b_data.materials.begin(b_mat); b_mat != b_data.materials.end(); ++b_mat) {
Shader *shader;
@@ -1194,9 +1218,37 @@ void BlenderSync::sync_materials(bool update_all)
shader->displacement_method = (experimental) ? get_displacement_method(cmat) : DISPLACE_BUMP;
shader->set_graph(graph);
shader->tag_update(scene);
/* By simplifying the shader graph as soon as possible, some
* redundant shader nodes might be removed which prevents loading
* unnecessary attributes later.
*
* However, since graph simplification also accounts for e.g. mix
* weight, this would cause frequent expensive resyncs in interactive
* sessions, so for those sessions optimization is only performed
* right before compiling.
*/
if(!preview) {
pool.push(function_bind(&ShaderGraph::simplify, graph, scene));
/* NOTE: Update shaders out of the threads since those routines
* are accessing and writing to a global context.
*/
updated_shaders.insert(shader);
}
else {
/* NOTE: Update tagging can access links which are being
* optimized out.
*/
shader->tag_update(scene);
}
}
}
pool.wait_work();
foreach(Shader *shader, updated_shaders) {
shader->tag_update(scene);
}
}
/* Sync World */

View File

@@ -14,29 +14,29 @@
* limitations under the License.
*/
#include "background.h"
#include "camera.h"
#include "film.h"
#include "graph.h"
#include "integrator.h"
#include "light.h"
#include "mesh.h"
#include "nodes.h"
#include "object.h"
#include "scene.h"
#include "shader.h"
#include "curves.h"
#include "render/background.h"
#include "render/camera.h"
#include "render/film.h"
#include "render/graph.h"
#include "render/integrator.h"
#include "render/light.h"
#include "render/mesh.h"
#include "render/nodes.h"
#include "render/object.h"
#include "render/scene.h"
#include "render/shader.h"
#include "render/curves.h"
#include "device.h"
#include "device/device.h"
#include "blender_sync.h"
#include "blender_session.h"
#include "blender_util.h"
#include "blender/blender_sync.h"
#include "blender/blender_session.h"
#include "blender/blender_util.h"
#include "util_debug.h"
#include "util_foreach.h"
#include "util_opengl.h"
#include "util_hash.h"
#include "util/util_debug.h"
#include "util/util_foreach.h"
#include "util/util_opengl.h"
#include "util/util_hash.h"
CCL_NAMESPACE_BEGIN
@@ -322,6 +322,15 @@ void BlenderSync::sync_integrator()
integrator->volume_samples = volume_samples;
}
if(b_scene.render().use_simplify()) {
if(preview) {
integrator->ao_bounces = get_int(cscene, "ao_bounces");
}
else {
integrator->ao_bounces = get_int(cscene, "ao_bounces_render");
}
}
if(integrator->modified(previntegrator))
integrator->tag_update(scene);
}

View File

@@ -22,15 +22,15 @@
#include "RNA_access.h"
#include "RNA_blender_cpp.h"
#include "blender_util.h"
#include "blender/blender_util.h"
#include "scene.h"
#include "session.h"
#include "render/scene.h"
#include "render/session.h"
#include "util_map.h"
#include "util_set.h"
#include "util_transform.h"
#include "util_vector.h"
#include "util/util_map.h"
#include "util/util_set.h"
#include "util/util_transform.h"
#include "util/util_vector.h"
CCL_NAMESPACE_BEGIN

View File

@@ -14,7 +14,7 @@
* limitations under the License.
*/
#include "blender_texture.h"
#include "blender/blender_texture.h"
CCL_NAMESPACE_BEGIN

View File

@@ -18,7 +18,7 @@
#define __BLENDER_TEXTURE_H__
#include <stdlib.h>
#include "blender_sync.h"
#include "blender/blender_sync.h"
CCL_NAMESPACE_BEGIN

View File

@@ -17,14 +17,15 @@
#ifndef __BLENDER_UTIL_H__
#define __BLENDER_UTIL_H__
#include "mesh.h"
#include "render/mesh.h"
#include "util_map.h"
#include "util_path.h"
#include "util_set.h"
#include "util_transform.h"
#include "util_types.h"
#include "util_vector.h"
#include "util/util_algorithm.h"
#include "util/util_map.h"
#include "util/util_path.h"
#include "util/util_set.h"
#include "util/util_transform.h"
#include "util/util_types.h"
#include "util/util_vector.h"
/* Hacks to hook into Blender API
* todo: clean this up ... */
@@ -78,7 +79,7 @@ static inline BL::Mesh object_to_mesh(BL::BlendData& data,
me.calc_normals_split();
}
else {
me.split_faces();
me.split_faces(false);
}
}
if(subdivision_type == Mesh::SUBDIVISION_NONE) {
@@ -173,22 +174,19 @@ static inline void curvemapping_color_to_array(BL::CurveMapping& cumap,
if(rgb_curve) {
BL::CurveMap mapI = cumap.curves[3];
for(int i = 0; i < size; i++) {
float t = min_x + (float)i/(float)(size-1) * range_x;
data[i][0] = mapR.evaluate(mapI.evaluate(t));
data[i][1] = mapG.evaluate(mapI.evaluate(t));
data[i][2] = mapB.evaluate(mapI.evaluate(t));
const float t = min_x + (float)i/(float)(size-1) * range_x;
data[i] = make_float3(mapR.evaluate(mapI.evaluate(t)),
mapG.evaluate(mapI.evaluate(t)),
mapB.evaluate(mapI.evaluate(t)));
}
}
else {
for(int i = 0; i < size; i++) {
float t = min_x + (float)i/(float)(size-1) * range_x;
data[i][0] = mapR.evaluate(t);
data[i][1] = mapG.evaluate(t);
data[i][2] = mapB.evaluate(t);
data[i] = make_float3(mapR.evaluate(t),
mapG.evaluate(t),
mapB.evaluate(t));
}
}
}
@@ -786,6 +784,35 @@ struct ParticleSystemKey {
}
};
class EdgeMap {
public:
EdgeMap() {
}
void clear() {
edges_.clear();
}
void insert(int v0, int v1) {
get_sorted_verts(v0, v1);
edges_.insert(std::pair<int, int>(v0, v1));
}
bool exists(int v0, int v1) {
get_sorted_verts(v0, v1);
return edges_.find(std::pair<int, int>(v0, v1)) != edges_.end();
}
protected:
void get_sorted_verts(int& v0, int& v1) {
if(v0 > v1) {
swap(v0, v1);
}
}
set< std::pair<int, int> > edges_;
};
CCL_NAMESPACE_END
#endif /* __BLENDER_UTIL_H__ */

View File

@@ -1,12 +1,6 @@
set(INC
.
../graph
../kernel
../kernel/svm
../render
../util
../device
..
)
set(INC_SYS
@@ -14,6 +8,8 @@ set(INC_SYS
set(SRC
bvh.cpp
bvh2.cpp
bvh4.cpp
bvh_binning.cpp
bvh_build.cpp
bvh_node.cpp
@@ -24,6 +20,8 @@ set(SRC
set(SRC_HEADERS
bvh.h
bvh2.h
bvh4.h
bvh_binning.h
bvh_build.h
bvh_node.h

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