Commit Graph

64618 Commits

Author SHA1 Message Date
Dalai Felinto
e0db647d35 Fix region_2d_to_origin_3d not working with ortho view
In some cases when:
* the viewport was in the camera mode
* the camera was ortho
* the view was not fitting (as oppose to use HOME)

region_2d_to_origin_3d would misbehave (and consequently region_2d_to_location_3d).

Sample addon to test it:
```
import bpy

from bpy_extras.view3d_utils import (
    region_2d_to_location_3d,
    )

from mathutils import (
    Vector,
    )

class MoveXYOperator(bpy.types.Operator):
    """Translate the view using mouse events"""
    bl_idname = "view3d.move_xy"
    bl_label = "Move XY"

    @classmethod
    def poll(cls, context):
        return context.object

    def modal(self, context, event):
        if event.type == 'MOUSEMOVE':
            self.move(context, event)

        elif event.type in {'LEFTMOUSE', 'RIGHTMOUSE', 'ESC'}:
            return {'FINISHED'}

        return {'RUNNING_MODAL'}

    def invoke(self, context, event):
        if context.space_data.type == 'VIEW_3D':
            self.ob = context.object
            context.window_manager.modal_handler_add(self)
            return {'RUNNING_MODAL'}
        else:
            self.report({'WARNING'}, "Active space must be a View3d")
            return {'CANCELLED'}

    def move(self, context, event):
        xy = region_2d_to_location_3d(
                context.region,
                context.space_data.region_3d,
                (event.mouse_region_x, event.mouse_region_y),
                Vector(),
                ).xy

        self.ob.location.xy = xy

def register():
    bpy.utils.register_class(MoveXYOperator)

def unregister():
    bpy.utils.unregister_class(MoveXYOperator)

if __name__ == "__main__":
    register()
```
2016-06-14 18:03:07 -03:00
Campbell Barton
09da51e603 Text Editor: auto-complete removed entire word on undo 2016-06-15 04:28:13 +10:00
Campbell Barton
81f435202a VSE: minor drawing glitch with meta's
Meta contents could obscure meta selection outline, draw after.
2016-06-15 04:08:03 +10:00
Campbell Barton
28398f654d Correct update issue caused by recent commit
VSE effects within a meta-strip could fail to update on cancel.
2016-06-15 04:08:03 +10:00
Campbell Barton
eaf894db6d Fix VSE updating effects within metas
Missing update caused internal lengths to be wrong.
2016-06-15 02:44:34 +10:00
Thomas Dinges
a3a7e46318 Cleanup: Remove outdated comment, visibility layers in kernel have been removed. 2016-06-14 16:46:44 +02:00
Bastien Montagne
9182e07c0e FileSpace cleanup: make ED_path_extension_type public.
Maybe we should move it to BLI, but not sure how, and where (and its defines
are SpaceFile's ones, meh :| ).
2016-06-14 16:30:16 +02:00
Bastien Montagne
c7e7c1b241 Write .blend file: refactor & fixes re ID block itself.
Factorized writing of ID block's data (so far, only IDProps) into own helper func.
This also fixes missing IDProp (aka custom data) saving from GreasePencil and Library
datablocks (and add comment about why we do not save WM IDProps).

Finaly, it ensures all ID-related data are written immediately after the ID itself
(was not the case for all data types previously, some were writting their own data
before IDProps). This is not a fix (.blend file format does not enforce any order
on sub-data of datablocks, they only have to be after datablock struct itself in file),
but makes things more consistent.
2016-06-14 15:03:49 +02:00
Campbell Barton
424f41ad1c Fix T48649: VSE meta-strip overlap shuffles recursively 2016-06-14 21:57:55 +10:00
Campbell Barton
180aad5e0b Correct sequencer transform check
Check to avoid operating on same strip multiple times wasn't working.

Harmless but better make it functional.
2016-06-14 21:57:55 +10:00
Gaia Clary
a47937454c fix T48602: Changed The Collada validator to treat faces with < 3 verts as Warning and let the Mesh Validator take care of the cleanup 2016-06-14 13:09:10 +02:00
Sergey Sharybin
6d111a233c Fix T48613: Bump mapping in cycles is not shown on the viewport when the material use node groups 2016-06-14 11:31:00 +02:00
Campbell Barton
51cb4ea2cf Fix T48154: Decimate topology changes with scale
This can't be avoided completely, however the threshold used can be much lower.
2016-06-14 17:12:29 +10:00
Bastien Montagne
049f715d1c Usual UI/i18n message fixes. 2016-06-14 00:16:39 +02:00
Phil Gosch
9c600435fa Made incremental snapping intervalls smaller for UV editor
Before the intervall was set to 0.125 which effectively resulted in 8 positions across the UV space (per axis).
I halved that value, holding shift enables an even finer movement.

This change was ported over from my soc-2016-uv_tools branch after talking with howardt, ideasman42 and hackerman-
2016-06-13 18:35:32 +02:00
Campbell Barton
abb9d0b0ad Curve Fitting: add high-quality flag
When this flag is set - even when the curve error is under the threshold,
keep attempting a better fit.

Enable this for freehand drawing, since it gives nicer results and isn't noticeably slower.
2016-06-14 02:27:32 +10:00
Campbell Barton
b0985b393c Fix T48595: UI glitch with driver menu re-opening
Holding Ctrl-D would keep opening driver menus.
2016-06-14 01:52:35 +10:00
Howard Trickey
520691e591 Bevel segments also changeable with mouse (S toggle).
Also, can use numeric input to set segments and profile when
in those respective value-adjusting modes (as per S or P toggle).
Finally, fixed problem with previous bevel commit: when changing
value-adjusting mode, would like to start off resumed value adjustment
where it was before.
2016-06-13 09:14:13 -04:00
Campbell Barton
08baf3ea79 Keymap: include 'Dopesheet Generic' 2016-06-13 23:03:00 +10:00
Sergey Sharybin
5be4d0b328 Fix misleading indentation in ImBuf 2016-06-13 14:46:04 +02:00
Thomas Dinges
f87611622d Fix typo in variable name as well. 2016-06-13 14:08:06 +02:00
Campbell Barton
f2c5ea2516 Fix own error w/ undefined behavior
This happened to work for me but caused issues on OSX.
2016-06-13 21:57:22 +10:00
Stefan Werner
2566652ae6 Cycles: fixed a typo that would crash shaders that use the "Is Diffuse Ray" output of the LightPath node 2016-06-13 13:33:56 +02:00
Campbell Barton
617c4d6adb Fix glShadeModel being left flat in edit-mode draw 2016-06-13 19:21:46 +10:00
Sergey Sharybin
8d8c5a542c Cycles: Fix unhandled enumerator in OSL switch
Unsigned int is not supported by OSL as far as i concerned, so should not
really matter here. However, might be wrong and perhaps more proper idea
would be so set it as regular int?
2016-06-13 10:15:39 +02:00
Campbell Barton
1883dbd8c3 Fix T48616: Auto-merge selects extra edges
Auto-merge caused all edges between selected vertices to be selected.
This only makes sense in vertex-select-mode.

Correct edge-flag merging code, which now merges flags from multiple edges.
2016-06-13 18:07:59 +10:00
cefbe8fe54 Fix build error with GCC 6.1. 2016-06-12 21:29:19 +02:00
24d53f79b2 Fix Cycles debug build assert on some platforms, tighten checks to avoid this in the future. 2016-06-12 17:35:15 +02:00
Bastien Montagne
055001111e Fix T48604: Crash on undo due to bad drawing code.
Short story: draw_lamp would add itself to delayed transp drawing list from 'xray' drawing step.
This was broken, since delayed transp drawing list is always handled **before** delayed xray one.

After undo it lead to segfault crash, v3d->afterdraw_transp still having reference to old freed scene's base.

Also added asserts that those afterdraw list are empty at end of drawing step, should help
avoiding that kind of issue in future.
2016-06-12 17:06:50 +02:00
Campbell Barton
2033f47e55 Curve Fitting: offset based fallback to calculate cubics
Add a new fallback method that uses offset distance from the curve to the line between both points,
for freehand drawing it typically only fives minor improvements (1-3% fewer points),
for curve dissolve the improvements are more noticeable.
2016-06-12 22:25:43 +10:00
Campbell Barton
66b12ef4ab BLI_math: cleanup arg names
project functions arg naming made it hard to tell which vector was projected onto.
2016-06-12 15:39:04 +10:00
Campbell Barton
65df2fd997 bmesh py api: expose BM_face_calc_tangent_*
D1988 by @wisaac, with own edits and improvements.

This improves on existing tangent calculation functions too.

- BM_face_calc_tangent_auto: Chooses method based on number of sides, used by manipulator (not exposed to Python).
- BM_face_calc_tangent_edge: from longest edge.
- BM_face_calc_tangent_edge_pair: from longest edge-pair (most useful with quads).
- BM_face_calc_tangent_edge_diagonal: edge farthest from any vertex.
- BM_face_calc_tangent_vert_diagonal: vert farthest from any vertex.

Also optimize BM_vert_tri_calc_tangent_edge* functions to avoid sqrt.
2016-06-12 15:12:34 +10:00
Campbell Barton
421ec97276 Docs: Support out-of-source reference-API builds
This was originally supported, however relative links to examples & templates made it fail.
Now files in the source tree are copied to the build-dir, with ".." replaced with "__"
to avoid having to mirror Blender's source-layout in the Sphinx build-dir.

Also skip uploading the built docs when an SSH user-name isn't passed to sphinx_doc_gen.sh
instead of aborting (so people w/o SSH access to our servers can use the shell-script).
2016-06-12 11:31:28 +10:00
Campbell Barton
2b15a588a1 Cleanup: API docs (whitespace/line length) 2016-06-12 10:05:35 +10:00
Thomas Dinges
1cd3676d4d Cleanup, remove unneeded variable. 2016-06-12 00:01:57 +02:00
Thomas Dinges
324bed3843 Fix compiler warning for unused variables. 2016-06-11 23:58:12 +02:00
ebdd2e0b6d Cycles: make shader node enums consistently lower case, update OSL shaders accordingly. 2016-06-11 23:50:11 +02:00
b8112a8960 Fix OS X build after Decklink changes, it is not supported yet so don't enable it. 2016-06-11 23:50:06 +02:00
Benoit Bolsee
eea89417f4 BGE: DeckLink card support for video capture and streaming.
You can capture and stream video in the BGE using the DeckLink video
   cards from Black Magic Design. You need a card and Desktop Video software
   version 10.4 or above to use these features in the BGE.
   Many thanks to Nuno Estanquiero who tested the patch extensively
   on a variety of Decklink products, it wouldn't have been possible without
   his help.
   You can find a brief summary of the decklink features here: https://wiki.blender.org/index.php/Dev:Source/GameEngine/Decklink
   The full API details and samples are in the Python API documentation.

bge.texture.VideoDeckLink(format, capture=0):

   Use this object to capture a video stream. the format argument describes
   the video and pixel formats and the capture argument the card number.
   This object can be used as a source for bge.texture.Texture so that the frame
   is sent to the GPU, or by itself using the new refresh method to get the video
   frame in a buffer.
   The frames are usually not in RGB but in YUV format (8bit or 10bit); they
   require a shader to extract the RGB components in the GPU. Details and sample
   shaders in the documentation.
   3D video capture is supported: the frames are double height with left and right
   eyes in top-bottom order. The 'eye' uniform (see setUniformEyef) can be used to
   sample the 3D frame when the BGE is also in stereo mode. This allows to composite
   a 3D video stream with a 3D scene and render it in stereo.
   In Windows, and if you have a nVidia Quadro GPU, you can benefit of an additional
   performance boost by using 'GPUDirect': a method to send a video frame to the GPU
   without going through the OGL driver. The 'pinned memory' OGL extension is also
   supported (only on high-end AMD GPU) with the same effect.

bge.texture.DeckLink(cardIdx=0, format=""):

   Use this object to send video frame to a DeckLink card. Only the immediate mode
   is supported, the scheduled mode is not implemented.
   This object is similar to bge.texture.Texture: you need to attach a image source
   and call refresh() to compute and send the frame to the card.
   This object is best suited for video keying: a video stream (not captured) flows
   through the card and the frame you send to the card are displayed above it (the
   card does the compositing automatically based on the alpha channel).
   At the time of this commit, 3D video keying is supported in the BGE but not in the
   DeckLink card due to a color space issue.
2016-06-11 22:26:05 +02:00
Benoit Bolsee
c0bf881ebf BL_Shader.setUniformEyef(name)
defines a uniform that reflects the eye being rendered in stereo mode:
    0.0 for the left eye, 0.5 for the right eye.
    In non stereo mode, the value of the uniform is fixed to 0.0.
    The typical use of this uniform is in stereo mode to sample stereo textures
    containing the left and right eye images in a top-bottom order.

    python:
      shader = obj.meshes[0].materials[mat].getShader()
      shader.setUniformEyef("eye")

    shader:
      uniform float eye;
      uniform sampler2D tex;
      void main(void)
      {
         vec4 color;
         float ty, tx;
         tx = gl_TexCoord[0].x;
         ty = eye+gl_TexCoord[0].y*0.5;
         // ty will be between 0 and 0.5 for the left eye render
         // and 0.5 and 1.0 for the right eye render.
         color = texture(tex, vec2(tx, ty));
         ...
      }
2016-06-11 22:24:18 +02:00
Benoit Bolsee
fa9bb2ffe9 Atomic ops: Fix atomic_add_uint32 and atomic_sub_uint32 in Windows
The assembler version in Windows used to return the previous value
    of the variable while all the other versions return the new value.
    This is now fixed for consistency.
    Note: this bug had no effect on blender because no part of the code
    use the return value of these functions, but the future BGE DeckLink
    module makes use of it to implement reference counter.
2016-06-11 22:15:25 +02:00
Benoit Bolsee
40f1c4f343 BGE: Various render improvements.
bge.logic.setRender(flag) to enable/disable render.
    The render pass is enabled by default but it can be disabled with
    bge.logic.setRender(False).
    Once disabled, the render pass is skipped and a new logic frame starts
    immediately. Note that VSync no longer limits the fps when render is off
    but the 'Use Frame Rate' option in the Render Properties still does.
    To run as many frames as possible, untick the option
    This function is useful when you don't need the default render, e.g.
    when doing offscreen render to an alternate device than the monitor.
    Note that without VSync, you must limit the frame rate by other means.

fbo = bge.render.offScreenCreate(width,height,[,samples=0][,target=bge.render.RAS_OFS_RENDER_BUFFER])
    Use this method to create an offscreen buffer of given size, with given MSAA
    samples and targetting either a render buffer (bge.render.RAS_OFS_RENDER_BUFFER)
    or a texture (bge.render.RAS_OFS_RENDER_TEXTURE). Use the former if you want to
    retrieve the frame buffer on the host and the latter if you want to pass the render
    to another context (texture are proper OGL object, render buffers aren't)
    The object created by this function can only be used as a parameter of the
    bge.texture.ImageRender() constructor to send the the render to the FBO rather
    than to the frame buffer. This is best suited when you want to create a render
    of specific size, or if you need an image with an alpha channel.

bge.texture.<imagetype>.refresh(buffer=None, format="RGBA", ts=-1.0)
    Without arg, the refresh method of the image objects is pretty much a no-op, it
    simply invalidates the image so that on next texture refresh, the image will
    be recalculated.
    It is now possible to pass an optional buffer object to transfer the image (and
    recalculate it if it was invalid) to an external object. The object must implement
    the 'buffer protocol'. The image will be transfered as "RGBA" or "BGRA" pixels
    depending on format argument (only those 2 formats are supported) and ts is an
    optional timestamp in the image depends on it (e.g. VideoFFmpeg playing a video file).
    With this function you don't need anymore to link the image object to a Texture
    object to use: the image object is self-sufficient.

bge.texture.ImageRender(scene, camera, fbo=None)
    Render to buffer is possible by passing a FBO object (see offScreenCreate).

bge.texture.ImageRender.render()
    Allows asynchronous render: call this method to render the scene but without
    extracting the pixels yet. The function returns as soon as the render commands
    have been send to the GPU. The render will proceed asynchronously in the GPU
    while the host can perform other tasks.
    To complete the render, you can either call refresh() directly of refresh the texture
    to which this object is the source. Asynchronous render is useful to achieve optimal
    performance: call render() on frame N and refresh() on frame N+1 to give as much as
    time as possible to the GPU to render the frame while the game engine can perform other tasks.

Support negative scale on camera.
    Camera scale was previously ignored in the BGE.
    It is now injected in the modelview matrix as a vertical or horizontal flip
    of the scene (respectively if scaleY<0 and scaleX<0).
    Note that the actual value of the scale is not used, only the sign.
    This allows to flip the image produced by ImageRender() without any performance
    degradation: the flip is integrated in the render itself.

Optimized image transfer from ImageRender to buffer.
    Previously, images that were transferred to the host were always going through
    buffers in VideoTexture. It is now possible to transfer ImageRender
    images to external buffer without intermediate copy (i.e. directly from OGL to buffer)
    if the attributes of the ImageRender objects are set as follow:
       flip=False, alpha=True, scale=False, depth=False, zbuff=False.
       (if you need to flip the image, use camera negative scale)
2016-06-11 22:05:20 +02:00
Thomas Dinges
5b061ddf1e Fix Gradient Texture and OSL after refactor. 2016-06-11 21:40:00 +02:00
0b415700f4 Attempted fix for T48625: tablet button configured to right click not working on OS X. 2016-06-11 20:32:24 +02:00
42aec3b355 Cycles: nodify shader nodes
Differential Revision: https://developer.blender.org/D2038
2016-06-11 20:32:24 +02:00
Bastien Montagne
4df6474f01 Fix T48617: VSE: Do not draw backdrop in Seq + Preview mode, only makes sense when no preview is available... 2016-06-11 17:28:32 +02:00
Campbell Barton
dccf5afbef BLI_rand: add BLI_rng_get_char_n
Use to fill an array of bytes to random values.
2016-06-12 00:41:02 +10:00
Bastien Montagne
4ec1c76afc Fix T48634: Interpolation and distribution of Children Particles breaks.
Own stupid off-by-one regression in rB019ce363b01bba0afe1 and later...
2016-06-11 14:37:47 +02:00
Bastien Montagne
07925b6316 UI Font: Fix bad kerning of Thai font.
Thai font is a complex script that assumes full featured unicode layout engine,
while Blender only knows about basic kerning (offset of a char based on the previous one).

So this commit edits Thai part of our i18n font to fix the very bad spacing of thai chars
we had in Blender so far.

Work done by Hồ Châu, many thanks!
2016-06-11 10:47:53 +02:00
Bastien Montagne
a99c03a0ad VSE: select by group: add option to select by group on same channel only. 2016-06-10 18:40:31 +02:00