1
1

Compare commits

...

1094 Commits

Author SHA1 Message Date
Julian Eisel
7576ad3d04 Merge branch 'blender2.8' into transform-manipulators
Conflicts:
	intern/gawain/gawain/immediate.h
	intern/gawain/src/immediate.c
	source/blender/editors/physics/physics_ops.c
	source/blender/editors/screen/glutil.c
	source/blender/editors/space_view3d/space_view3d.c
	source/blender/editors/space_view3d/view3d_draw.c
	source/blender/editors/space_view3d/view3d_edit.c
	source/blender/editors/space_view3d/view3d_ops.c
	source/blender/editors/transform/transform_manipulator.c
2017-04-04 21:39:57 +02:00
Dalai Felinto
db0f67f464 Collada export cleanup 2017-04-04 20:44:22 +02:00
9ecb196237 fix: Collada export selected worked only for the very first export (needs further testing and cleanup, see comments) 2017-04-04 19:17:52 +02:00
Dalai Felinto
f10219a977 Immediate Mode: handle other cases of glPop/glPushClientAttrib
Those cases were not using ClientAttrib but they should :)
Rather use a OpenGL3.3 alternative anyways.
2017-04-04 18:43:01 +02:00
Dalai Felinto
fa317eb69c Fix collada exporting for Blender 2.8
Instead of exporting all the scene objects, I'm exporting the scene
layer objects instead.
2017-04-04 17:45:55 +02:00
Dalai Felinto
69f7b513b5 Immediate Mode: removing unecessary comment on gpencil (false positive) 2017-04-04 17:04:03 +02:00
Dalai Felinto
a0ef482124 Image Draw: remove unused code since 2009
(removing false positive deprecated OpenGL calls)
2017-04-04 16:47:09 +02:00
7fc84d4e32 Merge branch 'master' into blender2.8 2017-04-04 15:47:58 +02:00
Dalai Felinto
c8cff31922 UV editor using new depsgraph for shadow uv 2017-04-04 14:31:01 +02:00
Dalai Felinto
c87bfb1f7d Immediate Mode / DerivedMesh: Handle UV Shadow 2017-04-04 14:31:01 +02:00
Dalai Felinto
0e95270eb7 Depsgraph: placeholder function for COW objects query 2017-04-04 14:31:01 +02:00
Dalai Felinto
1baa236acb CTX_data_depsgraph(bContext *C); 2017-04-04 14:31:01 +02:00
Dalai Felinto
5eac4e3057 Immediate Mode: glPop/glPushClientAttrib 2017-04-04 14:31:01 +02:00
373d362e4a Fix bad level call. 2017-04-04 11:04:00 +02:00
4fe8395215 Cleanup: avoid long lines (search tools complain!) 2017-04-04 17:38:51 +10:00
0c68c92840 fix node editor drawing (T51086)
Fixed a few issues
- wrong transform matrices
- assert on node with no sockets
- color of collapsed nodes, some title areas

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

```
echo "Fixing $1"

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

from render_layer_common import *
import unittest
import os
import sys

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

.
w
q
EOF
```

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

and glEnable/Disable for
GL_FOG, GL_LIGHTING, GL_COLOR_MATERIAL

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

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

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

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

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

Patch with contributions and fixes by Julian Eisel (Severin)

Subscribers: venomgfx

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

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

Note 2: commented out code update coming next

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

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

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

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

Reviewers: fclem, merwin

Tags: #bf_blender_2.8

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

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

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

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

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

This was the last use of glaDrawBorderCorners.

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

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

This was the last use of glutil_draw_lined_arc.

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Reviewers: dfelinto, fclem, merwin

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

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

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

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

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

There are two side-effects to this:

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

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

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

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

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

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

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

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

Reviewers: merwin

Tags: #bf_blender_2.8

Maniphest Tasks: T49043

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

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

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

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

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

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

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

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

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

We will use the outliner for this now.

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

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

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

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

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

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

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

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

Part of T49043

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

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

Part of T49043

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

Note: Master Collection should not be renamable, but also, it should be marked as MasterCollection (with an icon probably)
2017-02-13 11:16:23 +01:00
Dalai Felinto
8a92277a31 Layers: Per-Collection edit mode parsing
Note: we are now merging all the collection engines (mode and render), which eventually may get slow. But as stated before, this is to expose the functionality, while waiting for proper depsgraph integrated solution.
2017-02-13 00:25:30 +01:00
Julian Eisel
10b24eabba Merge branch 'blender2.8' into transform-manipulators
Conflicts:
	source/blender/editors/interface/resources.c
	source/blender/editors/space_view3d/view3d_intern.h
	source/blender/editors/transform/transform_manipulator.c
	source/blender/gpu/CMakeLists.txt
	source/blender/gpu/intern/gpu_shader.c
2017-02-12 21:43:13 +01:00
Dalai Felinto
adf355849f Layers: Per-Collection edit mode settings
I didn't manage to get the proper object context in the collection
properties editor. That said I got it working for now in a temporary way
since this will change once we get workspaces anyways

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

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

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

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

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

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

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

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

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

OpenGL immediate mode: interface_draw.c (end)

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

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

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

OpenGL immediate mode: interface_draw.c (cont)

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

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

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

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

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

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

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

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

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

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

Still need mouse selection, box selection, and menu selection

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

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

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

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

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

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

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

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

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

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

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

* A more complete Matcap customization with more options

* Per-Collection render engine settings

* New Ground Truth AO - not enabled

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

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

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

* General edit mode
  - Per-collection edit mode settings

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

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

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

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

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

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

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

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

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

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

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

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

* Collection Manager operators
  The existing buttons  are placeholders

* Collection Manager drawing
  The editor main region is empty

* Collection Override

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

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

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

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

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

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

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

    - Renamed references of layer manager to collections manager

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

    - The drawing code itself will be implemented separately by Julian

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

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

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

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

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

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

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

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

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

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

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

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

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

This commit also uses the new BLF_default function where possible.

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

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

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

Reviewers: dfelinto, merwin

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

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

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

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

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

Moved the new function from BLF to UI.

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

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

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

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

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

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

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

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

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

Reviewed By: merwin

Subscribers: dfelinto

Tags: #bf_blender_2.8

Maniphest Tasks: T49043

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

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

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

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

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

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

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

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

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

Reviewers: merwin

Subscribers: fclem

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

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

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

fixed up some color/rect calls

fixed up ANIM_channel_draw()

Reviewers: krash, merwin

Reviewed By: merwin

Tags: #bf_blender_2.8

Maniphest Tasks: T49043

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

Reviewers: merwin

Reviewed By: merwin

Tags: #bf_blender_2.8

Maniphest Tasks: T49043

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

part of T49043

Reviewers: merwin

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

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

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

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

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

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

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

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

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

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

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

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

Reviewers: krash, merwin

Reviewed By: krash, merwin

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

Reviewers: krash, merwin

Reviewed By: krash, merwin

Tags: #bf_blender_2.8

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

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

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

Reviewers: krash, merwin

Reviewed By: krash, merwin

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

warm regards,
Sebastian Witt

Reviewers: merwin

Reviewed By: merwin

Tags: #bf_blender_2.8

Maniphest Tasks: T49043

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

Reviewed By: merwin

Tags: #bf_blender_2.8

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

T49043

Reviewers: merwin

Tags: #bf_blender_2.8

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

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

Part of T49043.

Reviewers: merwin

Reviewed By: merwin

Tags: #bf_blender_2.8

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

Part of T49043

Reviewers: merwin

Reviewed By: merwin

Tags: #bf_blender_2.8

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

Reviewed By: merwin

Maniphest Tasks: T49043

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

Reviewers: merwin

Subscribers: LazyDodo

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

Reviewers: merwin

Reviewed By: merwin

Subscribers: Blendify, Severin

Tags: #bf_blender_2.8, #opengl_gfx

Maniphest Tasks: T49043

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

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

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

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

Batch API can use these now, will add support to immediate mode API if desired.

Enabling on Windows first. Will enable on all platforms after we switch Blender to core profile.
2016-11-13 20:18:51 -06:00
1dbe26f76c OpenGL: simplify debug, use only newer features
Drop SciTech support & workarounds for WinCE and OpenGL ES.

AMD_debug_output is still in the code but disabled. Once I verify the newer extensions are available on all the GPU + OS combos we support we can delete this disabled code.
2016-11-12 17:18:13 -06:00
eb880f280d Gawain: strict error checking in debug builds
Not release builds. Fix 66d7f01ecc to match what I meant to do.
2016-11-11 23:53:58 -06:00
8fd510f4b8 Gawain: new enum type for vertex attrib components
Motivations:
1) GLenum is too broad; tightly-defined enum just for this is safer.
2) enable a Vulkan future

New code should use these instead of GL_FLOAT etc. When all existing code has been updated to use new enum, we can drop compatibility with GLenum values.

Early work towards 10_10_10 format, more to come soon.
2016-11-11 19:39:56 -06:00
Julian Eisel
d5def0bedf Use axes colors from custom-manipulators branch 2016-11-10 23:24:08 +01:00
Julian Eisel
723e0a5e01 Don't draw helplines when using transform manipulators
Also removed unused transform flag.
2016-11-10 23:07:26 +01:00
Julian Eisel
82ba89b042 Fix T49961: Blender 2.8 Crashes on saving an image
Caused by 4811b2d356 which caused the event handler hack that is used to fire up the file browser from other operators to fail. Basically the context from before the file browser is opened gets stored and used later for executing the actual file read/write operation (in this case, saving image). This context storage is cleared when exiting an editor since 4811b2d356, which is technically correct, but causes usage of NULLed context data in this case, because the file browser is exited before the file read/write operation is executed.

For now I solved this by moving the fileselect handler to list of normal handlers, instead of modal ones. 4811b2d356 only touches list of modal handlers so we avoid the crash. Ideally we'd completely refactor how the file browser opening works to get rid of these event handler hacks.

Note that I wouldn't be suprised if this causes other regressions, but I couldn't find one so worth a try.
2016-11-10 20:34:35 +01:00
Dalai Felinto
69655a1103 Merge remote-tracking branch 'origin/master' into blender2.8 2016-11-09 14:36:59 +01:00
a0ae6d7116 OpenGL: manage built-in shaders better
As our library of built-in shaders grows, it's important to create, access, and discard them efficiently.

Lookup via GPU_shader_get_builtin is now constant time instead of linear (# of built-in shaders). This is called very often with our new immediate mode.

Creation and discard are unified.

Adding a new shader requires fewer steps.

365 lines shorter  :D
2016-11-08 22:53:59 -06:00
Julian Eisel
380aacb12a Remove bad storage hacks of old transform manipulators
Got rid of Scene.twcent, Scene.twmin, Scene.twmax, RegionView3D.twmat, RegionView3D.twdrawflag, RegionView3D.tw_idot, TransInfo.mat, TransInfo.vec.
Also cleaned-up variable and define names.

Decided to completely remove the struct members without doing proper file conversion for non-runtime ones. That will cause minor compatibility breakage but that's okay for 2.8.
2016-11-09 01:00:39 +01:00
Julian Eisel
90fcbde62d Remove old transform manipulators code 2016-11-08 21:22:12 +01:00
Julian Eisel
077ac7b302 Merge branch 'blender2.8' into transform-manipulators
Conflicts:
	source/blender/gpu/intern/gpu_shader.c
2016-11-08 20:42:52 +01:00
Julian Eisel
87fd59406b Rotation value indicator for rotation manipulators
Adds the arc thingy that displays the current delta rotation value while rotating.
It is a different implementation than the one of the custom-manipulators branch which was based on mouse coordinates and thus didn't work correctly with snapping and precision (shift) tweaking. This new implementation is based on object matrix and fixes these issues.

Commit only adds support for rotating objects, not yet for other elements (polygons, bones, GPencil points, etc)
Also some minor cleanup of course ;)
2016-11-08 20:36:11 +01:00
2b726b054e blender 2.8: OpenGL immediate mode: node_draw_preview_background
all is in the title.

Reviewers: merwin

Tags: #bf_blender_2.8, #opengl_gfx

Maniphest Tasks: T49043

Differential Revision: https://developer.blender.org/D2336
2016-11-08 11:12:29 -05:00
12bce04b2f Blender 2.8: OpenGL: new immediate mode for paint_image.c
This one is for the straight line (white with width 2.0 over a black with width 4.0) drawn when you use the gradient tool.

To test: Image editor, create / open an image, choose image paint mode and on the tool shelf: choose the Fill brush and enable "Use Gradient" for it. Then click and drag on the image.

From what I checked, calls to glLineWidth are not being removed yet, so I kept them.

Reviewers: dfelinto, Severin, merwin

Reviewed By: merwin

Tags: #bf_blender_2.8, #opengl_gfx

Maniphest Tasks: T49043

Differential Revision: https://developer.blender.org/D2312
2016-11-08 11:08:16 -05:00
f90b480f95 OpenGL: wm_operators.c uses new immediate mode
D2311 by @ianwill

This is the radial control that appears when we change the size of a brush in sculpt and vertex and texture painting modes, by pressing "f".

Also includes a new built-in shader that can be useful in other places.

Part of T49043
2016-11-08 10:55:23 -05:00
4e80bd2d6d Blender 2.8: OpenGL: new immediate mode API for screendump.c
It's the screencast cursor, tested here, compared to original, seems to be working fine.

Reviewers: dfelinto, Severin, merwin

Reviewed By: merwin

Tags: #bf_blender_2.8, #opengl_gfx

Maniphest Tasks: T49043

Differential Revision: https://developer.blender.org/D2306
2016-11-08 10:10:55 -05:00
66d7f01ecc Gawain: less error checking in release builds
Gawain does very strict runtime checking to help us catch coding errors. Final release should disable most of these checks, so I'm disabling now for all non-debug builds.

When writing Blender code that uses Gawain, always make debug builds and test there! "make lite debug" is my favorite.
2016-11-08 05:28:40 +01:00
de101fe9a8 OpenGL: mesh edit mode uses edge overlays
Legacy GL uses GL_LINES, modern GL uses the good stuff.

Edit mode still has a long way to go...
2016-11-08 05:22:17 +01:00
0b83680d85 OpenGL: support for edge overlays
Has some obvious opportunities for improvement. This is my second attempt. First attempt used MLoopTri and sort of worked...
2016-11-08 05:06:09 +01:00
016aca7427 OpenGL: fade other objects during edit mode
Right now this only affects other objects in wireframe. The idea is to do something similar for other draw modes, and keep focus on the edit object.

As seen at #bcon16
2016-11-07 20:32:27 +01:00
a3277ae384 OpenGL: simple mesh edit mode for new viewport
Very very simple. Needs a lot of work to reach "legacy viewport" capabilities.
2016-11-07 20:24:03 +01:00
5abf1a4e9d OpenGL: enable fancy wireframes
Most of this was already in place, just enabling & adding comments.

One fix was needed to make batch uniforms stick between multiple draws.

Added comments to selection outline; no functional changes there.
2016-11-07 20:07:31 +01:00
1cd754ad31 OpenGL: simple batch of all mesh triangles
Can be used for drawing basic surfaces, hit testing, depth pre-pass, ...
2016-11-07 20:07:31 +01:00
c1ba58c44d Merge branch 'master' into blender2.8
Conflicts:
	intern/cycles/blender/addon/properties.py
2016-11-07 15:46:27 +01:00
93dbd81796 Gawain: manage batch API's current shader program + uniform funcs
Typical pattern:
Batch_set_program
Batch_Uniform(s)
Batch_draw
2016-11-05 21:03:26 +01:00
5b26c36008 OpenGL: edge overlay shaders
As seen at #bcon16. These were produced quickly and probably need further work.

SIMPLE variant draws triangle mesh edges. Based on this research:
http://www2.imm.dtu.dk/pubdb/views/edoc_download.php/4884/pdf/imm4884.pdf
http://developer.download.nvidia.com/SDK/10/direct3d/Source/SolidWireframe/Doc/SolidWireframe.pdf

Non-SIMPLE variant can adjust thickness per edge. This can be used to draw only some edges, or accentuate some edges. Given the right inputs this is a general n-gon perimeter shader.

Part of T49165
2016-11-05 19:26:13 +01:00
a85f68e9c7 OpenGL: further wireframe shaders
As seen at #bcon16

Geometry shader version is automatically used on modern GL runtimes. Legacy version is used on pre-3.2 systems (Mac, Mesa compat profile). They have the same inputs and visual result.

TODO: specialized versions that are less flexible -- draw ALL edges or draw JUST silhouette edges.

Part of T49165
2016-11-05 18:56:57 +01:00
Dalai Felinto
c25c3bb6cb Fix UI for smoke cache
(this was probably broken since we got rid of point cache in 2.8)
2016-11-02 11:09:27 +01:00
Dalai Felinto
a41bbd3053 Merge remote-tracking branch 'origin/master' into blender2.8 2016-11-02 10:59:52 +01:00
fb6f42dc4f OpenGL: draw NLA strip curves with new imm mode
Part of T49043.
2016-10-31 17:42:11 +01:00
1556a28108 OpenGL: draw filebrowser dropshadow with new imm mode
Part of T49043.
2016-10-28 20:46:10 +02:00
Dalai Felinto
a25d3d7de2 Viewport: Set outline color for mesh based on active/select state
(also, fix warning regarding const float being written)

You only see the color if you use the "modern" viewport option
(otherwise I believe Blender is drawing the old on top of the new outline).

That said, in the "modern" viewport we have unfreed mem. To be
investigated separately.
2016-10-26 13:57:22 +00:00
2783d5df61 OpenGL: follow up on mesh wire TODOs
- depth test on (affects scene depth for now)
- color variations
- object outline  does not need GL_BLEND with latest shader
2016-10-26 04:18:19 -04:00
a394f4e545 OpenGL: edge shader discards fragments of unused edges
Discarded edges should not update depth buffer or blend with color buffer.

Geometry shader version will make this obsolete.
2016-10-26 03:57:14 -04:00
222ba0247f fix edge shader input 2016-10-25 19:38:22 -04:00
456d145d07 OpenGL: new mesh draw routines for new viewport
Totally WIP.

Started with copies of legacy routines, modified to use the new shaders & batch cache. Not all features are implemented; this is why we keep legacy viewport around during development!
2016-10-25 19:34:17 -04:00
Dalai Felinto
821fa24876 Viewport: fix depth not being cleared in ortho mode 2016-10-25 11:18:56 +00:00
Dalai Felinto
b4f849b9c6 Merge remote-tracking branch 'origin/master' into blender2.8 2016-10-25 11:18:41 +00:00
392551bd95 OpenGL: mesh batch cache (WIP)
Gawain batches are built on demand while drawing, then kept in this per-DerivedMesh cache.

A mesh's batches try to share vertex buffers as much as possible.

Not sure if this file is the best home for this code, but functions in this file are the only users of the cache. So maybe.

Big part of T49165
2016-10-25 05:31:25 -04:00
d8d42e1702 make View3D depth debug code optional
Quick hack to optionally disable depth buffer debugging at compile time.

Will this be useful for users or just during development?
2016-10-25 04:46:07 -04:00
bc566e9393 OpenGL: 3D View background & depth buffer details
Surveying buffer usage & clears for new viewport. Not yet perfect, but closer. Committing from Mac so I can test this on Windows.

Using new matrix API (T49450) for gradient background.
2016-10-25 04:39:55 -04:00
94e14a2c43 OpenGL: new built-in shaders for mesh edges 2016-10-25 03:19:10 -04:00
c5072941c3 OpenGL: clean up glActiveTexture usage
Removed some of my earlier glActiveTexture calls. After reviewing the
code I now trust that GL_TEXTURE0 is active by default. Fewer GL calls,
same results.

Fixed some misuse of glActiveTexture & glUniformi, mostly my fault.
Caught by --debug-gpu on Windows. Don't know why this appeared to be
working previously!

Plus some easy cleanup nearby.
2016-10-25 01:02:41 -04:00
Dalai Felinto
4d11b2fb91 Viewport: original gradient background
Last but not least, fix the original 3d view background based on
@merwin's comment.
2016-10-24 19:40:37 +00:00
Dalai Felinto
1458f0136d Viewport: move the background to the "modern" viewport
This also leaves room for the gradient background Mike Erwin wants to
implement.
2016-10-24 19:05:49 +00:00
Dalai Felinto
744718f635 immediate mode: background
There is a problem here, which is that we can't use immediate mode here
until we rely on `GPU_material_bind`.

(cc: @merwin)
2016-10-24 17:26:27 +00:00
Dalai Felinto
a3b69c8131 Viewport: fix depth filled before solid plates 2016-10-24 12:58:23 +00:00
6388d0c4a0 OpenGL: triple buffer tweaks
Works great on Mac now. Will test on Windows & Linux (Mesa) tomorrow. Related to T49505

Main fix is glActiveTexture and immUniform1i.

TEXTURE_2D vs TEXTURE_RECTANGLE is now a compile-time option. Both are available starting in GL 3.1 so there's no need for a run-time check.

Removed glClears that I don't think are necessary.

Prevent TEXTURE_2D from creating extra mipmap levels. We only need level 0.

Some minor cleanup: booleans and variable declarations.
2016-10-24 05:06:45 -04:00
1abdb0c2ee OpenGL: add NormalMatrix & inverse to new API
Part of T49450
2016-10-23 23:37:53 -04:00
2cb45c9938 a place to cache draw data in DerivedMesh
DerivedMesh owns this cache and cleans up as part of DM cleanup. DM has no idea what is stored in this cache. Loose coupling FTW
2016-10-23 23:22:16 -04:00
e53ab2b9ec Gawain: fixups & progress for batch API 2016-10-23 23:16:54 -04:00
Julian Eisel
754eaf45ff Make transform manipulators of multiple types work together nicely 2016-10-24 02:36:35 +02:00
Julian Eisel
54327bf6f1 Some cleanups/refactors for transform manipulators 2016-10-24 01:39:48 +02:00
Julian Eisel
dabbe6eb22 Fix memory leak when using depth-only shader 2016-10-24 00:03:55 +02:00
Julian Eisel
74e784b3e5 Add missing file 2016-10-23 23:37:27 +02:00
Julian Eisel
246a104dbc Implement new resize manipulators 2016-10-23 23:33:18 +02:00
Julian Eisel
c5c2c3be98 Use more modern OpenGL for dial manipulator drawing
Added a new shader for drawing with clipping plane.
2016-10-22 03:18:28 +02:00
Julian Eisel
6e8a0047d6 Merge branch 'blender2.8' into transform-manipulators 2016-10-22 00:31:44 +02:00
Julian Eisel
46257e01a7 Fix compiling with blenderplayer (once again...) 2016-10-22 00:30:28 +02:00
Dalai Felinto
5ff586610a Viewport: use depth shader to debug the depth
At the moment this already shows that the depth is the same after the solid plates and in the very end of drawing, while they should be different. Later on we can adapt this to show different buffers we want to debug.

I am using near=0.1, far=2.0 for my tests. I decided not to make a doversion for near/far because this is for debugging only
2016-10-21 20:51:12 +00:00
Dalai Felinto
deb77c0e74 Viewport: create a shader to show depth images linearized 2016-10-21 20:51:10 +00:00
Dalai Felinto
4c3624a7a0 Viewport: add missing alpha for stereo 2016-10-21 20:51:05 +00:00
Dalai Felinto
af20ca51a1 Viewport: Bring camera, speaker, rigid body shape and bounding box 2016-10-21 20:50:36 +00:00
cdcddddd96 OpenGL: disable GL_CULL_FACE state only when needed
The active camera has a solid "up" triangle instead of the usual outline. We want to see both sides of this triangle. Disable face culling only when drawing the active camera, not for every camera.
2016-10-21 16:25:17 -04:00
Dalai Felinto
01872d7f5d Fix build for gameengine 2016-10-21 12:50:04 +00:00
Dalai Felinto
dd23e52817 Merge remote-tracking branch 'origin/master' into blender2.8
Conflicts:
	source/blender/blenloader/intern/versioning_defaults.c
2016-10-21 12:22:50 +00:00
Julian Eisel
a14d7f3009 Implement new rotation manipulators 2016-10-21 01:57:40 +02:00
Julian Eisel
57d6983f52 Add view aligned circle manipulator for free translation 2016-10-21 00:51:54 +02:00
224d70c978 OpenGL: draw lamp objects with new imm mode
Previous commit in blender2.8 branch had some... unintended
consequences. This one should be better.

Part of T49043. Also uses new matrix API (T49450)
2016-10-20 16:55:40 -04:00
Julian Eisel
ca10cacf6c Remove unused includes 2016-10-20 22:14:34 +02:00
Julian Eisel
693265e1e9 Use more modern OpenGL for arrow manipulator drawing
Could/should do hings like sharing VBOs between manipulators, using own shader, use GPU_matrix API, etc but would need to figure out requirements some more first.
2016-10-20 22:11:28 +02:00
4ea6917468 OpenGL: box & circle outline functions that work with 3D position (z=0)
New immediate mode API is strict about attribute formats. These new functions make existing code easier to port.

Supports T49043
2016-10-20 14:33:32 -04:00
c6abbb40ad Gawain: closer integration of immediate mode & matrix APIs
- any shader program can use matrix state (not only built-in shaders)
- you can mix matrix & begin/end calls, and the bound shader will use the latest matrix state

Part of T49450 & T49043
2016-10-20 14:29:59 -04:00
a92d20a0a4 OpenGL: dirty bit for GPU matrix API
Have matrices changed since the most recent bind?

Part of T49450
2016-10-20 14:18:34 -04:00
Julian Eisel
26de2b4f9c Get tranform manipulators type toggle to work; increase arrow line-width; cleanup 2016-10-20 16:45:38 +02:00
Dalai Felinto
225edf4e66 immediate mode: outliner background
I tried using immRecti instead, but it didn't work. The current approach
should be more efficient anyways (since GL_TRIANGLE_FAN wouldn't work
here).
2016-10-20 01:44:49 +00:00
Julian Eisel
8d8f2e2e33 Support drawing arrow manipulators while translating 2016-10-20 02:04:58 +02:00
Dalai Felinto
33d99bdfe6 immediate mode: ed_util.c
note: I switched one of the glVertex2iv into glVertex2fv to use the same attrib_id
2016-10-19 23:59:22 +00:00
Julian Eisel
b574bd6cf7 Finish basic transform manipulators for translate 2016-10-20 01:18:30 +02:00
9941bc3041 OpenGL: draw empties with new imm mode
Part of T49043
2016-10-19 04:01:15 -04:00
625f1a1c30 OpenGL: draw cameras using new matrix API
Also removed some extra push/pops.
Ref T49450
2016-10-18 20:57:36 -04:00
05117d71a3 OpenGL: draw cameras with new immediate mode
Mostly the same as before. Except:
- avoid drawing same lines multiple times
- helper functions take "bool filled" argument instead of GLenum
- drawcamera_volume draws its own near & far planes
2016-10-18 20:27:24 -04:00
54a0ff3ab5 Gawain: yet another way to set uniform color 2016-10-18 20:22:22 -04:00
Julian Eisel
91fc0c4f2a Initial implementation of a new transform manipulator
This commit adds the basic framework for the new transform manipulators and also includes working manipulators for translation.

Wasn't really happy with the new transform manipulators code in the custom-manipulators (used to be wiggly-widgets) branch, especially since it reused quite some code of the old manipulator which is messy as hell. I decided to refactor this code by rewriting it from scratch. I'm doing this in an own branch so it can easily be merged into blender 2.8 when ready.

The new transform manipulators are part of the space_view3d module, IMHO they fit better into this than into transform module.
2016-10-19 00:44:40 +02:00
e9268abf4a fix narrow text entry fields
widget_draw_text was calculating wrong display length when field is too narrow to show entire input string. Gawain assert caught this 11 function calls away!

Thanks to @ianwill for reporting.
2016-10-18 17:34:29 -04:00
117af2356a skip drawing of gpencil strokes with overall thickness <= zero
Fixes an assert in drawing code.

Might need further work to support variable-thickness strokes (from pressure-sensitive stylus). This all is due for geometry shader overhaul anyway.
2016-10-18 13:12:40 -04:00
46a069822a draw gpencil dots smooth
Some strokes are just single dots. Draw these smooth / antialiased.
2016-10-18 13:07:35 -04:00
827ad4125c OpenGL: new built-in shader for smooth round 3D points 2016-10-18 13:03:30 -04:00
70ff63e63f OpenGL: tweak image shaders & code that uses them
- rename image shaders to describe exactly what they do
- rename inputs to match other built-in shaders
- set & use active texture unit
- no need to enable/disable textures with GLSL
- pull vertex format setup out of loops
2016-10-18 00:08:34 -04:00
0c6939f5f5 minor cleanup & deprecation 2016-10-17 23:48:12 -04:00
8327795f8d OpenGL: draw image empties with new API
This extensive rewrite caches the image texture in VRAM. Can handle images up to OpenGL limits (8K or 16K).

Part of T49043 & T49450
2016-10-17 23:28:51 -04:00
Dalai Felinto
6a0292cc19 Fix for gpu_shader_2D_texture_2D_frag.glsl
Report and patch by Willian Padovani Germano (ianwill)
2016-10-17 19:24:08 +00:00
Julian Eisel
4811b2d356 Proper fix for crash when joining areas that doesn't break manipulators
Turns out CTX_wm_region returns mostly NULL in wm_manipulatormaps_handled_modal_update. Now propertly unsetting area/region data of handlers when deleting area/region.
2016-10-17 19:28:09 +02:00
e7fddc0772 OpenGL: disable checks for NPOT texture support
Non-power-of-two textures are always allowed. Keeping the disabled checks in the code in case we support OpenGL ES in the future. Even then it should be a compile-time check, not at run-time.
2016-10-17 02:36:51 -04:00
42677fa937 Gawain: tweak tracking of unassigned attributes (no API change)
Hoping for a small performance win.
2016-10-16 23:50:18 -04:00
ca369e6f0c OpenGL: draw object centers nicer
Shaders + new immediate mode = very nice dots.

Part of T49043
2016-10-16 18:49:48 -04:00
61ca73ea10 OpenGL: new built-in shader for smooth round 3D points w/ outline 2016-10-16 18:43:24 -04:00
36d2365ac3 OpenGL: new immUniformThemeColorShadeAlpha function
Plus some naming cleanup.

Supports T49043
2016-10-16 17:48:35 -04:00
9cdf4afb76 Gawain: new immUniform4fv function 2016-10-16 17:48:35 -04:00
f7414b7412 fix IS_VIEWPORT_LEGACY macro 2016-10-16 17:48:35 -04:00
Julian Eisel
d1a35b7a08 Fix outliner items sometimes not opening
Own mistake in 9a9a663f40. Guessed there is a case where we have to rebuild the tree but everything seemed fine... It didn't work in display modes like "Data-Blocks".
2016-10-16 22:23:50 +02:00
Julian Eisel
fa39ec9e46 More fixes for keyframe theme options
Couple of issues here:
* Missing initialization for 3D view keyframe options for "Reset to Default Theme"
* Alpha values not reset correctly on "Reset to Default Theme"
* Alpha values of timeline keyframe options not reset correctly for old files
Also corrected old version patches even though they're overridden later, to avoid more issues in case people copy this code.

Corrections to d7af7a1e04 and 8d573aa0ec
2016-10-16 20:47:44 +02:00
Julian Eisel
196654ad08 Fix crash when joining areas (caused by manipulators)
Manipulator code tried to access the removed region from handler->op_region. Use context region now.
2016-10-16 19:31:57 +02:00
Julian Eisel
69713aa2da Cleanup: Quiet warnings, use RAD2DEG macro 2016-10-16 17:28:12 +02:00
Julian Eisel
b557ceb2c1 Merge branch 'master' into blender2.8
Conflicts:
	source/blender/editors/space_outliner/outliner_draw.c
	source/blender/editors/space_outliner/outliner_edit.c
	source/blender/editors/space_outliner/outliner_intern.h
	source/blender/editors/space_outliner/outliner_select.c
2016-10-16 15:33:00 +02:00
Julian Eisel
9a9a663f40 Outliner: Rework element selection behavior
* LMB now replaces selection instead of adding to it. Shift+LMB adds to selection (or removes if already selected). This is usual selection behavior Blender.
* Outliner selection isn't completely separate from object/sequencer-strip/render-layer/... selection anymore, when selecting an outliner item we now always try to select (and activate) the object it belongs to. Previously you had to click the name or icon of an item to select the object (or whatever) and on empty space within the row to set outliner selection.
* Collapsed items may show click-able icons for their children (nothing new). Clicking on such an icon will also select the hidden item it represents now, you'll notice after opening the parent. This valid from a technical POV, I'm not sure if this is wanted from user POV though. Changing would be easy, feedback welcome!
* Code cleanup.

Part of T37430.
2016-10-16 14:29:38 +02:00
Julian Eisel
f929045c2c Outliner: Avoid rebuilding tree when mouse-hover highlight changes 2016-10-16 14:10:30 +02:00
3999910b19 OpenGL: add GLSL #version 330, drop 140 and 150
GL 3.3 is the new minimum. Compatibility profile for now, core profile eventually. During development, GL 3.0 (on Mesa) and 2.1 (on Mac) will still work.

Part of T49012
2016-10-16 03:18:17 -04:00
1deab69e0a BLF/OpenGL: more text drawing optimization
Make color values compact. Set color once per primitive. Use new immSkipAttrib to avoid useless color copies.

All of this should make text drawing less CPU hungry.
2016-10-16 02:08:16 -04:00
741965615d Gawain: new immSkipAttrib function
Now you can explicitly skip a vertex attribute -- you don't give it a value and it won't get a copy of the previous vert's value. Useful for flat interpolated per-primitive values.

This is an advanced feature. Expect garbage in the empty spaces, and copies of garbage if you rely on the attrib copy behavior after skipping.
2016-10-16 01:58:26 -04:00
a4fe823416 BLF/OpenGL: accurate vertex count for drawing
We still need to BeginAtMost instead of simple Begin, since some glyphs could be clipped & not drawn.
2016-10-15 20:04:25 -04:00
a8dc3f4596 BLF: make blurry text an optional (disabled) feature
While trying to simplify text drawing, noticed no Blender code uses the blur feature. Hopefully scripts don't use it!
2016-10-15 19:40:41 -04:00
878938f203 OpenGL: remove some unused legacy matrix calls
Part of T49450
2016-10-15 19:08:19 -04:00
3996fbc564 OpenGL: bump Windows to GL 3.3 compat profile
Part of T49012
2016-10-15 14:41:29 -04:00
cf5750a85e Gawain: improve immediate mode performance
This was already fast on Apple, but @Severin and @dfelinto noticed slowdowns in user prefs, which is text heavy.

The problem was immBeginAtMost not being smart about VBO write flushing. immBeginAtMost can use all of its allocated range or only a subrange. The previous code was forcing back-to-back draw calls and buffer writes to serialize. This commit lets OpenGL know that our VBO writes never overlap, so there's no need to wait.

Should be much faster now!
2016-10-15 14:41:29 -04:00
Julian Eisel
5e428b3b3f Fix unitialized variable use
Own mistake in ae8e845470.
Patch by @efi0ng, thanks!
2016-10-15 18:59:31 +02:00
fcff984338 Merge branch 'master' into blender2.8 2016-10-15 10:05:03 +02:00
9632ca0a13 OpenGL: draw node sockets more efficiently
1 or 2 draw calls per node instead of 1 per socket (inputs + outputs).
Rearranged draw order so we set uniforms less frequently.
Some style & dead code cleanup.

Part of T49043
2016-10-15 02:49:00 -04:00
2df27995f9 OpenGL: new built-in point shader, clean up other shader names
Smooth round point with outline (uniform color) and fill (varying color).

Updated shader naming scheme: a shader that doesn't deal with color does not have to say "no color". Vertex shaders do not have to say "uniform color" since their frag counterpart actually has the uniform. Each name should describe what that shader *does*, not what it *doesn't do*.
2016-10-15 02:30:59 -04:00
48db35468f blender 2.8: OpenGL: node_circle_draw use now immediate mode
I use your new point shader to draw the node's soket

Reviewers: Severin, merwin

Maniphest Tasks: T49043

Differential Revision: https://developer.blender.org/D2286
2016-10-15 00:14:28 -04:00
29b47924dd OpenGL: bump Linux to GL 3.3 compat profile
fall back to 3.0 if needed (during development)

Part of T49012
2016-10-14 23:42:45 -04:00
4f4c7808e4 fix pointer type warning
thanks, gcc
2016-10-14 22:40:55 -04:00
Julian Eisel
325b21c1d5 Outliner: Fix missing indentation for search-match highlight
Own mistake in ae8e845470.
2016-10-15 02:08:38 +02:00
4736f19000 BLF: early exit when drawing empty strings
Avoids all kinds of setup & preparations to draw nothing.
2016-10-14 20:00:31 -04:00
3f0c0ed87d BLF: fix crash on text input fields
Some strings have known length, others are NULL terminated (len = INT_MAX in this case).

Now font drawing knows to treat INT_MAX special.
2016-10-14 20:00:31 -04:00
Julian Eisel
9904d73d9a Outliner: Draw highlights over entire row
Previously, highlights (mouse hover, selection, search-match) didn't affect background of restriction icons, now the entire line gets highlighted.
2016-10-15 01:38:44 +02:00
Julian Eisel
ae8e845470 Outliner: Element mouse hover feedback
Some little UI polish to get familiar with outliner code (but also because it's a useful feature). Committing to blender2.8 branch but can also port to master (2.7) if wanted.

This basically causes the mouse hovered element to be highlighted. Contrast of the highlight should be fine, even with a non-default theme. Also did some minor cleanup.
2016-10-15 01:03:25 +02:00
Dalai Felinto
ee54a6f130 viewport: draw non-mesh objects for a starter
This starts to decouple non-mesh objects and the legacy draw pipeline.
It shows how we can mix e.g., Cycles and lamps and empties.
2016-10-14 19:00:59 +00:00
Dalai Felinto
608e2402ef viewport: move border drawing code to new file 2016-10-14 19:00:45 +00:00
Dalai Felinto
4a10eb38a3 immediate mode: convert render border code and move to new drawing
routine
2016-10-14 19:00:32 +00:00
Dalai Felinto
e1e97bbb98 Immediate mode: use new util functions, and border draw functions
Part of T49043

Reviewers: merwin
2016-10-14 18:58:58 +00:00
Dalai Felinto
11653f85ff Immediate mode: new util functions (imm_cpack and imm_draw_line_box) 2016-10-14 18:57:38 +00:00
34dc660a76 OpenGL: draw text with fewer draw calls
Was one draw call per glyph,  now one per line.

Still room for improvement here.
2016-10-14 14:41:36 -04:00
dd350c0b37 GPencil: Avoid assert error if the immEnd is called with only one point for lines
This function will be replace by geometry shader, but we need this fix until the shader will be ready. The problem is similar to T49614.
2016-10-14 19:24:27 +02:00
6855ba4034 Fix T49614: Grease Pencil GPF error if stroke thickness change too much between stroke points
The problem was the function tried to draw a line with one point only. This fix will be replaced by new geometry shaders, but we need while this change is not ready.
2016-10-14 18:35:01 +02:00
f23db59e48 GPencil: Display stroke filling while drawing
Before this change, the stroke was filled only after complete the stroke drawing. For artist is better to get a feedback of the area he is filling while drawing, so this commit draws the filling area while drawing.

The triangulation of the stroke is recalculated every time the function is called because using a cache is not useful because the points information is changing all the time while the stroke is being drawing.
2016-10-14 12:06:30 +02:00
Dalai Felinto
58f0af965c viewport: fix rv3d->viewport mem free issue 2016-10-14 05:17:55 +00:00
Dalai Felinto
3cecf39069 immediate mode: starting using new immUniformThemeColorBlendShade and more conversion 2016-10-13 20:08:52 +00:00
Dalai Felinto
05cf74622f more theme color functions: UI_GetThemeColorBlendShade4fv, immUniformThemeColorBlendShade 2016-10-13 20:08:51 +00:00
945f8e3f93 Gawain: vertex format now uses fixed allocations (CPU perf++)
API stays exactly the same.

Attribute names can still be of variable length, as long as the average length does not exceed AVG_VERTEX_ATTRIB_NAME_LEN. Since this includes unused attributes (length = 0) the current avg of 5 might even be too high.
2016-10-13 15:15:40 -04:00
Dalai Felinto
dfa5b32c8c Merge remote-tracking branch 'origin/master' into blender2.8 2016-10-13 16:42:54 +00:00
Dalai Felinto
ecbedce81e viewport: barebones to handle viewport compositing in gpu_viewport.c 2016-10-13 16:26:29 +00:00
14d0549295 Gawain: fix build when TRUST_NO_ONE is disabled 2016-10-13 12:24:01 -04:00
Julian Eisel
916e631fc9 Fix compiling with Blenderplayer 2016-10-13 17:17:17 +02:00
Dalai Felinto
3579350481 immediate mode: small cleanup on timeline
(no need to unbind/rebind the same program)
2016-10-13 14:18:47 +00:00
6f220c1c55 inform immediate mode when switching OpenGL context
Longstanding to-do is now to-done.

Heinous bug reported by @dfelinto pushed me to fix this.
2016-10-13 00:38:29 -04:00
71656ac222 Gawain: fix immediate mode for multiple GL contexts
New functions activate & deactivate immediate mode. Call these when switching context and the internal VAO will be handled properly. VAOs are one of the few things *not* shared between OpenGL contexts.
2016-10-13 00:38:29 -04:00
Dalai Felinto
d5b75256e0 Fix for crash on dopesheet drawing with immediate mode (rB7a552612c) 2016-10-13 04:23:58 +00:00
Dalai Felinto
c565f7b5fd viewport: bring the manipulators 2016-10-13 02:50:42 +00:00
Dalai Felinto
165bdfb672 Fix timeline break after recent immediate mode change (rBf6e7e46f) 2016-10-13 02:19:04 +00:00
Dalai Felinto
b5c539f9fa gawain: assert for immBeginAtMost(..., 0) 2016-10-13 02:16:55 +00:00
Dalai Felinto
84ed9d9829 Draw depth even when in wire mode (for OB_RENDER)
Note: this is not working at the moment, but the logic is sound.
Since we will still change the drawing code a lot I think the commit is valid.
2016-10-13 00:36:58 +00:00
Dalai Felinto
69b1b95356 immediate mode: use new ThemeColor functions 2016-10-13 00:36:56 +00:00
Dalai Felinto
e79f302f16 gawain/immediate mode: new util functions for color uniforms 2016-10-13 00:36:52 +00:00
Dalai Felinto
f6e7e46fac Immediate mode: timeline (keyframes and range)
Part of T49043
2016-10-12 22:36:54 +00:00
683656681c BLF/OpenGL: use new matrix API when drawing text
First test of matrix API. This will eventually use the 2D part of this API, but the 3D part is ready now.

Part of T49450
2016-10-11 21:21:02 -04:00
06d4aca879 OpenGL: matrix fixes & compatibility
Was multiplying matrices backward, so concatenation was broken. Fixed!

Also a way to mix legacy matrix stacks with the new library. Just during the transition! Anything within SUPPORT_LEGACY_MATRIX will go away after we switch to core profile.

Part of T49450
2016-10-11 21:16:26 -04:00
c330f37135 quiet GPU matrix debug printing
Will be needed soon but turn it off by default.
Part of T49450
2016-10-11 14:44:12 -04:00
53d82c3e8d BLF/OpenGL: draw text with new immediate mode
Part of T49043
2016-10-11 14:36:16 -04:00
2fe7e70e92 install_deps: make c++11 building mandatory on blender2.8 branch. 2016-10-11 12:19:04 +02:00
0c43567a5a Merge branch 'master' into blender2.8 2016-10-11 12:09:59 +02:00
587a16352a Gawain: add immRect utility functions (replaces legacy glRect)
Caller is responsible for setting up vertex format, binding a shader program, and setting the color *before* calling immRect.
2016-10-10 12:31:38 -04:00
6371f8ff8a Merge branch 'master' into blender2.8
Conflicts:
	source/blender/blenloader/intern/readfile.c
	source/blender/editors/space_view3d/view3d_draw.c
2016-10-10 12:41:32 +02:00
ecbad54df9 blender 2.8; OpenGL. ui_panel_category_draw_tab with immediate API
Reviewers: dfelinto, Severin, merwin

Reviewed By: merwin

Tags: #bf_blender_2.8, #opengl_gfx

Maniphest Tasks: T49043

Differential Revision: https://developer.blender.org/D2281
2016-10-10 01:41:31 -04:00
22f59b81d7 OpenGL: remove GLSL support query (it's always supported) 2016-10-10 01:13:03 -04:00
78abbdf264 remove call to GLSL support query (it's always supported)
Reworked logic in the one place that still called this. Deleted the "GLSL not supported" fallback.
2016-10-10 01:11:03 -04:00
5fc9bed8b3 BGE: remove calls to GLSL support query (it's always supported)
Reworked logic in the few places that still called this. Deleted the "GLSL not supported" fallbacks.

Also removed some nearby checks for ARB_multitexture and OpenGL 1.1. Blender 2.77 removed checks like this, but game engine still has some.
2016-10-10 01:08:49 -04:00
7a60f889d3 OpenGL: plug new matrix system into shaders (WIP)
Built-in shaders now use uniforms instead of legacy built-in matrices. So far I only hooked this up for new immediate mode.

We use the same matrix naming convention as OpenGL, but without the gl_ prefix, e.g. gl_ModelView becomes ModelView.

Right now it can skip the new matrix stack and use the legacy built-in matrices app-side. This will help us transition gradually from glMatrix functions to gpuMatrix functions.

Still some work to do in gpuBindMatrices. See TODO comments in gpu_matrix.c for specifics.
2016-10-09 23:03:35 -04:00
e636529e33 OpenGL: Draw dividers in space_file with the new immediate mode
Thanks to @merwin for the review

Part of T49043
2016-10-09 18:20:52 +02:00
99db1b8d95 fix shaders for picky GLSL compilers
@zeauro reported this issue:
texture2DRect needs the ARB_texture_rectangle extension.
But isn't that an OpenGL 2.1 feature and should be part of GLSL 1.2+?

This should fix it, and future shaders should do something similar.
2016-10-09 10:53:03 -04:00
a2471d2b37 Gawain: validate inputs to add_attrib
Should help prevent errors when building vertex formats.
2016-10-08 16:58:06 -04:00
187d8f473a OpenGL: fix smooth point fringe
Smooth edge was fading to transparent black instead of transparent color. My bad.
2016-10-08 03:34:05 -04:00
7a552612c3 OpenGL: draw f-curve points and handles with new imm mode
Got rid of GLU and some matrix manipulation. Everything is shader driven now, drawn with point sprites.

Still plenty to do in this file...

Part of T49042 and T49043
2016-10-08 03:27:02 -04:00
25e4dc45e5 OpenGL: shaders for smooth round points
Solid color with an optional outline.

size (diameter) and outlineWidth are in pixels.
2016-10-08 03:11:53 -04:00
b071ac315c Gawain: allow immBeginAtMost, immEnd with no vertices
The whole point of BeginAtMost is to avoid counting before drawing. Sometimes the uncounted count is zero, and that's ok!
2016-10-07 23:50:52 -04:00
2a76da9ec2 draw region emboss with new immediate mode
Simple convert of drawing emboss lines to new immediate mode.

Part of T49043

Reviewers: merwin

Reviewed By: merwin

Subscribers: dfelinto

Tags: #bf_blender_2.8

Differential Revision: https://developer.blender.org/D2271
2016-10-07 23:46:52 -04:00
a398cdedfa Gawain: code cleanup & inline docs
Made function categories more clear & added more notes about how to use this API.

immEndVertex is no longer part of the public API.

Minor cleanup & organizing of recent additions.
2016-10-07 18:51:42 -04:00
b613d25354 Blender 2.8: OpenGL: replace old GL with the new immediate API in UI_draw_roundbox_gl_mode
I change UI_draw_roundbox_gl_mode to use immediate API.
The rest of the change is the call to the function.
I also make some change in UI_ThemeColor4(int colorid) for eg to make convenience to use.
I would really like to know if it's the good way to do, if yes I will make all the change in the node_daw.c after, else say me what's wrong and how to deal with color else.

Reviewers: merwin, dfelinto, Severin

Reviewed By: merwin

Subscribers: fablefox, Severin

Tags: #bf_blender_2.8, #opengl_gfx

Maniphest Tasks: T49043

Differential Revision: https://developer.blender.org/D2274
2016-10-07 15:03:21 -04:00
5c23b863f8 fix grid floor drawing assert
@dfelinto reported crash when setting grid subdivisions too low.

Code was setting color twice and Gawain was catching this. Fix is to only set regular grid color when we have regular grid lines to draw.  Then emphasized grid lines are free to set their own color further down.
2016-10-07 13:00:23 -04:00
Julian Eisel
6e358a1d06 Custom Manipulators Core Backend
This commit lands the core backend of the Custom Manipulators project onto the blender2.8 branch. It is a generic backend for managinig interactive on-screen controls that can be integrated into any 2D or 3D edito. It's also already integrated into the window-manager and editor code where needed.

NOTE: The changes here should not be visible for users at all. It's really just a back-end patch. Neither does this include any RNA or Python integration.

Of course, there's still lots of work ahead for custom manipulators, but this is a big milestone. WIP code that actually uses this backend can be found in the 'custom-manipulators' branch (previously called 'wiggly-widgets').

The work here isn't completely my own, all the initial work was done by @Antony Riakiotakis (psy-fi) and - although it has changed a lot since them - it's still the same in essence. He definitely deserves a big credit! Some changes in this patch were also done by @Campbell Barton (campbellbarton). Thank you guys!

Merge accepted by @brecht and @merwin.
Patch: https://developer.blender.org/D2232
Code documentation: https://wiki.blender.org/index.php/Dev:2.8/Source/Custom_Manipulator
Main task: https://developer.blender.org/T47343
More info: https://code.blender.org/2015/09/the-custom-manipulator-project-widget-project/
2016-10-07 16:59:55 +02:00
Julian Eisel
53d1dbbe5c Merge branch 'master' into blender2.8 2016-10-07 15:14:49 +02:00
4639664b3c Merge branch 'master' into blender2.8 2016-10-07 11:50:17 +02:00
107b585a41 OpenGL/gpencil: delete unused utility functions
Part of T49043  -- done with this file!
2016-10-07 03:17:23 -04:00
9d40c3dc32 OpenGL: draw gpencil fill with new imm mode
Part of T49043
2016-10-07 03:04:34 -04:00
1865bcd3cf OpenGL: draw 2D gpencil strokes with new imm mode
Part of T49043
2016-10-07 00:56:28 -04:00
1f6d704008 OpenGL: draw 3D gpencil strokes with new imm mode
Part of T49043
2016-10-07 00:06:20 -04:00
0fbe35c674 OpenGL: fix shader input typo 2016-10-07 00:00:12 -04:00
70a16298ea gpencil: disable / remove some legacy drawing
Want to avoid updating code we no longer use anyway.

Comments for areas to investigate or deadlines for deletion.

also some minor bool cleanup

Part of T49165
2016-10-06 22:05:28 -04:00
Julian Eisel
fc77787f6f Avoid possible compatibility issues with tmp viewport flags
We can't prevent users from using this branch, so I'd say it's reasonable to be a bit careful about what we store to files. In this concrete case we were storing a bit-flag for temporary use (only during early viewport transition) in a bit-field that's saved in files. Doing so would mean we either can't reuse this bit later or we risk breaking files (admittedly, likely in a pretty minor way). Moved the bit-flag to a new bit-field which can be removed later.
2016-10-07 03:56:32 +02:00
Dalai Felinto
49beb714c5 Viewport: support for external render engines (e.g., Cycles) with depth
(it is still a rough approach, but you can already see Cycles with Floor (when using board render or full render)
2016-10-07 01:47:30 +00:00
Dalai Felinto
4539c2b173 Viewport: floor cleanup 2016-10-07 01:47:30 +00:00
Dalai Felinto
82d069c232 Viewport: draw floor routine should not use GL_ALWAYS for depth
(talked with merwin about that, and he agrees on it, we are not supposed to write to the scene depth buffer
but we should read its depth)
2016-10-07 01:47:30 +00:00
Julian Eisel
490a938c8b Move panel for new viewport up
Makes it easier to enable it and avoids jumping of the panel when activating/deactivating it (because some panels disappear then). Also changed how panel title is drawn to make it behave like other panels.
2016-10-07 03:22:48 +02:00
Julian Eisel
1997b0f03c Use theme color for clearing viewport background
We'll obviously do more fancy stuff here later, but we don't have to look at pure blackness either ;)
2016-10-07 03:11:08 +02:00
1b4b4dfd0c OpenGL/GPencil: draw stroke-in-progress with new imm mode
We should revisit this later and use geometry shader to draw one continuous tapered stroke.

Part of T49043
2016-10-06 20:51:31 -04:00
fe654a93c7 Gawain: allow strips of 1 line, fans of 1 triangle
My initial tests were stricter than necessary, and blocked some valid uses. Fixed!
2016-10-06 20:51:31 -04:00
e01b1eac84 cleanup: C99, const, blank lines 2016-10-06 20:51:30 -04:00
Julian Eisel
553b4faac8 Merge branch 'master' into blender2.8 2016-10-07 00:22:21 +02:00
ffc46668c4 OpenGL: modernize gp_draw_strokes_edit
Single draw call per stroke!

Part of T49043
2016-10-06 17:41:23 -04:00
Dalai Felinto
ea89b4a918 Viewport: bring grid over to the new viewport
We will keep the old system working as long as we can. At the moment even the visibility flags we are getting from the old system. That will continue like this until we have decided on the new UI
2016-10-06 20:35:41 +00:00
Dalai Felinto
6b88f3118f Viewport: Starting to port over the principles of the draw flux into placeholder functions
A lot of the work still have to done on space_view3d.c for initialize the data and buffers properly, but it is a start
2016-10-06 20:35:40 +00:00
198e3a35c8 OpenGL: another built-in shader for 2D points
GPU_SHADER_2D_POINT_VARYING_SIZE_VARYING_COLOR
2016-10-06 16:32:02 -04:00
86e439e311 OpenGL: convert gp_draw_stroke_point to new immediate mode
and constify some static utility functions

Note: 2D shader will ignore position's z value, but making pos a vec3 lets us unify code in this function.
2016-10-06 14:40:47 -04:00
edcce96d97 OpenGL: more built-in GPU_SHADERs for points
No new GLSL shaders were needed! Just combined existing vertex & fragment shaders in new ways.
2016-10-06 14:20:33 -04:00
360cb87007 OpenGL: modernize more volumetric gpencil drawing
Main goal is to get rid of GLU.

Part of T49042, touches on T49043 and T49450
2016-10-06 12:45:04 -04:00
e86bd78745 Gawain: more ways to set uniform color 2016-10-06 09:37:04 -04:00
1731e94d0c draw gpencil erase cursor with new imm mode
Part of T49043 and T49450.
2016-10-05 14:05:55 -04:00
e874f3cdc5 draw gpencil sculpt cursor with new imm mode
Part of T49043 and T49450.
2016-10-05 13:45:28 -04:00
c462500618 Gawain: more ways to set uniform color 2016-10-05 13:12:18 -04:00
Dalai Felinto
5e8c4ae75b Barebones for viewport code apart from 2.7x drawing code
A new option (set in the properties region) allows the user to pick the
"new viewport" for the rendering  (in the UI: Modern Viewport).

For now we have a semi-blank file (view3d_draw.c) that can starts to take
over the drawing pipeline.

I can't guarantee we will be able to keep both drawing systems working
through the entire 2.8 development, but it should do for now.

also, we can use branches for some of the viewport development, but it's
better to keep things in 2.8 whenever we can, so people can test it.
2016-10-04 22:02:05 +00:00
3a4c1db14b fix Linux build
My mistake. Breakage reported by @mont29
2016-10-04 01:31:24 -04:00
79b8242fd1 Gawain: fix bug in immUniformColor4ubv
Reported by @kgeogeo
2016-10-04 01:24:33 -04:00
Dalai Felinto
ae44e24fed Merge remote-tracking branch 'origin/master' into blender2.8 2016-10-03 20:54:22 +00:00
55aadccbde Merge branch 'master' into blender2.8 2016-10-03 20:48:00 +02:00
72473a61b0 Fix compile errors with Alembic. 2016-10-02 20:52:25 +02:00
c50ccc8476 Merge branch 'master' into blender2.8 2016-10-02 18:53:01 +02:00
ba30b852f3 OpenGL: draw volumetric gpencil with point sprites
Transition away from GLU and legacy matrix stack. Using point sprites eliminated the need for most of the matrix math!

Depends on decent support of large aliased points. NVIDIA is good at this, must test limits on AMD & Intel systems.

Still needs proper scaling based on view zoom.

Part of T49042, touches on T49043 and T49450.
2016-10-01 18:11:58 -04:00
b8e3d81f31 OpenGL: fix point sprites
Apparently GL_POINT_SPRITE is important to GL 3.2+ compatibility profile, not just to GL 2.1 as thought.

We'll remove this during the core profile transition.
2016-10-01 17:34:41 -04:00
875d63ccb5 OpenGL: one more point shader
Added a built-in shader for points that vary both size and color.
2016-10-01 17:32:29 -04:00
5753a1462f OpenGL: new built-in shaders for drawing points
Both of these draw round points with jaggy edges, but treat color & size differently.
2016-09-30 20:44:22 -04:00
d1b21d1278 OpenGL: add support for programmable point size
And enable point sprites always. Fragment shaders can use gl_PointCoord now.
2016-09-30 19:51:04 -04:00
82648a8f91 OpenGL: make platform requirements explicit
At context startup, make sure our assumptions about the OpenGL version are true. Should match since we set up the contexts... but this is what asserts are for, to check "should"s!

Part of T49012
2016-09-30 19:10:30 -04:00
Julian Eisel
42ed1f0e3c Merge branch 'master' into blender2.8
Conflicts:
	source/blender/blenloader/intern/writefile.c
2016-09-30 01:18:41 +02:00
47bba7e15f OpenGL: draw nurbs control verts with new imm mode
patch P397 by @lichtwert + minor const by @merwin

Notes from drawvertsN function:
this used to be called twice (once for selected/active, once for unselected -- guess: to avoid state switches[color]?)
this used to be called in a loop, too (subcurves), moved the loop here to avoid multiple init stuff

Part of T49043
2016-09-29 15:23:13 -04:00
Julian Eisel
35bd833e02 Cleanup: Style 2016-09-29 21:15:27 +02:00
bbf32980b0 OpenGL: draw speaker with new immediate mode
patch P388 by @lichtwerk, I tweaked a few things.

Since speaker theme color is opaque we leave blend mode alone.

Part of T49043
2016-09-29 14:47:38 -04:00
Dalai Felinto
9bac74c27b Complement fixup for 4a1feaa555 (texture shaders)
We now multiply the alpha by the image alpha (as per severin
suggestion).
That still doesn't solve the main question of user preference drawing
black.
2016-09-28 19:11:11 +00:00
Dalai Felinto
4c7ff8fb1e Fix animation transition in region overlay not working since 4a1feaa5
We still have stills with the User Preference window, though.
2016-09-28 18:48:51 +00:00
83d5a919e2 modernize basic shader a tiny bit
"varying" is redundant here, all GS inputs & outputs vary.

Any code that uses this will be GLSL 1.3 or newer.
2016-09-27 21:25:38 +02:00
0ca2118851 safety checks in GPU shader library
If shader compilation fails, or for some other reason the shader is NULL or 0, we need to know.
2016-09-27 21:25:38 +02:00
ad32b774cb fix basic shader syntax when drawing lines
Fixed on GL 3.2+, Mac still lays an egg due to the geometry shader.
2016-09-27 21:05:48 +02:00
Julian Eisel
88aa42a6f7 Fix most toolbar panels not visible
Was likely in here since initial blender2.8 branch commit (particle removal).
2016-09-27 03:38:24 +02:00
Dalai Felinto
fc485302cc immediate mode: using texture shader for stereo drawing
(for side-by-side and top-bottom stereo modes)
2016-09-26 15:38:24 +00:00
8cff9c20ff Merge branch 'master' into blender2.8
WARNING! Full build is broken, alembic has not been merged in correctly and has some references to particle stuff.
Don't have time to tackle this now (and probably would be better if someone knowing what he's doing does it anyway).

Conflicts:
	release/scripts/startup/bl_ui/properties_particle.py
	source/blender/blenkernel/intern/library_remap.c
	source/blender/blenkernel/intern/smoke.c
	source/blender/editors/physics/particle_object.c
	source/blender/editors/physics/physics_intern.h
	source/blender/editors/physics/physics_ops.c
	source/blender/editors/space_outliner/outliner_intern.h
	source/blender/editors/space_view3d/drawvolume.c
	source/blender/makesrna/intern/rna_smoke.c
2016-09-26 17:19:03 +02:00
628ef78e8a overhaul gpuMatrix API
Complete (for our needs) 2D & 3D transformation API. Should be easy to port legacy OpenGL matrix stack-based code to this. Still needs testing.

Ported ortho, frustum, lookAt functions from Viewport FX (rB194998766c65). Kept plenty of Viewport FX code from previous commit.

Stack API and 2D routines ported from Gawain. This version uses BLI_math library so everything is licensed under GPL instead of the usual MPL.

Part of T49450
2016-09-25 19:29:45 +02:00
a731c75442 port math function from Viewport FX
mul_v4_m4v3(r, M, v) means r = M * vec4(v, 1.0)
Based on rB194998766c65
2016-09-25 19:01:18 +02:00
9bea012b8c specialize mat3 multiply routines
Same as 5c6baf1ee9 but for 3x3 matrices.
2016-09-25 18:48:11 +02:00
5c6baf1ee9 specialize mat4 multiply routines
mul_m4_m4m4(R, A, B) gives us R = AB in general. Existing code assumed the worst, that A and B both alias the output R. For safety it makes internal copies of A and B before calculating & writing R.

This is the least common case. Usually all 3 matrices differ. Often we see M = AM or M = MB, but never M = MM.

With this revision mul_m4_m4m4 is called in exactly the same way but copies inputs only when needed. If you know the inputs are independent of the output use the "uniq" variant to skip the saftety checks.
2016-09-25 14:27:48 +02:00
addc666999 constify BLI_math_matrix inputs
GPU_matrix needs this very soon, and it's good practice in general.

also sprinkled in some TODOs for later
2016-09-24 16:21:38 +02:00
36bbdf142c OpenGL: fix new shader for Mac
Follow-up to rB4a1feaa5558ed60388fd3be41db74fbc54f2ab08
2016-09-23 18:16:45 +02:00
7fc2e333bb small merge fix
Follow-up to rB1dfb89d22930
2016-09-23 18:12:24 +02:00
Julian Eisel
1dfb89d229 Merge branch 'master' into blender2.8
Conflicts:
	intern/ghost/intern/GHOST_ContextCGL.mm
	intern/ghost/intern/GHOST_WindowCocoa.mm
	source/blender/makesrna/intern/rna_main.c
2016-09-23 01:40:19 +02:00
Dalai Felinto
4a1feaa555 immediate mode: Triple Buffer and two new shaders for TEXTURE_2D and TEXTURE_RECT
Use the same vertex shader for both fragment shaders
2016-09-22 13:40:33 +00:00
1d469f3780 OpenGL: remove double precision matrix functions
Proper fp64 is a GL 4.x feature. Pretending to support it in our API is just clutter.
2016-09-22 12:19:24 +02:00
0e7c3dfe75 OpenGL: matrix code from viewport-fx
Bringing over whole files from rB194998766c65
2016-09-22 12:11:40 +02:00
825150605e GPU_basic_shader uses GLSL by default
switch back to old mode at runtime:
blender --enable-legacy-basic-shader
2016-09-21 20:24:02 +02:00
9047717b3f Gawain: support triangle strips & fans in immediate mode
fixes crash in Vertex Paint (color picker)
2016-09-21 15:47:08 +02:00
0f759da370 Gawain: batch drawing works
Forgot to tell OpenGL which shader program the batch is using. Now it works!
2016-09-20 18:03:59 +02:00
Dalai Felinto
284398e517 immediate mode refactor: walk navigation cross 2016-09-20 14:50:24 +00:00
Dalai Felinto
04bc828fb6 gawain update: immAttribute for 2i 2016-09-20 14:50:20 +00:00
Dalai Felinto
6ebf5c18c3 immediate mode refactor: fly navigation square 2016-09-20 14:47:14 +00:00
d3365c5c72 OpenGL: fix GPU_SHADER_TEXT on non-Mac
Developed on Mac and committed quickly.. oops
2016-09-20 16:13:01 +02:00
Julian Eisel
42ad5952ff Quiet warning with -Wformat-signedness
Is actually a redundant cast since Blender uses -funsigned-char, however I think it's fine to be explicit about it in new code so cast is required to make compiler happy. Am not a fan of -funsigned-char anyway...
2016-09-20 14:23:15 +02:00
34bd89a9f6 OpenGL: draw_view_axis with new immediate mode
Changed drawing to use smooth lines, and to fade away when axis points toward / away from screen. (transform manipulators do this already)

Also fixed a nearby (but unrelated) missing immUnbindProgram.

Part of T49043
2016-09-17 15:52:32 +02:00
e21853abb9 OpenGL: streamline font rendering
Ignore texture matrix in the shader, stop messing with texture matrix in BLF code.

Use linear screen-space interpolation instead of perspective.

Avoid redundant call to glMatrixMode.
2016-09-17 13:54:30 +02:00
1b1275f0db add GPU_SHADER_TEXT for font rendering
With USE_GLSL enabled, GPU_basic_shader(TEXTURE|COLOR) always rendered black. New shader uses a solid color + alpha channel of texture (which in our case is a font glyph). See fragment shader for details.

I prefer this approah -- multiple shaders that each do one thing well (and are easy to read/write/understand), instead of one shader that can do many things given the right options.
2016-09-17 13:33:48 +02:00
c3034afa58 OpenGL: simplify basic_shader_bind
No need to enable/disable texturing with GLSL, just use textures in the fragment shader.
2016-09-17 13:33:48 +02:00
834cb93f40 Blender 2.8: Fix some strict aspects on Linux 2016-09-16 17:18:19 +02:00
d96b8e168f Merge branch 'master' into blender2.8 2016-09-16 17:09:28 +02:00
76c99f361f Gawain improvements
Fixed compile error in debug build (thanks mont29)

Renamed some functions for consistency.

New features:

Create a Batch with immediate mode! Just use immBeginBatch instead of immBegin. You can keep the result and draw it as many times as you like. This partially replaces the need for display lists.

Copy a VertexFormat, and create a VertexBuffer using an existing format.

Resize a VertexBuffer to a different number of vertices. (can only resize BEFORE using it to draw)
2016-09-15 21:45:10 +02:00
5eddb80513 Extend Gawain to use Blender's built-in shaders
Was already done for immediate mode, but rearranged code to make a clean separation. Cleaned up #includes for code that uses this feature.

Added same for batched rendering.
2016-09-15 18:41:28 +02:00
39f7a81176 Gawain: batch rendering API
Follow-up to rBddb1d5648dbd

API is nearly complete but untested.

1) create batch with vertex buffer & optional index buffer
2) choose shader program
3) draw!
2016-09-15 16:51:10 +02:00
0d54d32dd6 Gawain: simplify attrib binding API
This API is used internally by the immediate and batch drawing systems.
2016-09-15 12:57:07 +02:00
2fb5a959e9 Gawain: delete bind_attrib_locations
This function modifies the GL program object, which reduces our ability to share a shader among meshes with different vertex formats. Recommended approach is to use get_attrib_locations.
2016-09-15 12:24:06 +02:00
110d68ca1d Gawain: flesh out VertexBuffer
create, specify, fill with data
2016-09-14 16:29:01 +02:00
df7be04ca6 fix Mac build with Xcode 8
Small issues in GHOST
- use NSApplicationDelegate protocol for our app delegate
- make sure NSApp is initialized before using
2016-09-14 16:29:01 +02:00
54b00657ca Gawain: fix Windows compile error
MSVC was NOT happy about uint64_t, now it is.
2016-09-13 03:21:16 -04:00
1b5b899228 OpenGL: add built-in GPU_SHADER_3D_DEPTH_ONLY
We’re discussing several techniques that require a depth pre-pass.
2016-09-13 02:51:38 -04:00
ddb1d5648d Gawain: geometry batches (unfinished)
Vertex Buffer to store vertex attribute data.
Element List (AKA Index Buffer) to select which vertices to use.
Batch combines these into an object that can be built once then drawn
many times.

Porting over from the C++ version… Most of this C code is compiled but
unused. Some of it is not even compiled. Committing now in case I’m
lost at sea.
2016-09-13 02:41:43 -04:00
b6bd299359 Gawain: reorganize source code
Put Gawain source code in a subfolder to make the boundary between the
library and the rest of Blender clear.

Changed Gawain’s license from Apache to Mozilla Public License. Has
more essence of copyleft — closer to GPL but not as restrictive.

Split immediate.c into several files so parts can be reused (adding
more files soon…)
2016-09-13 02:18:33 -04:00
18d49a8283 Gawain: add immBeginAtMost
immBegin requires us to know how many vertices will be drawn. Most times this is fine, but sometimes it can be tricky. Do we make the effort to count everything in one pass, then draw it in a second?

immBeginAtMost makes this simple. Example: I'll draw at most 100 vertices. Supply only 6 verts and it draws only 6.

Any unused space is reclaimed and given to the next immBegin.
2016-09-06 16:56:08 -04:00
031c5bad87 Gawain: fix GL_POINTS in immediate mode
Was using GL_NONE to mean "no primitive" but GL_NONE and GL_POINTS are both defined as 0x0000.

Introducing PRIM_NONE = 0xF which does not clash with any primitive types.
2016-09-06 15:45:10 -04:00
3c29aad787 Merge branch 'master' into blender2.8
Conflicts:
	intern/cycles/blender/blender_particles.cpp
	source/blender/blenkernel/intern/particle.c
	source/blender/gpu/intern/gpu_shader.c
2016-09-04 16:41:06 +02:00
498583844f OpenGL: use new uniform color functions
Color picker code motivated these convenience functions. looks much better now.
2016-08-27 14:14:01 -04:00
9d3813e602 Gawain: convenience functions for uniform color
Application code can pass ubytes, Gawain converts to float vec4 expected by shader.

For now the conversion is simple linear. We can add sRGB support later if needed.
2016-08-27 14:10:37 -04:00
42bbfe7f0a OpenGL: draw grid floor & axes with new immediate mode
Significant rewrite with some improvements.

Maintain visual hierarchy of the grid:
- emphasized lines draw atop normal lines
- axes draw atop all lines (same as before)

Draw axes only once, not twice.

Return early if nothing to draw.

Single draw call for the default case (grid floor with X and Y axes).

Z axis needs a second draw call because it uses 3D coordinates.

Part of T49043
2016-08-26 01:12:44 -04:00
060bf1bd28 OpenGL: draw empties without GLU
Also reduced number of matrix ops by generating final positions directly.

Also removed a display list (deprecated in modern GL).

Tried to reuse sinval & cosval tables but those values are skewed (last value repeats first value, middle values are squished to compensate). Went with sinf & cosf instead.

Part of T49042
2016-08-25 13:45:39 -04:00
da36b447c7 OpenGL: de-GLU the transform manipulator
Part of T49042

Also reduced the number of matrix ops.

TODO: replace glBegin/glVertex with new immediate mode
2016-08-24 23:47:45 -04:00
1fc1fd8372 OpenGL: draw area resize handle with new immediate mode
The little grabby handle in the corner of an area. Now uses 1 draw call
instead of 6.

Also one version of the (+) icon to show a hidden region. Why do we
have multiple versions of this?

Fixed a harmless signed/unsigned error.

Fixed a GL state error that prematurely disabled blending.

Added imm_draw_filled_circle function, which can be used for drawing
other widgets.

Work toward T49042 and T49043
2016-08-22 23:39:42 -04:00
069569f820 Merge branch 'master' into blender2.8
In addition to pack of conflicts listed below, also had to comment out particle part of new Alembic code... :/

Conflicts:
	intern/ghost/intern/GHOST_WindowWin32.cpp
	source/blender/blenkernel/BKE_effect.h
	source/blender/blenkernel/BKE_pointcache.h
	source/blender/blenkernel/intern/cloth.c
	source/blender/blenkernel/intern/depsgraph.c
	source/blender/blenkernel/intern/dynamicpaint.c
	source/blender/blenkernel/intern/effect.c
	source/blender/blenkernel/intern/particle_system.c
	source/blender/blenkernel/intern/pointcache.c
	source/blender/blenkernel/intern/rigidbody.c
	source/blender/blenkernel/intern/smoke.c
	source/blender/blenkernel/intern/softbody.c
	source/blender/depsgraph/intern/builder/deg_builder_relations.cc
	source/blender/gpu/intern/gpu_debug.c
	source/blender/makesdna/DNA_object_types.h
	source/blender/makesrna/intern/rna_particle.c
2016-08-21 13:18:26 +02:00
be2bc7e0f6 OpenGL: draw color picker wheel with new immediate mode
Includes new imm_draw_lined_circle function that can be used for other
widgets.

Part of T49043
2016-08-20 15:40:08 -04:00
eb717ee979 Gawain: more immediate mode functions
Scanned Blender code for commonly used glVertex, glColor functions.
Implemented immVertex, immAttrib versions of these to ease transition
away from legacy OpenGL.
2016-08-20 15:09:32 -04:00
1e6b3ef1a1 cleanup: unused OpenGL utility code
Keeping unused gla2D code because it might be useful, or inspire
something useful, for Blender 2.8 development.

Also removed an old Mac driver bug workaround. Disabled this before the
2.77 release and nobody has complained.
2016-08-20 13:57:17 -04:00
7e02d335c0 OpenGL: don't poll for errors, rely on KHR_debug
Errors are caught & reported by our GL debug callback. This gives us way more useful information than sporadic calls to glGetError.

I removed almost all use of glGetError, including our own GPU_ASSERT_NO_GL_ERRORS and GPU_CHECK_ERRORS_AROUND macros.

Still used in rna_Image_gl_load because it passes unvalidated input to OpenGL functions.

Still used in gpu_state_print_fl_ex as an exception handling hack -- will rewrite this soon.

The optimism embodied by this commit will not prevent OpenGL errors. We need to analyze what would cause GL to fail at certain points and proactively intercept these failures. Or guarantee they can't happen.
2016-08-19 00:52:52 -04:00
d8f036efd6 OpenGL: draw NDOF guide with new immediate mode
This is the rotation pivot guide for 3D mouse input.

Work toward T49043
2016-08-16 21:54:50 -04:00
6b34eed217 Gawain: add v functions to immediate mode
Legacy OpenGL has a matching Vertex3fv for every Vertex3f, and so on. Add something similar to Gawain, just for a few common functions. Might add more as the need arises.
2016-08-16 21:45:17 -04:00
b92d76000d fix #includes for GPU debug
Can now build release and debug.

Close to final version in master (which took several commits).
2016-08-16 17:14:42 -04:00
b8f27b2514 OpenGL: shaders for simple 3D drawing
These are intended for very simple drawing. No lighting etc.

Shares some fragment code with the 2D shaders.

Similar to their 2D counterparts, but are not combined because of
future plans for separate 2D & 3D matrix stacks.
2016-08-16 14:58:53 -04:00
8619e09107 OpenGL: tweak legacy 2D shader
EXT_gpu_shader4 lets us say “noperspective” in GLSL #version 120 just
like in later GLSL.

Mac shader now matches modern GLSL available on other platforms.
2016-08-15 21:44:44 -04:00
23d7ae1843 OpenGL: backtrace on errors (--debug-gpu)
Backtrace so we can pinpoint where the GL error came from. Then fflush
on severe errors in case it's severe enough to crash Blender.
2016-08-15 04:00:59 -04:00
f1ad3483af get latest OpenGL version on Windows + AMD
When we ask for GL 3.2 compatibility profile:
AMD (Radeon HD 6970) gives us exactly this version
NVIDIA (Quadro K600) gives at least this version
Still need to check Intel behavior

We want *at least* the version requested, plus more recent features if
available.

Both GPUs tested & mentioned above are capable of GL 4.5. With this
commit they both give 4.5 to Blender.
2016-08-14 01:27:00 -04:00
91f04b82a5 early out for ortho grid drawing
Helps most when real-world units are used.

Previous code started at the smallest visible unit (e.g. Inches) then
followed to Feet, Yards, Chains, Furlongs, Miles. Always to the largest
unit of the set, even though most would be way off screen.

New code knows whether it skipped any grid lines for the next unit to
fill in, can stop once all lines are on screen.
2016-08-13 22:33:49 -04:00
90c4ad7387 Mac fixes for new ortho grid drawing
Previous commit works on Windows, found some issues after trying on Mac.

- benign warnings about && within ||
- replaced nearbyint() with round() to avoid floating point environment
surprises
- remquo function appears to be broken on Mac (!) results were way way
off. Replaced with simple division.
- minor tweaks to debug output
2016-08-13 22:13:24 -04:00
db5ad6a79e draw ortho grid with new immediate mode
Work toward T49043, with a side of client vertex arrays.

Not a straightforward port from glVertex to immVertex since Gawain needs
to know how many vertices we'll be drawing *before* we start drawing.

Fixed these not-so-great aspects of grid drawing:
- coarse grids would draw atop some lines from the finer grids
- visible axes would draw atop lines from coarse grid
- axes were drawn even if they weren't in view
- terrible misuse of vertex arrays
- each line issued its own draw call

New code draws each line exactly once. The entire grid is one draw call.

Bonus: I had to / got to learn how the units system works!
2016-08-13 18:14:45 -04:00
e36af2c257 Gawain: increase size of immediate mode buffer
New value of 4MB should handle our needs without taking up too many GPU
resources.

Old value of 1KB was for observing what happens when the buffer fills up
and we need to flush and start a new one.
2016-08-13 16:31:44 -04:00
dfbc51f764 cleanup: ortho grid drawing
Getting this ready for Gawain treatment.

Removed setlinestyle(0) -- solid lines are the default,  hope this isn't
really needed.

Eliminated redundant math.

Arithmetic is still double precision, passed to OpenGL as single
precision. Even though it said GL_DOUBLE before, values were converted
to GL_FLOAT internally.

Use C99-isms for declaring variables close to where they're used.

Minor whitespace tweaks.
2016-08-12 17:20:21 -04:00
4565f3d0c8 use new immediate mode for UI_draw_box_shadow
This serves as a good example of the Gawain API. (I’ve thought of a
better way to draw drop shadows, but that can wait!)

Part of T49043.

This is what I had in mind for D1753.
2016-08-11 01:06:17 -04:00
7664d947b3 Gawain: allow partial vertex specification
If you don’t specify a vertex’s color, it will use the color of the
previous vertex. Similar for all other attributes.

This matches the legacy behavior of glColor, glNormal, etc. *except* in
Gawain the first vertex of each immBegin must be fully specified. There
is no “current” color in the new system.
2016-08-11 00:11:48 -04:00
4aadf7331e Gawain: tweak immediate mode API
Should be simpler to use now.

Made vertex format structure private. New immVertexFormat() function
clears and returns the format. Devs can start with add_attrib(format...)
and not have to clear it first.

immBindProgram automatically packs the vertex format if needed.

Updated 3D cursor drawing to use new API.
2016-08-10 18:01:04 -04:00
f537d96286 Merge branch 'blender2.8' of git.blender.org:blender into blender2.8 2016-08-10 16:09:08 -04:00
adbbcefe57 Gawain: fewer glEnable/DisableVertexAttribArray calls
Track previously enabled attrib locations so we can call OpenGL only
when needed.

Same result, fewer GL calls.
2016-08-10 16:08:32 -04:00
8fd4a8ab5d Merge branch 'master' into blender2.8
Conflicts:
	source/blender/blenkernel/intern/library.c
	source/blender/blenkernel/intern/particle.c
2016-08-10 15:06:40 +02:00
e7a32365cf Gawain: map vertex format to shader inputs
glBindAttribLocation does not take effect until the program is
re-linked. In other words I was doing it wrong!

New code gets attrib locations from program, then remembers the attrib
-> location mapping for subsequent draw calls.

The program and VertexFormat are not modified (makes threading and reuse
easier).
2016-08-10 04:45:23 -04:00
5320a0ad9b Gawain: fix compiler warnings
properly typed function parameters
pointer casting & arithmetic
ptrdiff_t formatting
2016-08-10 02:38:51 -04:00
e4e1b0c7d3 OpenGL: invalidate buffers the modern way
There are older ways to give OpenGL hints about buffer invalidation, but
glInvalidateBufferData does exactly what we want. Use this function when
OpenGL 4.3 is available (Windows and proprietary Linux drivers).

Part of Gawain immediate mode.
2016-08-09 17:17:34 -04:00
f3d65ad23c OpenGL: debug context on Windows
Enable based on --debug-gpu at the command line. Linux already works
this way.
2016-08-09 03:29:49 -04:00
b7f3fb0ef9 Gawain: fix Windows build error
MSVC is more strict than  gcc or clang about pointer arithmetic. Also
fixed pointer cast warnings.
2016-08-09 02:27:54 -04:00
a77e77599d OpenGL: enhance debug output
When running blender --debug-gpu

Display which debug facilities are available. One of these, in order of preference:
- OpenGL 4.3
- KHR_debug
- ARB_debug_output
- AMD_debug_output

All messages are logged now, not just errors. Will probably turn some of these off later.

GL_DEBUG_OUTPUT_SYNCHRONOUS lets us break on errors and backtrace to the exact trouble spot.

Callers of GPU_string_marker no longer pass in a message length, just the message itself (null terminated).

Apple provides no GL debug logging features.
2016-08-09 01:29:58 -04:00
9893153799 OpenGL: fix FBO error messages
Old code had a mix of framebuffer error codes from OpenGL ES, EXT_framebuffer_object, and desktop GL. We use desktop GL (or ARB_framebuffer_object which acts just like GL 3.x) so I made it compatible with that.

Changed messages to the actual GL_FRAMEBUFFER_XXX symbols. These are less friendly and more accurate. Can easily look up what an error means, unfiltered by what a Blender dev thinks it means.

Kept ES error codes around in case we support that one day. Just flip the #if or use a compile-time option.
2016-08-08 18:02:40 -04:00
39259fc8ab draw 3D cursor with new immediate mode
Replace legacy OpenGL with Gawain. Use shaders instead of fixed
function pipeline.

This simple UI element is shown at startup so is easy to verify things
are working. It also serves as a good example for people converting
other parts of the code.

Part of T49043
2016-08-08 15:45:18 -04:00
c73e4e99a5 OpenGL: simple 2D shader with flat color
Flat color means each primitive will use color from the provoking
vertex.
2016-08-08 04:56:02 -04:00
4214b3c44a OpenGL: simplify 3D cursor drawing
Use simple alternating colored lines instead of stippled overdraw.

Reimplement circ function to not use deprecated GLU (T49042). It also
leaves matrix stack untouched.

Remove unused circf function.
2016-08-08 03:17:24 -04:00
6c65e5a00c GPU: bind builtin shader for immediate mode
immBindBuiltinProgram extends Gawain’s immBindProgram to use Blender’s
library of built-in shader programs.

It uses imm prefix instead of GPU_ so people won’t be tempted to call
GPU_unbind_program() afterward.

From my understanding, Apache code is not allowed to call GPL code, so
this function needs to be in the GPU lib.
2016-08-07 22:11:45 -04:00
8e99eec026 Gawain: immediate mode set uniforms for active program
Start simple with vec4 uniforms. Add more later.
2016-08-07 21:30:02 -04:00
11ffbfb36a Gawain: bind a shader for immediate mode
How to use:
1) set up vertex format
2) bind a shader
3) draw with immBegin … immEnd
4) unbind shader

TODO: expand this a little, so we can send uniform values to the bound
shader.
2016-08-07 01:35:42 -04:00
6fea42d677 Gawain: initialize & destroy immediate mode
TODO: make this work better with multiple OpenGL contexts
2016-08-07 01:30:45 -04:00
f27516839f fix simple 2D built-in shaders
Forgot the projection matrix.
2016-08-07 01:26:29 -04:00
0ea8430549 Gawain: legacy Mac VBO workarounds
glMapBufferRange is a wonderful function that doesn’t exist on GL < 3.0.

Use the APPLE_flush_buffer_range extension on Mac. It offers several of
glMapBufferRange’s benefits.

Use older “black arts” method to orphan VBOs when we are done with
them. In modern OpenGL this behavior is more obvious.

Add APPLE_flush_buffer_range to Mac requirements. Every GPU is
supported. T49012
2016-08-07 01:05:49 -04:00
e7f9614f07 Gawain: legacy OpenGL compatibility
Apple invented VAOs and exposes them via an extension in legacy GL.
Other platforms use at least GL 3.0 which has VAOs built in.

QUADS were removed from core profile but are useful for immediate-mode
drawing. We’ll have to implement our own QUAD drawing before switching
to core profile.
2016-08-07 01:05:49 -04:00
6b21d22c60 Gawain: fix VAO and VBO binds
Immediate mode no longer leaves its internals bound after use. Part of
transition from a simple prototype app to non-simple Blender, which has
lots of other parts using OpenGL.
2016-08-07 01:05:49 -04:00
a55c5dbcc4 Gawain: flesh out immediate mode
More ways to send values via immAttrib:
2D float vectors
3 & 4 component ubytes (for colors mostly)

New immVertex functions that act more like familiar glVertex. We’ll
find a balance between making this API convenient and keeping it small.
2f and 3f are enough for now.
2016-08-07 01:05:49 -04:00
3eae585791 Merge branch 'master' into blender2.8 2016-08-06 12:57:21 +02:00
9843921288 Merge branch 'master' into blender2.8
Conflicts:
	release/scripts/startup/bl_ui/properties_particle.py
	release/scripts/startup/bl_ui/properties_physics_cloth.py
	release/scripts/startup/bl_ui/properties_physics_dynamicpaint.py
	release/scripts/startup/bl_ui/properties_physics_softbody.py
	source/blender/blenkernel/BKE_library.h
	source/blender/blenkernel/BKE_particle.h
	source/blender/blenkernel/intern/cloth.c
	source/blender/blenkernel/intern/library.c
	source/blender/blenkernel/intern/library_query.c
	source/blender/blenkernel/intern/particle_system.c
	source/blender/blenkernel/intern/scene.c
	source/blender/blenkernel/intern/softbody.c
	source/blender/blenloader/intern/readfile.c
	source/blender/blenloader/intern/versioning_270.c
	source/blender/editors/space_file/filesel.c
	source/blender/editors/space_outliner/outliner_intern.h
	source/blender/makesdna/DNA_ID.h
	source/blender/makesdna/DNA_object_force.h
	source/blender/makesdna/DNA_particle_types.h
	source/blender/makesrna/intern/rna_particle.c
	source/blender/makesrna/intern/rna_sculpt_paint.c
	source/blender/makesrna/intern/rna_smoke.c
	source/blender/makesrna/intern/rna_space.c
2016-08-06 12:45:03 +02:00
4571fdde0e OpenGL: transition to ARB FBOs, remove runtime checks
ARB_framebuffer_object replaces several related EXT extensions. The ARB
version pulls GL 3 FBO features into GL 2.1, useful for Mac platform.
Its functions and enums have no ARB suffix so transition to modern GL
will be seamless!

Extension is checked at startup, so is guaranteed to be true at runtime.

Part of T49012
2016-08-04 21:11:45 -04:00
58697444bb OpenGL: remove runtime check for EXT_gpu_shader4
It’s checked at startup, so is guaranteed to be true at runtime.

Part of T49012
2016-08-04 20:27:24 -04:00
32757d488f OpenGL: require EXT_gpu_shader4 & ARB_framebuffer_object on Mac
Mac’s OpenGL version is furthest away from our target of GL 3.2. This
commit brings Mac closer to other platforms, so that our shaders and
other code don’t diverge too much during development.

According to Apple’s OpenGL matrix these useful extensions are
available on all GPUs that will be able to run Blender 2.8.

Only checked in debug builds; we might need something more forceful.

Part of T49012
2016-08-04 20:25:47 -04:00
396dd82428 OpenGL: add simple shaders for 2D drawing
The first two of several new simple built-in shaders (will test these
before adding more). These are intended for the new immediate mode API,
but you can use them just like any built-in GPUShader.

Due to limitations on different platforms, shaders need to work with
GLSL versions 120, 130 and 150. Final Blender 2.8 will be pure #version
150.
2016-08-04 15:59:38 -04:00
797f1896fa OpenGL: immediate mode work-alike
Introducing an immediate mode drawing API that works with modern GL 3.2
core profile. I wrote and tested this using a core context on Mac.

This is part of the Gawain library which is Apache 2 licensed. Be very
careful not to pull other Blender code into these files.

Modifications for the Blender integration:
- prefix filenames to match rest of Blender’s GPU libs
- include GPU_glew.h instead of <OpenGL/gl3.h>
- disable thread-local vars until we figure out how best to do this
2016-08-04 15:36:20 -04:00
42d816a3d9 Blender 2.8 requires Mac OS 10.7 or later
MacOS 10.7 “Lion” was the first to implement OpenGL 3.2, which will be
required to run Blender 2.8.

Minimum OS version was unspecified before.
2016-08-04 03:13:20 -04:00
3d9cc4d3f1 support automatic GPU switching on Mac
First attempt. On my laptop (Intel + nVidia) Blender still switches to
nVidia at launch time.
2016-08-04 03:08:13 -04:00
b3cb7e2652 OpenGL: on Mac use legacy 2.1 or core 3.2
This implements Mac part of T49012.

Removed options for EGL, ES2, compatibility profile. None of these
exist on Mac platform.

Create a GL 3.2 core context when requested at build time. Old code
just pretended to support core profile.
2016-08-04 02:36:46 -04:00
0d1f0116fe OpenGL: Blender 2.8 on X11 requires GL 3.0
Implements the Linux part of T49012.

Simplify the options for context creation. No options for legacy GL or EGL or ES2. Select 3.2 CORE or COMPATIBILITY profile at build time.

If that fails, use a GL 3.0 context. This keeps Mesa supported while we work on full 3.2 core elsewhere in the code.
2016-08-03 17:58:24 -04:00
eccf5a6f81 OpenGL: Blender 2.8 on Windows requires GL 3.2
This greatly simplifies the options for context creation. No options for
legacy GL or EGL or ES2. Select CORE or COMPATIBILITY profile at build
time.

OpenGL 3.2 core profile will be our final target on all platforms. Until
all our code is ready we can use 3.2 compatibility profile or "legacy"
GL 2.1 on platforms that don't support compatibility profile.
2016-08-03 14:46:29 -04:00
251349c3c2 Merge branch 'master' into blender2.8 2016-07-28 12:00:58 +10:00
b1532493c2 Merge branch 'master' into blender2.8
Conflicts:
	source/blender/blenkernel/BKE_particle.h
	source/blender/blenkernel/intern/library.c
	source/blender/blenkernel/intern/particle.c
2016-07-25 15:07:17 +02:00
9186b9ae48 Merge branch 'master' into blender2.8 2016-07-18 19:25:44 +10:00
cfbd605567 Merge branch 'master' into blender2.8
Conflicts:
	intern/cycles/blender/addon/ui.py
	source/blender/blenkernel/BKE_particle.h
	source/blender/blenkernel/intern/dynamicpaint.c
	source/blender/blenkernel/intern/library.c
	source/blender/blenkernel/intern/object.c
	source/blender/blenkernel/intern/particle.c
	source/blender/blenkernel/intern/particle_distribute.c
	source/blender/blenkernel/intern/texture.c
	source/blender/editors/object/object_add.c
	source/blender/editors/object/object_relations.c
	source/blender/editors/physics/particle_edit.c
	source/blender/editors/physics/particle_object.c
	source/blender/editors/transform/transform_snap_object.c
2016-07-12 00:07:44 +02:00
71a57a37b2 Merge branch 'master' into blender2.8 2016-06-29 17:58:39 +02:00
f45fbf4b83 Merge branch 'master' into blender2.8 2016-06-29 17:45:16 +02:00
b90b02a480 Merge branch 'master' into blender2.8 2016-06-28 21:21:11 +10:00
5ae6a3b6b6 Merge branch 'master' into blender2.8 2016-06-28 21:10:11 +10:00
0f927d6eca Fix stupid merge error. 2016-06-27 16:07:38 +02:00
cbce7fef16 Merge branch 'master' into blender2.8
Conflicts:
	source/blender/blenkernel/intern/pointcache.c
	source/blender/makesrna/intern/rna_main_api.c
	source/blender/makesrna/intern/rna_particle.c
2016-06-27 15:59:01 +02:00
c2dc77983d Merge branch 'master' into blender2.8
No changes, just resolve conflicts.
2016-06-23 08:04:19 +10:00
3b0a5dd158 Merge branch 'master' into blender2.8 2016-06-23 07:52:58 +10:00
97ee7f8609 Merge branch 'master' into blender2.8
Conflicts:
	source/blender/blenloader/intern/readfile.c
	source/blender/editors/physics/particle_edit.c
2016-06-22 13:12:44 +02:00
48c58bd913 Merge branch 'master' into blender2.8 2016-06-21 12:14:49 +10:00
2cfff95ba3 Merge branch 'master' into blender2.8 2016-06-15 17:41:22 +10:00
eedcc4a6a0 Merge branch 'master' into blender2.8 2016-06-15 17:29:11 +10:00
5864269b2c Merge branch 'master' into blender2.8 2016-06-13 19:26:56 +10:00
46e1d85e61 Reduce conflicts be keeping same indent-level as master 2016-06-10 05:51:34 +10:00
c96d4ec644 Merge branch 'master' into blender2.8 2016-06-10 05:46:29 +10:00
a151806698 Merge branch 'master' into blender2.8 2016-06-10 05:17:33 +10:00
10d57f991b Merge branch 'master' into blender2.8 2016-06-10 05:15:06 +10:00
4b99958ca1 Remove particle expander
Having this caused buffer-overrun on startup
2016-06-07 18:27:31 +10:00
1e5735ab99 World space switch for BI nodes.
At the moment light shading in Blender is produced in viewspace. Apparently, that's why
shader nodes work with normals in camera space. But it is not convenient for artists.
The more convenient approach is implemented in Cycles where normals are represented in world space.
Blend4Web Team designed the engine keeping in mind shader parameters readability,
so normals are interpreted in world space as well. And now our users have to use some tweaks, like
empty node group with the name "Replace", which is replacing one input by another on the engine side
(replacing working configuration in Blender Viewport by the configuration that has the same behavior in the engine).

This patch adds the ability to switch to world space for normals and lamp vector in BI and Viewport.
This patch is very important to us and we crave to see this patch in Blender 2.7 because
it will significantly simplify Blend4Web material creation workflow.

{F315547}

{F315548}

Reviewers: campbellbarton, brecht

Reviewed By: brecht

Subscribers: homyachetser, Evgeny_Rodygin, AlexKowel, yurikovelenov

Differential Revision: https://developer.blender.org/D2046
2016-06-07 10:21:55 +02:00
5750549f6a Cleanup: warnings 2016-06-07 18:16:03 +10:00
ed6f86a510 Merge branch 'master' into blender2.8 2016-06-07 18:06:46 +10:00
24d29f2e50 Merge branch 'master' into blender2.8
Conflicts:
	source/blender/blenkernel/intern/particle.c
	source/blender/editors/transform/transform_snap_object.c
2016-06-07 09:59:26 +02:00
11af9e9a5b Merge branch 'master' into blender2.8
Conflicts:
	intern/cycles/blender/blender_curves.cpp
	intern/cycles/blender/blender_particles.cpp
	source/blender/depsgraph/intern/builder/deg_builder_relations.h
	source/blender/depsgraph/intern/depsgraph_build.cc
2016-06-01 14:34:11 +02:00
faec430914 Merge branch 'master' into blender2.8
Conflicts:
	intern/cycles/blender/blender_curves.cpp
	source/blender/blenkernel/intern/dynamicpaint.c
	source/blender/blenkernel/intern/particle.c
	source/blender/blenloader/intern/versioning_270.c
	source/blender/editors/physics/particle_edit.c
	source/blender/editors/transform/transform_snap_object.c
	source/blender/editors/util/undo.c
	source/blender/makesrna/intern/rna_object_force.c
2016-05-24 16:48:10 +02:00
f85745b17b Flat shading for basic shader
The purpose of the patch is to replace deprecated  glShadeModel.

To decrease glShadeModel calls I've set GL_SMOOTH by default

Reviewers: merwin, brecht

Reviewed By: brecht

Subscribers: blueprintrandom, Evgeny_Rodygin, AlexKowel, yurikovelenov

Differential Revision: https://developer.blender.org/D1958
2016-05-16 11:13:21 +03:00
b4a721af69 Merge branch 'temp_remove_pointcache' into blender2.8 2016-05-02 11:00:34 +02:00
5aa19be912 Merge branch 'temp_remove_particles' into blender2.8 2016-05-02 11:00:26 +02:00
735727e2b8 Removed DNA for point caches. 2016-04-30 14:20:13 +02:00
ac30a04b27 Removed point cache blenkernel code. 2016-04-29 15:03:58 +02:00
181d095f50 Removed PointCache RNA struct definition and uses. 2016-04-29 11:07:11 +02:00
ceb452bc9d Removed point cache operators. 2016-04-29 10:44:09 +02:00
c3863650cc Removed UI for point cache users. 2016-04-28 18:38:10 +02:00
1f723603c8 Merge branch 'master' into temp_remove_particles 2016-04-28 17:33:19 +02:00
3632c4997f Merge branch 'master' into temp_remove_particles 2016-04-20 16:25:16 +02:00
773efb506a Removed particle sync code from Cycles.
Note that this only removes the actual dependencies of Cycles on the
particle code in Blender, but not the internal "particle" definition
or the curve type handling inside Cycles. These structures may be in need
of some improvement themselves, but that is out of scope here.
2016-04-20 11:59:02 +02:00
ba279efbdb Removed the ND_PARTICLE notifier and outliner particle elements. 2016-04-16 17:27:49 +02:00
9465d3decf Removed the particle context of property buttons space. 2016-04-16 17:17:31 +02:00
ecb695ccc8 Removed tool settings for particle edit mode. 2016-04-16 14:26:09 +02:00
cd0ec340c4 Removed remaining uses of the particle edit mode flag. 2016-04-16 12:39:41 +02:00
15c8d095e5 Removed the Main.particle list, used for ParticleSettings ID blocks.
There were still some type-agnostic uses as well, owing to the generic
ListBase type.
2016-04-16 12:28:29 +02:00
7c57822afa Fixed some minor errors in game engine and player. 2016-04-16 12:11:34 +02:00
c92b6f1de6 Removed the translation context for particle settings. 2016-04-16 11:32:45 +02:00
d30b942f07 Removed the ID_PA code used for ParticleSettings. 2016-04-16 11:29:28 +02:00
df2e543d44 Removed some unused declarations for boids code. 2016-04-16 11:11:39 +02:00
fbed29a246 Merge branch 'master' into temp_remove_particles 2016-04-15 17:59:54 +02:00
987bb50a74 Removed remaining use of pointers to particle types as well as boids headers. 2016-04-13 18:10:23 +02:00
d474ed9b88 Partially revert 82ec9c87a7, to add back point cache operators.
Eventually point cache will also be replaced, but it can be kept working at first even without particles.
2016-04-13 16:58:44 +02:00
664f5b8c06 Removed particle DNA. 2016-04-13 13:41:11 +02:00
d8d49befa0 Removed particle system and particle instance modifiers. 2016-04-13 11:45:15 +02:00
d47173c8ca Removed blenkernel particle code. 2016-04-13 10:49:39 +02:00
cf6cb3dcaf Removed most particle system code from RNA. 2016-04-12 18:26:19 +02:00
bcd12bf64d Removed most partical-related code from UI scripts.
There are a lot of cases here where deciding for removal is a bit tricky.
Many features have options for "use_particles" and similar settings. Only
features which actually store a particle object reference or work on actual
particle data have been removed.
2016-04-12 16:28:00 +02:00
29a792a75b Removed all direct uses of BKE_particle.h and DNA_particle_types.h from source/blender/editors. 2016-04-12 13:04:31 +02:00
cc468c1974 Removed remnants of particle draw code. 2016-04-12 12:18:38 +02:00
82ec9c87a7 Removed particle operators API and point cache operators. 2016-04-12 11:47:08 +02:00
5a783144e2 Removed particle operators from editors/physics/. 2016-04-12 11:25:40 +02:00
819 changed files with 67646 additions and 29335 deletions

4
.gitmodules vendored
View File

@@ -1,20 +1,24 @@
[submodule "release/scripts/addons"]
path = release/scripts/addons
url = ../blender-addons.git
branch = blender2.8
ignore = all
branch = master
[submodule "release/scripts/addons_contrib"]
path = release/scripts/addons_contrib
url = ../blender-addons-contrib.git
branch = master
ignore = all
branch = master
[submodule "release/datafiles/locale"]
path = release/datafiles/locale
url = ../blender-translations.git
branch = master
ignore = all
branch = master
[submodule "source/tools"]
path = source/tools
url = ../blender-dev-tools.git
branch = master
ignore = all
branch = master

View File

@@ -242,6 +242,8 @@ endif()
option(WITH_PLAYER "Build Player" OFF)
option(WITH_OPENCOLORIO "Enable OpenColorIO color management" ${_init_OPENCOLORIO})
option(WITH_CLAY_ENGINE "Enable New Clay engine (Breaks Mac and Intel compatibility)" ON)
# Compositor
option(WITH_COMPOSITOR "Enable the tile based nodal compositor" ON)
@@ -472,12 +474,6 @@ mark_as_advanced(
WITH_GL_PROFILE_ES20
)
if(WITH_GL_PROFILE_COMPAT)
set(WITH_GLU ON)
else()
set(WITH_GLU OFF)
endif()
if(WIN32)
option(WITH_GL_ANGLE "Link with the ANGLE library, an OpenGL ES 2.0 implementation based on Direct3D, instead of the system OpenGL library." OFF)
mark_as_advanced(WITH_GL_ANGLE)
@@ -498,11 +494,10 @@ endif()
# We default options to whatever default standard in the current compiler.
if(CMAKE_COMPILER_IS_GNUCC AND (NOT "${CMAKE_C_COMPILER_VERSION}" VERSION_LESS "6.0") AND (NOT WITH_CXX11))
set(_c11_init ON)
set(_cxx11_init ON)
else()
set(_c11_init OFF)
set(_cxx11_init OFF)
endif()
set(_cxx11_init ON)
option(WITH_C11 "Build with C11 standard enabled, for development use only!" ${_c11_init})
mark_as_advanced(WITH_C11)
@@ -1057,11 +1052,6 @@ endif()
find_package(OpenGL)
blender_include_dirs_sys("${OPENGL_INCLUDE_DIR}")
if(WITH_GLU)
list(APPEND BLENDER_GL_LIBRARIES "${OPENGL_glu_LIBRARY}")
list(APPEND GL_DEFINITIONS -DWITH_GLU)
endif()
if(WITH_SYSTEM_GLES)
find_package_wrapper(OpenGLES)
endif()
@@ -1289,9 +1279,7 @@ else()
endif()
if(NOT WITH_GLU)
list(APPEND GL_DEFINITIONS -DGLEW_NO_GLU)
endif()
list(APPEND GL_DEFINITIONS -DGLEW_NO_GLU)
#-----------------------------------------------------------------------------
# Configure Bullet
@@ -1799,7 +1787,6 @@ if(FIRST_RUN)
info_cfg_text("OpenGL:")
info_cfg_option(WITH_GLEW_ES)
info_cfg_option(WITH_GLU)
info_cfg_option(WITH_GL_EGL)
info_cfg_option(WITH_GL_PROFILE_COMPAT)
info_cfg_option(WITH_GL_PROFILE_CORE)

View File

@@ -402,7 +402,7 @@ update: .FORCE
svn update ../lib/* ; \
fi
git pull --rebase
git submodule foreach git pull --rebase origin master
git submodule update --remote
# -----------------------------------------------------------------------------

View File

@@ -25,7 +25,7 @@
ARGS=$( \
getopt \
-o s:i:t:h \
--long source:,install:,tmp:,info:,threads:,help,show-deps,no-sudo,no-build,no-confirm,use-cxx11,\
--long source:,install:,tmp:,info:,threads:,help,show-deps,no-sudo,no-build,no-confirm,\
with-all,with-opencollada,\
ver-ocio:,ver-oiio:,ver-llvm:,ver-osl:,ver-osd:,ver-openvdb:,\
force-all,force-python,force-numpy,force-boost,\
@@ -104,11 +104,6 @@ ARGUMENTS_INFO="\"COMMAND LINE ARGUMENTS:
--no-confirm
Disable any interaction with user (suitable for automated run).
--use-cxx11
Build all libraries in cpp11 'mode' (will be mandatory soon in blender2.8 branch).
NOTE: If your compiler is gcc-6.0 or above, you probably *want* to enable this option (since it's default
standard starting from this version).
--with-all
By default, a number of optional and not-so-often needed libraries are not installed.
This option will try to install them, at the cost of potential conflicts (depending on
@@ -287,7 +282,7 @@ SUDO="sudo"
NO_BUILD=false
NO_CONFIRM=false
USE_CXX11=false
USE_CXX11=true # Mandatory in blender2.8
PYTHON_VERSION="3.5.2"
PYTHON_VERSION_MIN="3.5"
@@ -499,9 +494,6 @@ while true; do
--no-confirm)
NO_CONFIRM=true; shift; continue
;;
--use-cxx11)
USE_CXX11=true; shift; continue
;;
--with-all)
WITH_ALL=true; shift; continue
;;
@@ -793,7 +785,7 @@ FFMPEG_SOURCE=( "http://ffmpeg.org/releases/ffmpeg-$FFMPEG_VERSION.tar.bz2" )
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
WARNING "C++11 is now mandatory for blender2.8, this *should* go smoothly with any very recent distribution.
However, if you are experiencing linking errors (also when building Blender itself), please try the following:
* 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.

View File

@@ -597,6 +597,8 @@ function(SETUP_BLENDER_SORTED_LIBS)
bf_modifiers
bf_bmesh
bf_gpu
bf_draw
bf_intern_gawain
bf_blenloader
bf_blenkernel
bf_physics

View File

@@ -23,6 +23,8 @@
# Libraries configuration for Apple.
set(MACOSX_DEPLOYMENT_TARGET "10.9")
if(NOT DEFINED LIBDIR)
if(WITH_CXX11)
set(LIBDIR ${CMAKE_SOURCE_DIR}/../lib/darwin)

View File

@@ -52,6 +52,7 @@ class OffScreenDraw(bpy.types.Operator):
@staticmethod
def _update_offscreen(context, offscreen):
scene = context.scene
render_layer = context.render_layer
render = scene.render
camera = scene.camera
@@ -65,6 +66,7 @@ class OffScreenDraw(bpy.types.Operator):
offscreen.draw_view3d(
scene,
render_layer,
context.space_data,
context.region,
projection_matrix,

View File

@@ -1024,6 +1024,7 @@ context_type_map = {
"brush": ("Brush", False),
"camera": ("Camera", False),
"cloth": ("ClothModifier", False),
"collection": ("LayerCollection", False),
"collision": ("CollisionModifier", False),
"curve": ("Curve", False),
"dynamic_paint": ("DynamicPaintModifier", False),
@@ -1055,6 +1056,7 @@ context_type_map = {
"particle_system": ("ParticleSystem", False),
"particle_system_editable": ("ParticleSystem", False),
"pose_bone": ("PoseBone", False),
"render_layer": ("SceneLayer", False),
"scene": ("Scene", False),
"sculpt_object": ("Object", False),
"selectable_bases": ("ObjectBase", True),

View File

@@ -33,6 +33,7 @@ add_subdirectory(opencolorio)
add_subdirectory(mikktspace)
add_subdirectory(glew-mx)
add_subdirectory(eigen)
add_subdirectory(gawain)
if(WITH_GAMEENGINE_DECKLINK)
add_subdirectory(decklink)

View File

@@ -1589,6 +1589,7 @@ class CyclesScene_PT_simplify(CyclesButtonsPanel, Panel):
row.prop(rd, "simplify_subdivision", text="Viewport")
row.prop(rd, "simplify_subdivision_render", text="Render")
col = layout.column(align=True)
col.label(text="Child Particles")
row = col.row(align=True)

View File

@@ -0,0 +1,34 @@
set(INC gawain)
set(INC_SYS ${GLEW_INCLUDE_PATH})
set(SRC
src/attrib_binding.c
src/batch.c
src/element.c
src/buffer_id.cpp
src/immediate.c
src/imm_util.c
src/primitive.c
src/shader_interface.c
src/vertex_buffer.c
src/vertex_format.c
gawain/attrib_binding.h
gawain/batch.h
gawain/buffer_id.h
gawain/common.h
gawain/element.h
gawain/immediate.h
gawain/imm_util.h
gawain/primitive.h
gawain/shader_interface.h
gawain/vertex_buffer.h
gawain/vertex_format.h
)
# remove this when we switch to core profile
add_definitions(-DWITH_GL_PROFILE_COMPAT)
blender_add_lib(bf_intern_gawain "${SRC}" "${INC}" "${INC_SYS}")

View File

@@ -0,0 +1,24 @@
// Gawain vertex attribute binding
//
// This code is part of the Gawain library, with modifications
// specific to integration with Blender.
//
// Copyright 2016 Mike Erwin
//
// This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0. If a copy of
// the MPL was not distributed with this file, You can obtain one at https://mozilla.org/MPL/2.0/.
#pragma once
#include "vertex_format.h"
typedef struct {
uint64_t loc_bits; // store 4 bits for each of the 16 attribs
uint16_t enabled_bits; // 1 bit for each attrib
} AttribBinding;
void clear_AttribBinding(AttribBinding*);
void get_attrib_locations(const VertexFormat*, AttribBinding*, GLuint program);
unsigned read_attrib_location(const AttribBinding*, unsigned a_idx);

View File

@@ -0,0 +1,110 @@
// Gawain geometry batch
//
// This code is part of the Gawain library, with modifications
// specific to integration with Blender.
//
// Copyright 2016 Mike Erwin
//
// This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0. If a copy of
// the MPL was not distributed with this file, You can obtain one at https://mozilla.org/MPL/2.0/.
#pragma once
#include "vertex_buffer.h"
#include "element.h"
typedef enum {
READY_TO_FORMAT,
READY_TO_BUILD,
BUILDING,
READY_TO_DRAW
} BatchPhase;
#define BATCH_MAX_VBO_CT 3
typedef struct Batch {
// geometry
VertexBuffer* verts[BATCH_MAX_VBO_CT]; // verts[0] is required, others can be NULL
ElementList* elem; // NULL if element list not needed
PrimitiveType prim_type;
// book-keeping
GLuint vao_id; // remembers all geometry state (vertex attrib bindings & element buffer)
BatchPhase phase;
bool program_dirty;
bool program_in_use;
// state
GLuint program;
} Batch;
Batch* Batch_create(PrimitiveType, VertexBuffer*, ElementList*);
void Batch_init(Batch*, PrimitiveType, VertexBuffer*, ElementList*);
void Batch_discard(Batch*); // verts & elem are not discarded
void Batch_discard_all(Batch*); // including verts & elem
int Batch_add_VertexBuffer(Batch*, VertexBuffer*);
void Batch_set_program(Batch*, GLuint program);
// Entire batch draws with one shader program, but can be redrawn later with another program.
// Vertex shader's inputs must be compatible with the batch's vertex format.
void Batch_use_program(Batch*); // call before Batch_Uniform (temp hack?)
void Batch_done_using_program(Batch*);
void Batch_Uniform1i(Batch*, const char* name, int value);
void Batch_Uniform1b(Batch*, const char* name, bool value);
void Batch_Uniform1f(Batch*, const char* name, float value);
void Batch_Uniform2f(Batch*, const char* name, float x, float y);
void Batch_Uniform3f(Batch*, const char* name, float x, float y, float z);
void Batch_Uniform4f(Batch*, const char* name, float x, float y, float z, float w);
void Batch_Uniform3fv(Batch*, const char* name, const float data[3]);
void Batch_Uniform4fv(Batch*, const char* name, const float data[4]);
void Batch_draw(Batch*);
// clement : temp stuff
void Batch_draw_stupid(Batch*);
void Batch_draw_stupid_instanced(Batch*, unsigned int instance_vbo, int instance_count,
int attrib_nbr, int attrib_stride, int attrib_loc[16], int attrib_size[16]);
#if 0 // future plans
// Can multiple batches share a VertexBuffer? Use ref count?
// We often need a batch with its own data, to be created and discarded together.
// WithOwn variants reduce number of system allocations.
typedef struct {
Batch batch;
VertexBuffer verts; // link batch.verts to this
} BatchWithOwnVertexBuffer;
typedef struct {
Batch batch;
ElementList elem; // link batch.elem to this
} BatchWithOwnElementList;
typedef struct {
Batch batch;
ElementList elem; // link batch.elem to this
VertexBuffer verts; // link batch.verts to this
} BatchWithOwnVertexBufferAndElementList;
Batch* create_BatchWithOwnVertexBuffer(PrimitiveType, VertexFormat*, unsigned v_ct, ElementList*);
Batch* create_BatchWithOwnElementList(PrimitiveType, VertexBuffer*, unsigned prim_ct);
Batch* create_BatchWithOwnVertexBufferAndElementList(PrimitiveType, VertexFormat*, unsigned v_ct, unsigned prim_ct);
// verts: shared, own
// elem: none, shared, own
Batch* create_BatchInGeneral(PrimitiveType, VertexBufferStuff, ElementListStuff);
#endif // future plans

View File

@@ -0,0 +1,34 @@
// Gawain buffer IDs
//
// This code is part of the Gawain library, with modifications
// specific to integration with Blender.
//
// Copyright 2016 Mike Erwin
//
// This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0. If a copy of
// the MPL was not distributed with this file, You can obtain one at https://mozilla.org/MPL/2.0/.
#pragma once
// Manage GL buffer IDs in a thread-safe way
// Use these instead of glGenBuffers & its friends
// - alloc must be called from main thread
// - free can be called from any thread
#ifdef __cplusplus
extern "C" {
#endif
#include "common.h"
GLuint buffer_id_alloc(void);
void buffer_id_free(GLuint buffer_id);
GLuint vao_id_alloc(void);
void vao_id_free(GLuint vao_id);
#ifdef __cplusplus
}
#endif

View File

@@ -0,0 +1,36 @@
// Gawain common #defines and #includes
//
// This code is part of the Gawain library, with modifications
// specific to integration with Blender.
//
// Copyright 2016 Mike Erwin
//
// This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0. If a copy of
// the MPL was not distributed with this file, You can obtain one at https://mozilla.org/MPL/2.0/.
#pragma once
#define TRUST_NO_ONE !defined(NDEBUG)
// strict error checking, enabled for debug builds during early development
#include <GL/glew.h>
#include <stdbool.h>
#include <stdint.h>
#if TRUST_NO_ONE
#include <assert.h>
#endif
#define APPLE_LEGACY (defined(__APPLE__) && defined(WITH_GL_PROFILE_COMPAT))
#if APPLE_LEGACY
#undef glGenVertexArrays
#define glGenVertexArrays glGenVertexArraysAPPLE
#undef glDeleteVertexArrays
#define glDeleteVertexArrays glDeleteVertexArraysAPPLE
#undef glBindVertexArray
#define glBindVertexArray glBindVertexArrayAPPLE
#endif

View File

@@ -0,0 +1,64 @@
// Gawain element list (AKA index buffer)
//
// This code is part of the Gawain library, with modifications
// specific to integration with Blender.
//
// Copyright 2016 Mike Erwin
//
// This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0. If a copy of
// the MPL was not distributed with this file, You can obtain one at https://mozilla.org/MPL/2.0/.
#pragma once
#include "primitive.h"
#define TRACK_INDEX_RANGE 1
typedef enum {
INDEX_U8 = GL_UNSIGNED_BYTE, // GL has this, Vulkan does not
INDEX_U16 = GL_UNSIGNED_SHORT,
INDEX_U32 = GL_UNSIGNED_INT
} IndexType;
typedef struct {
unsigned index_ct;
#if TRACK_INDEX_RANGE
IndexType index_type;
unsigned min_index;
unsigned max_index;
unsigned base_index;
#endif
void* data; // NULL indicates data in VRAM (unmapped) or not yet allocated
GLuint vbo_id; // 0 indicates not yet sent to VRAM
} ElementList;
void ElementList_use(ElementList*);
unsigned ElementList_size(const ElementList*);
typedef struct {
unsigned max_allowed_index;
unsigned max_index_ct;
unsigned index_ct;
PrimitiveType prim_type;
unsigned* data;
} ElementListBuilder;
// supported primitives:
// PRIM_POINTS
// PRIM_LINES
// PRIM_TRIANGLES
void ElementListBuilder_init(ElementListBuilder*, PrimitiveType, unsigned prim_ct, unsigned vertex_ct);
//void ElementListBuilder_init_custom(ElementListBuilder*, PrimitiveType, unsigned index_ct, unsigned vertex_ct);
void add_generic_vertex(ElementListBuilder*, unsigned v);
void add_point_vertex(ElementListBuilder*, unsigned v);
void add_line_vertices(ElementListBuilder*, unsigned v1, unsigned v2);
void add_triangle_vertices(ElementListBuilder*, unsigned v1, unsigned v2, unsigned v3);
ElementList* ElementList_build(ElementListBuilder*);
void ElementList_build_in_place(ElementListBuilder*, ElementList*);
void ElementList_discard(ElementList*);

View File

@@ -0,0 +1,18 @@
// Gawain immediate mode drawing utilities
//
// This code is part of the Gawain library, with modifications
// specific to integration with Blender.
//
// Copyright 2016 Mike Erwin
//
// This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0. If a copy of
// the MPL was not distributed with this file, You can obtain one at https://mozilla.org/MPL/2.0/.
#pragma once
// Draw 2D rectangles (replaces glRect functions)
// caller is reponsible for vertex format & shader
void immRectf(unsigned pos, float x1, float y1, float x2, float y2);
void immRecti(unsigned pos, int x1, int y1, int x2, int y2);

View File

@@ -0,0 +1,112 @@
// Gawain immediate mode work-alike
//
// This code is part of the Gawain library, with modifications
// specific to integration with Blender.
//
// Copyright 2016 Mike Erwin
//
// This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0. If a copy of
// the MPL was not distributed with this file, You can obtain one at https://mozilla.org/MPL/2.0/.
#pragma once
#include "vertex_format.h"
#include "primitive.h"
#define IMM_BATCH_COMBO 1
VertexFormat* immVertexFormat(void); // returns a cleared vertex format, ready for add_attrib
void immBindProgram(GLuint program); // every immBegin must have a program bound first
void immUnbindProgram(void); // call after your last immEnd, or before binding another program
void immBegin(PrimitiveType, unsigned vertex_ct); // must supply exactly vertex_ct vertices
void immBeginAtMost(PrimitiveType, unsigned max_vertex_ct); // can supply fewer vertices
void immEnd(void); // finishes and draws
#if IMM_BATCH_COMBO
#include "batch.h"
// immBegin a batch, then use standard immFunctions as usual.
// immEnd will finalize the batch instead of drawing.
// Then you can draw it as many times as you like! Partially replaces the need for display lists.
Batch* immBeginBatch(PrimitiveType, unsigned vertex_ct);
Batch* immBeginBatchAtMost(PrimitiveType, unsigned vertex_ct);
#endif
// provide attribute values that can change per vertex
// first vertex after immBegin must have all its attributes specified
// skipped attributes will continue using the previous value for that attrib_id
void immAttrib1f(unsigned attrib_id, float x);
void immAttrib2f(unsigned attrib_id, float x, float y);
void immAttrib3f(unsigned attrib_id, float x, float y, float z);
void immAttrib4f(unsigned attrib_id, float x, float y, float z, float w);
void immAttrib2i(unsigned attrib_id, int x, int y);
void immAttrib2s(unsigned attrib_id, short x, short y);
void immAttrib3fv(unsigned attrib_id, const float data[3]);
void immAttrib4fv(unsigned attrib_id, const float data[4]);
void immAttrib3ub(unsigned attrib_id, unsigned char r, unsigned char g, unsigned char b);
void immAttrib4ub(unsigned attrib_id, unsigned char r, unsigned char g, unsigned char b, unsigned char a);
void immAttrib3ubv(unsigned attrib_id, const unsigned char data[4]);
void immAttrib4ubv(unsigned attrib_id, const unsigned char data[4]);
// explicitly skip an attribute
// this advanced option kills automatic value copying for this attrib_id
void immSkipAttrib(unsigned attrib_id);
// provide one last attribute value & end the current vertex
// this is most often used for 2D or 3D position (similar to glVertex)
void immVertex2f(unsigned attrib_id, float x, float y);
void immVertex3f(unsigned attrib_id, float x, float y, float z);
void immVertex2i(unsigned attrib_id, int x, int y);
void immVertex2s(unsigned attrib_id, short x, short y);
void immVertex2fv(unsigned attrib_id, const float data[2]);
void immVertex3fv(unsigned attrib_id, const float data[3]);
void immVertex2iv(unsigned attrib_id, const int data[2]);
// provide uniform values that don't change for the entire draw call
void immUniform1i(const char* name, int x);
void immUniform1f(const char* name, float x);
void immUniform2f(const char* name, float x, float y);
void immUniform2fv(const char* name, const float data[2]);
void immUniform3f(const char* name, float x, float y, float z);
void immUniform3fv(const char* name, const float data[3]);
void immUniformArray3fv(const char* name, const float *data, int count);
void immUniform4f(const char* name, float x, float y, float z, float w);
void immUniform4fv(const char* name, const float data[4]);
void immUniformMatrix4fv(const char* name, const float data[4][4]);
// convenience functions for setting "uniform vec4 color"
// the rgb functions have implicit alpha = 1.0
void immUniformColor4f(float r, float g, float b, float a);
void immUniformColor4fv(const float rgba[4]);
void immUniformColor3f(float r, float g, float b);
void immUniformColor3fv(const float rgb[3]);
void immUniformColor3fvAlpha(const float rgb[3], float a);
void immUniformColor3ub(unsigned char r, unsigned char g, unsigned char b);
void immUniformColor4ub(unsigned char r, unsigned char g, unsigned char b, unsigned char a);
void immUniformColor3ubv(const unsigned char rgb[3]);
void immUniformColor4ubv(const unsigned char rgba[4]);
// these are called by the system -- not part of drawing API
void immInit(void);
void immActivate(void);
void immDeactivate(void);
void immDestroy(void);

View File

@@ -0,0 +1,44 @@
// Gawain geometric primitives
//
// This code is part of the Gawain library, with modifications
// specific to integration with Blender.
//
// Copyright 2017 Mike Erwin
//
// This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0. If a copy of
// the MPL was not distributed with this file, You can obtain one at https://mozilla.org/MPL/2.0/.
#pragma once
#include "common.h"
typedef enum {
PRIM_POINTS = GL_POINTS,
PRIM_LINES = GL_LINES,
PRIM_TRIANGLES = GL_TRIANGLES,
#ifdef WITH_GL_PROFILE_COMPAT
PRIM_QUADS = GL_QUADS, // legacy GL has this, modern GL & Vulkan do not
#endif
PRIM_LINE_STRIP = GL_LINE_STRIP,
PRIM_LINE_STRIP_ADJACENCY = GL_LINE_STRIP_ADJACENCY,
PRIM_LINE_LOOP = GL_LINE_LOOP, // GL has this, Vulkan does not
PRIM_TRIANGLE_STRIP = GL_TRIANGLE_STRIP,
PRIM_TRIANGLE_FAN = GL_TRIANGLE_FAN,
PRIM_NONE = 0xF
} PrimitiveType;
// what types of primitives does each shader expect?
typedef enum {
PRIM_CLASS_NONE = 0,
PRIM_CLASS_POINT = (1 << 0),
PRIM_CLASS_LINE = (1 << 1),
PRIM_CLASS_SURFACE = (1 << 2),
PRIM_CLASS_ANY = PRIM_CLASS_POINT | PRIM_CLASS_LINE | PRIM_CLASS_SURFACE
} PrimitiveClass;
PrimitiveClass prim_class_of_type(PrimitiveType);
bool prim_type_belongs_to_class(PrimitiveType, PrimitiveClass);

View File

@@ -0,0 +1,49 @@
// Gawain shader interface (C --> GLSL)
//
// This code is part of the Gawain library, with modifications
// specific to integration with Blender.
//
// Copyright 2017 Mike Erwin
//
// This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0. If a copy of
// the MPL was not distributed with this file, You can obtain one at https://mozilla.org/MPL/2.0/.
#pragma once
#include "common.h"
typedef enum {
UNIFORM_NONE, // uninitialized/unknown
UNIFORM_MODELVIEW_3D, // mat4 ModelViewMatrix
UNIFORM_PROJECTION_3D, // mat4 ProjectionMatrix
UNIFORM_MVP_3D, // mat4 ModelViewProjectionMatrix
UNIFORM_NORMAL_3D, // mat3 NormalMatrix
UNIFORM_INV_NORMAL_3D, // mat3 InverseNormalMatrix
UNIFORM_MODELVIEW_2D, // mat3 ModelViewMatrix
UNIFORM_PROJECTION_2D, // mat3 ProjectionMatrix
UNIFORM_MVP_2D, // mat3 ModelViewProjectionMatrix
UNIFORM_COLOR, // vec4 color
UNIFORM_CUSTOM // custom uniform, not one of the above built-ins
} BuiltinUniform;
typedef struct {
const char* name;
GLenum gl_type;
BuiltinUniform builtin_type; // only for uniform inputs
GLint size;
GLint location;
} ShaderInput;
typedef struct {
uint16_t uniform_ct;
uint16_t attrib_ct;
ShaderInput inputs[0]; // dynamic size, uniforms followed by attribs
} ShaderInterface;
ShaderInterface* ShaderInterface_create(GLint program_id);
void ShaderInterface_discard(ShaderInterface*);

View File

@@ -0,0 +1,64 @@
// Gawain geometry batch
//
// This code is part of the Gawain library, with modifications
// specific to integration with Blender.
//
// Copyright 2016 Mike Erwin
//
// This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0. If a copy of
// the MPL was not distributed with this file, You can obtain one at https://mozilla.org/MPL/2.0/.
#pragma once
#include "vertex_format.h"
// How to create a VertexBuffer:
// 1) verts = create_VertexBuffer() or init_VertexBuffer(verts)
// 2) add_attrib(verts->format, ...)
// 3) allocate_vertex_data(verts, vertex_ct) <-- finalizes/packs vertex format
// 4) fillAttrib(verts, pos, application_pos_buffer)
// 5) prime_VertexBuffer(verts);
// Is VertexBuffer always used as part of a Batch?
typedef struct {
VertexFormat format;
unsigned vertex_ct;
GLubyte* data; // NULL indicates data in VRAM (unmapped) or not yet allocated
GLuint vbo_id; // 0 indicates not yet sent to VRAM
} VertexBuffer;
VertexBuffer* VertexBuffer_create(void);
VertexBuffer* VertexBuffer_create_with_format(const VertexFormat*);
void VertexBuffer_discard(VertexBuffer*);
void VertexBuffer_init(VertexBuffer*);
void VertexBuffer_init_with_format(VertexBuffer*, const VertexFormat*);
unsigned VertexBuffer_size(const VertexBuffer*);
void VertexBuffer_allocate_data(VertexBuffer*, unsigned v_ct);
void VertexBuffer_resize_data(VertexBuffer*, unsigned v_ct);
// The most important setAttrib variant is the untyped one. Get it right first.
// It takes a void* so the app developer is responsible for matching their app data types
// to the vertex attribute's type and component count. They're in control of both, so this
// should not be a problem.
void setAttrib(VertexBuffer*, unsigned a_idx, unsigned v_idx, const void* data);
void fillAttrib(VertexBuffer*, unsigned a_idx, const void* data); // tightly packed, non interleaved input data
void fillAttribStride(VertexBuffer*, unsigned a_idx, unsigned stride, const void* data);
// TODO: decide whether to keep the functions below
// doesn't immediate mode satisfy these needs?
// void setAttrib1f(unsigned a_idx, unsigned v_idx, float x);
// void setAttrib2f(unsigned a_idx, unsigned v_idx, float x, float y);
// void setAttrib3f(unsigned a_idx, unsigned v_idx, float x, float y, float z);
// void setAttrib4f(unsigned a_idx, unsigned v_idx, float x, float y, float z, float w);
//
// void setAttrib3ub(unsigned a_idx, unsigned v_idx, unsigned char r, unsigned char g, unsigned char b);
// void setAttrib4ub(unsigned a_idx, unsigned v_idx, unsigned char r, unsigned char g, unsigned char b, unsigned char a);
void VertexBuffer_use(VertexBuffer*);

View File

@@ -0,0 +1,87 @@
// Gawain vertex format
//
// This code is part of the Gawain library, with modifications
// specific to integration with Blender.
//
// Copyright 2016 Mike Erwin
//
// This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0. If a copy of
// the MPL was not distributed with this file, You can obtain one at https://mozilla.org/MPL/2.0/.
#pragma once
#include "common.h"
#define MAX_VERTEX_ATTRIBS 16
#define AVG_VERTEX_ATTRIB_NAME_LEN 5
#define VERTEX_ATTRIB_NAMES_BUFFER_LEN ((AVG_VERTEX_ATTRIB_NAME_LEN + 1) * MAX_VERTEX_ATTRIBS)
#define USE_10_10_10 defined(_WIN32)
// (GLEW_VERSION_3_3 || GLEW_ARB_vertex_type_2_10_10_10_rev)
// ^-- this is only guaranteed on Windows right now, will be true on all platforms soon
typedef enum {
COMP_I8 = GL_BYTE,
COMP_U8 = GL_UNSIGNED_BYTE,
COMP_I16 = GL_SHORT,
COMP_U16 = GL_UNSIGNED_SHORT,
COMP_I32 = GL_INT,
COMP_U32 = GL_UNSIGNED_INT,
COMP_F32 = GL_FLOAT, // TODO: drop the GL_ equivalence here, use a private lookup table
#if USE_10_10_10
COMP_I10 = GL_INT_2_10_10_10_REV
#endif
} VertexCompType;
typedef enum {
KEEP_FLOAT,
KEEP_INT,
NORMALIZE_INT_TO_FLOAT, // 127 (ubyte) -> 0.5 (and so on for other int types)
CONVERT_INT_TO_FLOAT // 127 (any int type) -> 127.0
} VertexFetchMode;
typedef struct {
VertexCompType comp_type;
unsigned comp_ct; // 1 to 4
unsigned sz; // size in bytes, 1 to 16
unsigned offset; // from beginning of vertex, in bytes
VertexFetchMode fetch_mode;
const char* name;
} Attrib;
typedef struct {
unsigned attrib_ct; // 0 to 16 (MAX_VERTEX_ATTRIBS)
unsigned stride; // stride in bytes, 1 to 256
bool packed;
Attrib attribs[MAX_VERTEX_ATTRIBS]; // TODO: variable-size attribs array
char names[VERTEX_ATTRIB_NAMES_BUFFER_LEN];
unsigned name_offset;
} VertexFormat;
void VertexFormat_clear(VertexFormat*);
void VertexFormat_copy(VertexFormat* dest, const VertexFormat* src);
unsigned add_attrib(VertexFormat*, const char* name, VertexCompType, unsigned comp_ct, VertexFetchMode);
// format conversion
#if USE_10_10_10
typedef struct {
int x : 10;
int y : 10;
int z : 10;
int w : 2; // 0 by default, can manually set to { -2, -1, 0, 1 }
} PackedNormal;
PackedNormal convert_i10_v3(const float data[3]);
#endif // USE_10_10_10
// for internal use
void VertexFormat_pack(VertexFormat*);
unsigned padding(unsigned offset, unsigned alignment);
unsigned vertex_buffer_size(const VertexFormat*, unsigned vertex_ct);

View File

@@ -0,0 +1,69 @@
// Gawain vertex attribute binding
//
// This code is part of the Gawain library, with modifications
// specific to integration with Blender.
//
// Copyright 2016 Mike Erwin
//
// This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0. If a copy of
// the MPL was not distributed with this file, You can obtain one at https://mozilla.org/MPL/2.0/.
#include "attrib_binding.h"
#if MAX_VERTEX_ATTRIBS != 16
#error "attrib binding code assumes MAX_VERTEX_ATTRIBS = 16"
#endif
void clear_AttribBinding(AttribBinding* binding)
{
binding->loc_bits = 0;
binding->enabled_bits = 0;
}
unsigned read_attrib_location(const AttribBinding* binding, unsigned a_idx)
{
#if TRUST_NO_ONE
assert(a_idx < MAX_VERTEX_ATTRIBS);
assert(binding->enabled_bits & (1 << a_idx));
#endif
return (binding->loc_bits >> (4 * a_idx)) & 0xF;
}
static void write_attrib_location(AttribBinding* binding, unsigned a_idx, unsigned location)
{
#if TRUST_NO_ONE
assert(a_idx < MAX_VERTEX_ATTRIBS);
assert(location < MAX_VERTEX_ATTRIBS);
#endif
const unsigned shift = 4 * a_idx;
const uint64_t mask = ((uint64_t)0xF) << shift;
// overwrite this attrib's previous location
binding->loc_bits = (binding->loc_bits & ~mask) | (location << shift);
// mark this attrib as enabled
binding->enabled_bits |= 1 << a_idx;
}
void get_attrib_locations(const VertexFormat* format, AttribBinding* binding, GLuint program)
{
#if TRUST_NO_ONE
assert(glIsProgram(program));
#endif
clear_AttribBinding(binding);
for (unsigned a_idx = 0; a_idx < format->attrib_ct; ++a_idx)
{
const Attrib* a = format->attribs + a_idx;
GLint loc = glGetAttribLocation(program, a->name);
#if TRUST_NO_ONE
assert(loc != -1);
// TODO: make this a recoverable runtime error? indicates mismatch between vertex format and program
#endif
write_attrib_location(binding, a_idx, loc);
}
}

405
intern/gawain/src/batch.c Normal file
View File

@@ -0,0 +1,405 @@
// Gawain geometry batch
//
// This code is part of the Gawain library, with modifications
// specific to integration with Blender.
//
// Copyright 2016 Mike Erwin
//
// This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0. If a copy of
// the MPL was not distributed with this file, You can obtain one at https://mozilla.org/MPL/2.0/.
#include "batch.h"
#include "buffer_id.h"
#include <stdlib.h>
// necessary functions from matrix API
extern void gpuBindMatrices(GLuint program);
extern bool gpuMatricesDirty(void); // how best to use this here?
Batch* Batch_create(PrimitiveType prim_type, VertexBuffer* verts, ElementList* elem)
{
Batch* batch = calloc(1, sizeof(Batch));
Batch_init(batch, prim_type, verts, elem);
return batch;
}
void Batch_init(Batch* batch, PrimitiveType prim_type, VertexBuffer* verts, ElementList* elem)
{
#if TRUST_NO_ONE
assert(verts != NULL);
// assert(prim_type == PRIM_POINTS || prim_type == PRIM_LINES || prim_type == PRIM_TRIANGLES);
// we will allow other primitive types in a future update
#endif
batch->verts[0] = verts;
for (int v = 1; v < BATCH_MAX_VBO_CT; ++v)
batch->verts[v] = NULL;
batch->elem = elem;
batch->prim_type = prim_type;
batch->phase = READY_TO_DRAW;
}
void Batch_discard(Batch* batch)
{
if (batch->vao_id)
vao_id_free(batch->vao_id);
free(batch);
}
void Batch_discard_all(Batch* batch)
{
for (int v = 0; v < BATCH_MAX_VBO_CT; ++v)
{
if (batch->verts[v] == NULL)
break;
VertexBuffer_discard(batch->verts[v]);
}
if (batch->elem)
ElementList_discard(batch->elem);
Batch_discard(batch);
}
int Batch_add_VertexBuffer(Batch* batch, VertexBuffer* verts)
{
for (unsigned v = 0; v < BATCH_MAX_VBO_CT; ++v)
{
if (batch->verts[v] == NULL)
{
#if TRUST_NO_ONE
// for now all VertexBuffers must have same vertex_ct
assert(verts->vertex_ct == batch->verts[0]->vertex_ct);
// in the near future we will enable instanced attribs which have their own vertex_ct
#endif
batch->verts[v] = verts;
// TODO: mark dirty so we can keep attrib bindings up-to-date
return v;
}
}
// we only make it this far if there is no room for another VertexBuffer
#if TRUST_NO_ONE
assert(false);
#endif
return -1;
}
void Batch_set_program(Batch* batch, GLuint program)
{
#if TRUST_NO_ONE
assert(glIsProgram(program));
#endif
batch->program = program;
batch->program_dirty = true;
Batch_use_program(batch); // hack! to make Batch_Uniform* simpler
}
static void Batch_update_program_bindings(Batch* batch)
{
// disable all as a precaution
// why are we not using prev_attrib_enabled_bits?? see immediate.c
for (unsigned a_idx = 0; a_idx < MAX_VERTEX_ATTRIBS; ++a_idx)
glDisableVertexAttribArray(a_idx);
for (int v = 0; v < BATCH_MAX_VBO_CT; ++v)
{
VertexBuffer* verts = batch->verts[v];
if (verts == NULL)
break;
const VertexFormat* format = &verts->format;
const unsigned attrib_ct = format->attrib_ct;
const unsigned stride = format->stride;
VertexBuffer_use(verts);
for (unsigned a_idx = 0; a_idx < attrib_ct; ++a_idx)
{
const Attrib* a = format->attribs + a_idx;
const GLvoid* pointer = (const GLubyte*)0 + a->offset;
const GLint loc = glGetAttribLocation(batch->program, a->name);
if (loc == -1) continue;
glEnableVertexAttribArray(loc);
switch (a->fetch_mode)
{
case KEEP_FLOAT:
case CONVERT_INT_TO_FLOAT:
glVertexAttribPointer(loc, a->comp_ct, a->comp_type, GL_FALSE, stride, pointer);
break;
case NORMALIZE_INT_TO_FLOAT:
glVertexAttribPointer(loc, a->comp_ct, a->comp_type, GL_TRUE, stride, pointer);
break;
case KEEP_INT:
glVertexAttribIPointer(loc, a->comp_ct, a->comp_type, stride, pointer);
}
}
}
batch->program_dirty = false;
}
void Batch_use_program(Batch* batch)
{
// NOTE: use_program & done_using_program are fragile, depend on staying in sync with
// the GL context's active program. use_program doesn't mark other programs as "not used".
// TODO: make not fragile (somehow)
if (!batch->program_in_use)
{
glUseProgram(batch->program);
batch->program_in_use = true;
}
}
void Batch_done_using_program(Batch* batch)
{
if (batch->program_in_use)
{
glUseProgram(0);
batch->program_in_use = false;
}
}
void Batch_Uniform1i(Batch* batch, const char* name, int value)
{
int loc = glGetUniformLocation(batch->program, name);
#if TRUST_NO_ONE
assert(loc != -1);
#endif
glUniform1i(loc, value);
}
void Batch_Uniform1b(Batch* batch, const char* name, bool value)
{
int loc = glGetUniformLocation(batch->program, name);
#if TRUST_NO_ONE
assert(loc != -1);
#endif
glUniform1i(loc, value ? GL_TRUE : GL_FALSE);
}
void Batch_Uniform2f(Batch* batch, const char* name, float x, float y)
{
int loc = glGetUniformLocation(batch->program, name);
#if TRUST_NO_ONE
assert(loc != -1);
#endif
glUniform2f(loc, x, y);
}
void Batch_Uniform3f(Batch* batch, const char* name, float x, float y, float z)
{
int loc = glGetUniformLocation(batch->program, name);
#if TRUST_NO_ONE
assert(loc != -1);
#endif
glUniform3f(loc, x, y, z);
}
void Batch_Uniform4f(Batch* batch, const char* name, float x, float y, float z, float w)
{
int loc = glGetUniformLocation(batch->program, name);
#if TRUST_NO_ONE
assert(loc != -1);
#endif
glUniform4f(loc, x, y, z, w);
}
void Batch_Uniform1f(Batch* batch, const char* name, float x)
{
int loc = glGetUniformLocation(batch->program, name);
#if TRUST_NO_ONE
assert(loc != -1);
#endif
glUniform1f(loc, x);
}
void Batch_Uniform3fv(Batch* batch, const char* name, const float data[3])
{
int loc = glGetUniformLocation(batch->program, name);
#if TRUST_NO_ONE
assert(loc != -1);
#endif
glUniform3fv(loc, 1, data);
}
void Batch_Uniform4fv(Batch* batch, const char* name, const float data[4])
{
int loc = glGetUniformLocation(batch->program, name);
#if TRUST_NO_ONE
assert(loc != -1);
#endif
glUniform4fv(loc, 1, data);
}
static void Batch_prime(Batch* batch)
{
batch->vao_id = vao_id_alloc();
glBindVertexArray(batch->vao_id);
for (int v = 0; v < BATCH_MAX_VBO_CT; ++v)
{
if (batch->verts[v] == NULL)
break;
VertexBuffer_use(batch->verts[v]);
}
if (batch->elem)
ElementList_use(batch->elem);
// vertex attribs and element list remain bound to this VAO
}
void Batch_draw(Batch* batch)
{
#if TRUST_NO_ONE
assert(batch->phase == READY_TO_DRAW);
assert(glIsProgram(batch->program));
#endif
if (batch->vao_id)
glBindVertexArray(batch->vao_id);
else
Batch_prime(batch);
if (batch->program_dirty)
Batch_update_program_bindings(batch);
Batch_use_program(batch);
gpuBindMatrices(batch->program);
if (batch->elem)
{
const ElementList* el = batch->elem;
#if TRACK_INDEX_RANGE
if (el->base_index)
glDrawRangeElementsBaseVertex(batch->prim_type, el->min_index, el->max_index, el->index_ct, el->index_type, 0, el->base_index);
else
glDrawRangeElements(batch->prim_type, el->min_index, el->max_index, el->index_ct, el->index_type, 0);
#else
glDrawElements(batch->prim_type, el->index_ct, GL_UNSIGNED_INT, 0);
#endif
}
else
glDrawArrays(batch->prim_type, 0, batch->verts[0]->vertex_ct);
Batch_done_using_program(batch);
glBindVertexArray(0);
}
// clement : temp stuff
void Batch_draw_stupid(Batch* batch)
{
if (batch->vao_id)
glBindVertexArray(batch->vao_id);
else
Batch_prime(batch);
if (batch->program_dirty)
Batch_update_program_bindings(batch);
// Batch_use_program(batch);
//gpuBindMatrices(batch->program);
if (batch->elem)
{
const ElementList* el = batch->elem;
#if TRACK_INDEX_RANGE
if (el->base_index)
glDrawRangeElementsBaseVertex(batch->prim_type, el->min_index, el->max_index, el->index_ct, el->index_type, 0, el->base_index);
else
glDrawRangeElements(batch->prim_type, el->min_index, el->max_index, el->index_ct, el->index_type, 0);
#else
glDrawElements(batch->prim_type, el->index_ct, GL_UNSIGNED_INT, 0);
#endif
}
else
glDrawArrays(batch->prim_type, 0, batch->verts[0]->vertex_ct);
// Batch_done_using_program(batch);
glBindVertexArray(0);
}
// clement : temp stuff
void Batch_draw_stupid_instanced(Batch* batch, unsigned int instance_vbo, int instance_count,
int attrib_nbr, int attrib_stride, int attrib_size[16], int attrib_loc[16])
{
if (batch->vao_id)
glBindVertexArray(batch->vao_id);
else
Batch_prime(batch);
if (batch->program_dirty)
Batch_update_program_bindings(batch);
glBindBuffer(GL_ARRAY_BUFFER, instance_vbo);
int ptr_ofs = 0;
for (int i = 0; i < attrib_nbr; ++i) {
int size = attrib_size[i];
int loc = attrib_loc[i];
int atr_ofs = 0;
while (size > 0) {
glEnableVertexAttribArray(loc + atr_ofs);
glVertexAttribPointer(loc + atr_ofs, (size > 4) ? 4 : size, GL_FLOAT, GL_FALSE,
sizeof(float) * attrib_stride, (GLvoid*)(sizeof(float) * ptr_ofs));
glVertexAttribDivisor(loc + atr_ofs, 1);
atr_ofs++;
ptr_ofs += (size > 4) ? 4 : size;
size -= 4;
}
}
glBindBuffer(GL_ARRAY_BUFFER, 0);
// Batch_use_program(batch);
//gpuBindMatrices(batch->program);
if (batch->elem)
{
const ElementList* el = batch->elem;
glDrawElementsInstanced(batch->prim_type, el->index_ct, GL_UNSIGNED_INT, 0, instance_count);
}
else
glDrawArraysInstanced(batch->prim_type, 0, batch->verts[0]->vertex_ct, instance_count);
// Batch_done_using_program(batch);
glBindVertexArray(0);
}

View File

@@ -0,0 +1,115 @@
// Gawain buffer IDs
//
// This code is part of the Gawain library, with modifications
// specific to integration with Blender.
//
// Copyright 2016 Mike Erwin
//
// This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0. If a copy of
// the MPL was not distributed with this file, You can obtain one at https://mozilla.org/MPL/2.0/.#include "buffer_id.h"
#include "buffer_id.h"
#include <mutex>
#include <vector>
#define ORPHAN_DEBUG 0
#if ORPHAN_DEBUG
#include <cstdio>
#endif
static std::vector<GLuint> orphaned_buffer_ids;
static std::vector<GLuint> orphaned_vao_ids;
static std::mutex orphan_mutex;
extern "C" {
extern int BLI_thread_is_main(void); // Blender-specific function
}
static bool thread_is_main()
{
// "main" here means the GL context's thread
return BLI_thread_is_main();
}
GLuint buffer_id_alloc()
{
#if TRUST_NO_ONE
assert(thread_is_main());
#endif
// delete orphaned IDs
orphan_mutex.lock();
if (!orphaned_buffer_ids.empty())
{
const auto orphaned_buffer_ct = (unsigned)orphaned_buffer_ids.size();
#if ORPHAN_DEBUG
printf("deleting %u orphaned VBO%s\n", orphaned_buffer_ct, orphaned_buffer_ct == 1 ? "" : "s");
#endif
glDeleteBuffers(orphaned_buffer_ct, orphaned_buffer_ids.data());
orphaned_buffer_ids.clear();
}
orphan_mutex.unlock();
GLuint new_buffer_id = 0;
glGenBuffers(1, &new_buffer_id);
return new_buffer_id;
}
void buffer_id_free(GLuint buffer_id)
{
if (thread_is_main())
glDeleteBuffers(1, &buffer_id);
else
{
// add this ID to the orphaned list
orphan_mutex.lock();
#if ORPHAN_DEBUG
printf("orphaning VBO %u\n", buffer_id);
#endif
orphaned_buffer_ids.emplace_back(buffer_id);
orphan_mutex.unlock();
}
}
GLuint vao_id_alloc()
{
#if TRUST_NO_ONE
assert(thread_is_main());
#endif
// delete orphaned IDs
orphan_mutex.lock();
if (!orphaned_vao_ids.empty())
{
const auto orphaned_vao_ct = (unsigned)orphaned_vao_ids.size();
#if ORPHAN_DEBUG
printf("deleting %u orphaned VAO%s\n", orphaned_vao_ct, orphaned_vao_ct == 1 ? "" : "s");
#endif
glDeleteVertexArrays(orphaned_vao_ct, orphaned_vao_ids.data());
orphaned_vao_ids.clear();
}
orphan_mutex.unlock();
GLuint new_vao_id = 0;
glGenVertexArrays(1, &new_vao_id);
return new_vao_id;
}
void vao_id_free(GLuint vao_id)
{
if (thread_is_main())
glDeleteVertexArrays(1, &vao_id);
else
{
// add this ID to the orphaned list
orphan_mutex.lock();
#if ORPHAN_DEBUG
printf("orphaning VAO %u\n", vao_id);
#endif
orphaned_vao_ids.emplace_back(vao_id);
orphan_mutex.unlock();
}
}

283
intern/gawain/src/element.c Normal file
View File

@@ -0,0 +1,283 @@
// Gawain element list (AKA index buffer)
//
// This code is part of the Gawain library, with modifications
// specific to integration with Blender.
//
// Copyright 2016 Mike Erwin
//
// This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0. If a copy of
// the MPL was not distributed with this file, You can obtain one at https://mozilla.org/MPL/2.0/.
#include "element.h"
#include "buffer_id.h"
#include <stdlib.h>
#define KEEP_SINGLE_COPY 1
unsigned ElementList_size(const ElementList* elem)
{
#if TRACK_INDEX_RANGE
switch (elem->index_type)
{
case INDEX_U8: return elem->index_ct * sizeof(GLubyte);
case INDEX_U16: return elem->index_ct * sizeof(GLushort);
case INDEX_U32: return elem->index_ct * sizeof(GLuint);
default:
#if TRUST_NO_ONE
assert(false);
#endif
return 0;
}
#else
return elem->index_ct * sizeof(GLuint);
#endif
}
static void ElementList_prime(ElementList* elem)
{
elem->vbo_id = buffer_id_alloc();
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, elem->vbo_id);
// fill with delicious data & send to GPU the first time only
glBufferData(GL_ELEMENT_ARRAY_BUFFER, ElementList_size(elem), elem->data, GL_STATIC_DRAW);
#if KEEP_SINGLE_COPY
// now that GL has a copy, discard original
free(elem->data);
elem->data = NULL;
#endif
}
void ElementList_use(ElementList* elem)
{
if (elem->vbo_id)
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, elem->vbo_id);
else
ElementList_prime(elem);
}
void ElementListBuilder_init(ElementListBuilder* builder, PrimitiveType prim_type, unsigned prim_ct, unsigned vertex_ct)
{
unsigned verts_per_prim = 0;
switch (prim_type)
{
case PRIM_POINTS:
verts_per_prim = 1;
break;
case PRIM_LINES:
verts_per_prim = 2;
break;
case PRIM_TRIANGLES:
verts_per_prim = 3;
break;
default:
#if TRUST_NO_ONE
assert(false);
#endif
return;
}
builder->max_allowed_index = vertex_ct - 1;
builder->max_index_ct = prim_ct * verts_per_prim;
builder->index_ct = 0; // start empty
builder->prim_type = prim_type;
builder->data = calloc(builder->max_index_ct, sizeof(unsigned));
}
void add_generic_vertex(ElementListBuilder* builder, unsigned v)
{
#if TRUST_NO_ONE
assert(builder->data != NULL);
assert(builder->index_ct < builder->max_index_ct);
assert(v <= builder->max_allowed_index);
#endif
builder->data[builder->index_ct++] = v;
}
void add_point_vertex(ElementListBuilder* builder, unsigned v)
{
#if TRUST_NO_ONE
assert(builder->prim_type == PRIM_POINTS);
#endif
add_generic_vertex(builder, v);
}
void add_line_vertices(ElementListBuilder* builder, unsigned v1, unsigned v2)
{
#if TRUST_NO_ONE
assert(builder->prim_type == PRIM_LINES);
assert(v1 != v2);
#endif
add_generic_vertex(builder, v1);
add_generic_vertex(builder, v2);
}
void add_triangle_vertices(ElementListBuilder* builder, unsigned v1, unsigned v2, unsigned v3)
{
#if TRUST_NO_ONE
assert(builder->prim_type == PRIM_TRIANGLES);
assert(v1 != v2 && v2 != v3 && v3 != v1);
#endif
add_generic_vertex(builder, v1);
add_generic_vertex(builder, v2);
add_generic_vertex(builder, v3);
}
#if TRACK_INDEX_RANGE
// Everything remains 32 bit while building to keep things simple.
// Find min/max after, then convert to smallest index type possible.
static unsigned index_range(const unsigned values[], unsigned value_ct, unsigned* min_out, unsigned* max_out)
{
unsigned min_value = values[0];
unsigned max_value = values[0];
for (unsigned i = 1; i < value_ct; ++i)
{
const unsigned value = values[i];
if (value < min_value)
min_value = value;
else if (value > max_value)
max_value = value;
}
*min_out = min_value;
*max_out = max_value;
return max_value - min_value;
}
static void squeeze_indices_byte(const unsigned values[], ElementList* elem)
{
const unsigned index_ct = elem->index_ct;
GLubyte* data = malloc(index_ct * sizeof(GLubyte));
if (elem->max_index > 0xFF)
{
const unsigned base = elem->min_index;
elem->base_index = base;
elem->min_index = 0;
elem->max_index -= base;
for (unsigned i = 0; i < index_ct; ++i)
data[i] = (GLubyte)(values[i] - base);
}
else
{
elem->base_index = 0;
for (unsigned i = 0; i < index_ct; ++i)
data[i] = (GLubyte)(values[i]);
}
elem->data = data;
}
static void squeeze_indices_short(const unsigned values[], ElementList* elem)
{
const unsigned index_ct = elem->index_ct;
GLushort* data = malloc(index_ct * sizeof(GLushort));
if (elem->max_index > 0xFFFF)
{
const unsigned base = elem->min_index;
elem->base_index = base;
elem->min_index = 0;
elem->max_index -= base;
for (unsigned i = 0; i < index_ct; ++i)
data[i] = (GLushort)(values[i] - base);
}
else
{
elem->base_index = 0;
for (unsigned i = 0; i < index_ct; ++i)
data[i] = (GLushort)(values[i]);
}
elem->data = data;
}
#endif // TRACK_INDEX_RANGE
ElementList* ElementList_build(ElementListBuilder* builder)
{
ElementList* elem = calloc(1, sizeof(ElementList));
ElementList_build_in_place(builder, elem);
return elem;
}
void ElementList_build_in_place(ElementListBuilder* builder, ElementList* elem)
{
#if TRUST_NO_ONE
assert(builder->data != NULL);
#endif
elem->index_ct = builder->index_ct;
#if TRACK_INDEX_RANGE
const unsigned range = index_range(builder->data, builder->index_ct, &elem->min_index, &elem->max_index);
if (range <= 0xFF)
{
elem->index_type = INDEX_U8;
squeeze_indices_byte(builder->data, elem);
}
else if (range <= 0xFFFF)
{
elem->index_type = INDEX_U16;
squeeze_indices_short(builder->data, elem);
}
else
{
elem->index_type = INDEX_U32;
elem->base_index = 0;
if (builder->index_ct < builder->max_index_ct)
{
builder->data = realloc(builder->data, builder->index_ct * sizeof(unsigned));
// TODO: realloc only if index_ct is much smaller than max_index_ct
}
elem->data = builder->data;
}
#else
if (builder->index_ct < builder->max_index_ct)
{
builder->data = realloc(builder->data, builder->index_ct * sizeof(unsigned));
// TODO: realloc only if index_ct is much smaller than max_index_ct
}
elem->data = builder->data;
#endif
// elem->data will never be *larger* than builder->data... how about converting
// in place to avoid extra allocation?
elem->vbo_id = 0;
// TODO: create GL buffer object directly, based on an input flag
// discard builder (one-time use)
if (builder->data != elem->data)
free(builder->data);
builder->data = NULL;
// other fields are safe to leave
}
void ElementList_discard(ElementList* elem)
{
if (elem->vbo_id)
buffer_id_free(elem->vbo_id);
#if KEEP_SINGLE_COPY
else
#endif
if (elem->data)
free(elem->data);
free(elem);
}

View File

@@ -0,0 +1,46 @@
// Gawain immediate mode drawing utilities
//
// This code is part of the Gawain library, with modifications
// specific to integration with Blender.
//
// Copyright 2016 Mike Erwin
//
// This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0. If a copy of
// the MPL was not distributed with this file, You can obtain one at https://mozilla.org/MPL/2.0/.
#include "imm_util.h"
#include "immediate.h"
void immRectf(unsigned pos, float x1, float y1, float x2, float y2)
{
immBegin(PRIM_TRIANGLE_FAN, 4);
immVertex2f(pos, x1, y1);
immVertex2f(pos, x2, y1);
immVertex2f(pos, x2, y2);
immVertex2f(pos, x1, y2);
immEnd();
}
void immRecti(unsigned pos, int x1, int y1, int x2, int y2)
{
immBegin(PRIM_TRIANGLE_FAN, 4);
immVertex2i(pos, x1, y1);
immVertex2i(pos, x2, y1);
immVertex2i(pos, x2, y2);
immVertex2i(pos, x1, y2);
immEnd();
}
#if 0 // more complete version in case we want that
void immRecti_complete(int x1, int y1, int x2, int y2, const float color[4])
{
VertexFormat *format = immVertexFormat();
unsigned pos = add_attrib(format, "pos", COMP_I32, 2, CONVERT_INT_TO_FLOAT);
immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR);
immUniformColor4fv(color);
immRecti(pos, x1, y1, x2, y2);
immUnbindProgram();
}
#endif

View File

@@ -0,0 +1,884 @@
// Gawain immediate mode work-alike
//
// This code is part of the Gawain library, with modifications
// specific to integration with Blender.
//
// Copyright 2016 Mike Erwin
//
// This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0. If a copy of
// the MPL was not distributed with this file, You can obtain one at https://mozilla.org/MPL/2.0/.
#include "immediate.h"
#include "attrib_binding.h"
#include "buffer_id.h"
#include <string.h>
// necessary functions from matrix API
extern void gpuBindMatrices(GLuint program);
extern bool gpuMatricesDirty(void);
typedef struct {
// TODO: organize this struct by frequency of change (run-time)
#if IMM_BATCH_COMBO
Batch* batch;
#endif
// current draw call
GLubyte* buffer_data;
unsigned buffer_offset;
unsigned buffer_bytes_mapped;
unsigned vertex_ct;
bool strict_vertex_ct;
PrimitiveType prim_type;
VertexFormat vertex_format;
// current vertex
unsigned vertex_idx;
GLubyte* vertex_data;
uint16_t unassigned_attrib_bits; // which attributes of current vertex have not been given values?
GLuint vbo_id;
GLuint vao_id;
GLuint bound_program;
AttribBinding attrib_binding;
uint16_t prev_enabled_attrib_bits; // <-- only affects this VAO, so we're ok
} Immediate;
// size of internal buffer -- make this adjustable?
#define IMM_BUFFER_SIZE (4 * 1024 * 1024)
static bool initialized = false;
static Immediate imm;
void immInit(void)
{
#if TRUST_NO_ONE
assert(!initialized);
#endif
memset(&imm, 0, sizeof(Immediate));
imm.vbo_id = buffer_id_alloc();
glBindBuffer(GL_ARRAY_BUFFER, imm.vbo_id);
glBufferData(GL_ARRAY_BUFFER, IMM_BUFFER_SIZE, NULL, GL_DYNAMIC_DRAW);
#if APPLE_LEGACY
glBufferParameteriAPPLE(GL_ARRAY_BUFFER, GL_BUFFER_SERIALIZED_MODIFY_APPLE, GL_FALSE);
glBufferParameteriAPPLE(GL_ARRAY_BUFFER, GL_BUFFER_FLUSHING_UNMAP_APPLE, GL_FALSE);
#endif
imm.prim_type = PRIM_NONE;
imm.strict_vertex_ct = true;
glBindBuffer(GL_ARRAY_BUFFER, 0);
initialized = true;
immActivate();
}
void immActivate(void)
{
#if TRUST_NO_ONE
assert(initialized);
assert(imm.prim_type == PRIM_NONE); // make sure we're not between a Begin/End pair
assert(imm.vao_id == 0);
#endif
imm.vao_id = vao_id_alloc();
}
void immDeactivate(void)
{
#if TRUST_NO_ONE
assert(initialized);
assert(imm.prim_type == PRIM_NONE); // make sure we're not between a Begin/End pair
assert(imm.vao_id != 0);
#endif
vao_id_free(imm.vao_id);
imm.vao_id = 0;
imm.prev_enabled_attrib_bits = 0;
}
void immDestroy(void)
{
immDeactivate();
buffer_id_free(imm.vbo_id);
initialized = false;
}
VertexFormat* immVertexFormat(void)
{
VertexFormat_clear(&imm.vertex_format);
return &imm.vertex_format;
}
void immBindProgram(GLuint program)
{
#if TRUST_NO_ONE
assert(imm.bound_program == 0);
assert(glIsProgram(program));
#endif
if (!imm.vertex_format.packed)
VertexFormat_pack(&imm.vertex_format);
glUseProgram(program);
get_attrib_locations(&imm.vertex_format, &imm.attrib_binding, program);
imm.bound_program = program;
gpuBindMatrices(program);
}
void immUnbindProgram(void)
{
#if TRUST_NO_ONE
assert(imm.bound_program != 0);
#endif
glUseProgram(0);
imm.bound_program = 0;
}
#if TRUST_NO_ONE
static bool vertex_count_makes_sense_for_primitive(unsigned vertex_ct, PrimitiveType prim_type)
{
// does vertex_ct make sense for this primitive type?
if (vertex_ct == 0)
return false;
switch (prim_type)
{
case PRIM_POINTS:
return true;
case PRIM_LINES:
return vertex_ct % 2 == 0;
case PRIM_LINE_STRIP:
case PRIM_LINE_LOOP:
return vertex_ct >= 2;
case PRIM_LINE_STRIP_ADJACENCY:
return vertex_ct >= 4;
case PRIM_TRIANGLES:
return vertex_ct % 3 == 0;
case PRIM_TRIANGLE_STRIP:
case PRIM_TRIANGLE_FAN:
return vertex_ct >= 3;
#ifdef WITH_GL_PROFILE_COMPAT
case PRIM_QUADS:
return vertex_ct % 4 == 0;
#endif
default:
return false;
}
}
#endif
void immBegin(PrimitiveType prim_type, unsigned vertex_ct)
{
#if TRUST_NO_ONE
assert(initialized);
assert(imm.prim_type == PRIM_NONE); // make sure we haven't already begun
assert(vertex_count_makes_sense_for_primitive(vertex_ct, prim_type));
#endif
imm.prim_type = prim_type;
imm.vertex_ct = vertex_ct;
imm.vertex_idx = 0;
imm.unassigned_attrib_bits = imm.attrib_binding.enabled_bits;
// how many bytes do we need for this draw call?
const unsigned bytes_needed = vertex_buffer_size(&imm.vertex_format, vertex_ct);
#if TRUST_NO_ONE
assert(bytes_needed <= IMM_BUFFER_SIZE);
#endif
glBindBuffer(GL_ARRAY_BUFFER, imm.vbo_id);
// does the current buffer have enough room?
const unsigned available_bytes = IMM_BUFFER_SIZE - imm.buffer_offset;
// ensure vertex data is aligned
const unsigned pre_padding = padding(imm.buffer_offset, imm.vertex_format.stride); // might waste a little space, but it's safe
if ((bytes_needed + pre_padding) <= available_bytes)
imm.buffer_offset += pre_padding;
else
{
// orphan this buffer & start with a fresh one
#if APPLE_LEGACY
glBufferData(GL_ARRAY_BUFFER, IMM_BUFFER_SIZE, NULL, GL_DYNAMIC_DRAW);
#else
if (GLEW_VERSION_4_3 || GLEW_ARB_invalidate_subdata)
glInvalidateBufferData(imm.vbo_id);
else
glMapBufferRange(GL_ARRAY_BUFFER, 0, IMM_BUFFER_SIZE, GL_MAP_INVALIDATE_BUFFER_BIT);
#endif
imm.buffer_offset = 0;
}
// printf("mapping %u to %u\n", imm.buffer_offset, imm.buffer_offset + bytes_needed - 1);
#if APPLE_LEGACY
imm.buffer_data = glMapBuffer(GL_ARRAY_BUFFER, GL_WRITE_ONLY) + imm.buffer_offset;
#else
imm.buffer_data = glMapBufferRange(GL_ARRAY_BUFFER, imm.buffer_offset, bytes_needed,
GL_MAP_WRITE_BIT | GL_MAP_UNSYNCHRONIZED_BIT | (imm.strict_vertex_ct ? 0 : GL_MAP_FLUSH_EXPLICIT_BIT));
#endif
#if TRUST_NO_ONE
assert(imm.buffer_data != NULL);
#endif
imm.buffer_bytes_mapped = bytes_needed;
imm.vertex_data = imm.buffer_data;
}
void immBeginAtMost(PrimitiveType prim_type, unsigned vertex_ct)
{
#if TRUST_NO_ONE
assert(vertex_ct > 0);
#endif
imm.strict_vertex_ct = false;
immBegin(prim_type, vertex_ct);
}
#if IMM_BATCH_COMBO
Batch* immBeginBatch(PrimitiveType prim_type, unsigned vertex_ct)
{
#if TRUST_NO_ONE
assert(initialized);
assert(imm.prim_type == PRIM_NONE); // make sure we haven't already begun
assert(vertex_count_makes_sense_for_primitive(vertex_ct, prim_type));
#endif
imm.prim_type = prim_type;
imm.vertex_ct = vertex_ct;
imm.vertex_idx = 0;
imm.unassigned_attrib_bits = imm.attrib_binding.enabled_bits;
VertexBuffer* verts = VertexBuffer_create_with_format(&imm.vertex_format);
VertexBuffer_allocate_data(verts, vertex_ct);
imm.buffer_bytes_mapped = VertexBuffer_size(verts);
imm.vertex_data = verts->data;
imm.batch = Batch_create(prim_type, verts, NULL);
imm.batch->phase = BUILDING;
Batch_set_program(imm.batch, imm.bound_program);
return imm.batch;
}
Batch* immBeginBatchAtMost(PrimitiveType prim_type, unsigned vertex_ct)
{
imm.strict_vertex_ct = false;
return immBeginBatch(prim_type, vertex_ct);
}
#endif // IMM_BATCH_COMBO
static void immDrawSetup(void)
{
// set up VAO -- can be done during Begin or End really
glBindVertexArray(imm.vao_id);
// enable/disable vertex attribs as needed
if (imm.attrib_binding.enabled_bits != imm.prev_enabled_attrib_bits)
{
for (unsigned loc = 0; loc < MAX_VERTEX_ATTRIBS; ++loc)
{
bool is_enabled = imm.attrib_binding.enabled_bits & (1 << loc);
bool was_enabled = imm.prev_enabled_attrib_bits & (1 << loc);
if (is_enabled && !was_enabled)
{
// printf("enabling attrib %u\n", loc);
glEnableVertexAttribArray(loc);
}
else if (was_enabled && !is_enabled)
{
// printf("disabling attrib %u\n", loc);
glDisableVertexAttribArray(loc);
}
}
imm.prev_enabled_attrib_bits = imm.attrib_binding.enabled_bits;
}
const unsigned stride = imm.vertex_format.stride;
for (unsigned a_idx = 0; a_idx < imm.vertex_format.attrib_ct; ++a_idx)
{
const Attrib* a = imm.vertex_format.attribs + a_idx;
const unsigned offset = imm.buffer_offset + a->offset;
const GLvoid* pointer = (const GLubyte*)0 + offset;
const unsigned loc = read_attrib_location(&imm.attrib_binding, a_idx);
// printf("specifying attrib %u '%s' with offset %u, stride %u\n", loc, a->name, offset, stride);
switch (a->fetch_mode)
{
case KEEP_FLOAT:
case CONVERT_INT_TO_FLOAT:
glVertexAttribPointer(loc, a->comp_ct, a->comp_type, GL_FALSE, stride, pointer);
break;
case NORMALIZE_INT_TO_FLOAT:
glVertexAttribPointer(loc, a->comp_ct, a->comp_type, GL_TRUE, stride, pointer);
break;
case KEEP_INT:
glVertexAttribIPointer(loc, a->comp_ct, a->comp_type, stride, pointer);
}
}
if (gpuMatricesDirty())
gpuBindMatrices(imm.bound_program);
}
void immEnd(void)
{
#if TRUST_NO_ONE
assert(imm.prim_type != PRIM_NONE); // make sure we're between a Begin/End pair
#endif
unsigned buffer_bytes_used;
if (imm.strict_vertex_ct)
{
#if TRUST_NO_ONE
assert(imm.vertex_idx == imm.vertex_ct); // with all vertices defined
#endif
buffer_bytes_used = imm.buffer_bytes_mapped;
}
else
{
#if TRUST_NO_ONE
assert(imm.vertex_idx <= imm.vertex_ct);
#endif
// printf("used %u of %u verts,", imm.vertex_idx, imm.vertex_ct);
if (imm.vertex_idx == imm.vertex_ct)
{
buffer_bytes_used = imm.buffer_bytes_mapped;
}
else
{
#if TRUST_NO_ONE
assert(imm.vertex_idx == 0 || vertex_count_makes_sense_for_primitive(imm.vertex_idx, imm.prim_type));
#endif
imm.vertex_ct = imm.vertex_idx;
buffer_bytes_used = vertex_buffer_size(&imm.vertex_format, imm.vertex_ct);
// unused buffer bytes are available to the next immBegin
// printf(" %u of %u bytes\n", buffer_bytes_used, imm.buffer_bytes_mapped);
}
#if !APPLE_LEGACY
// tell OpenGL what range was modified so it doesn't copy the whole mapped range
// printf("flushing %u to %u\n", imm.buffer_offset, imm.buffer_offset + buffer_bytes_used - 1);
glFlushMappedBufferRange(GL_ARRAY_BUFFER, 0, buffer_bytes_used);
#endif
}
#if IMM_BATCH_COMBO
if (imm.batch)
{
if (buffer_bytes_used != imm.buffer_bytes_mapped)
{
VertexBuffer_resize_data(imm.batch->verts[0], imm.vertex_ct);
// TODO: resize only if vertex count is much smaller
}
imm.batch->phase = READY_TO_DRAW;
imm.batch = NULL; // don't free, batch belongs to caller
}
else
#endif
{
#if APPLE_LEGACY
// tell OpenGL what range was modified so it doesn't copy the whole buffer
// printf("flushing %u to %u\n", imm.buffer_offset, imm.buffer_offset + buffer_bytes_used - 1);
glFlushMappedBufferRangeAPPLE(GL_ARRAY_BUFFER, imm.buffer_offset, buffer_bytes_used);
#endif
glUnmapBuffer(GL_ARRAY_BUFFER);
if (imm.vertex_ct > 0)
{
immDrawSetup();
glDrawArrays(imm.prim_type, 0, imm.vertex_ct);
}
glBindBuffer(GL_ARRAY_BUFFER, 0);
glBindVertexArray(0);
// prep for next immBegin
imm.buffer_offset += buffer_bytes_used;
}
// prep for next immBegin
imm.prim_type = PRIM_NONE;
imm.strict_vertex_ct = true;
}
static void setAttribValueBit(unsigned attrib_id)
{
uint16_t mask = 1 << attrib_id;
#if TRUST_NO_ONE
assert(imm.unassigned_attrib_bits & mask); // not already set
#endif
imm.unassigned_attrib_bits &= ~mask;
}
// --- generic attribute functions ---
void immAttrib1f(unsigned attrib_id, float x)
{
Attrib* attrib = imm.vertex_format.attribs + attrib_id;
#if TRUST_NO_ONE
assert(attrib_id < imm.vertex_format.attrib_ct);
assert(attrib->comp_type == COMP_F32);
assert(attrib->comp_ct == 1);
assert(imm.vertex_idx < imm.vertex_ct);
assert(imm.prim_type != PRIM_NONE); // make sure we're between a Begin/End pair
#endif
setAttribValueBit(attrib_id);
float* data = (float*)(imm.vertex_data + attrib->offset);
// printf("%s %td %p\n", __FUNCTION__, (GLubyte*)data - imm.buffer_data, data);
data[0] = x;
}
void immAttrib2f(unsigned attrib_id, float x, float y)
{
Attrib* attrib = imm.vertex_format.attribs + attrib_id;
#if TRUST_NO_ONE
assert(attrib_id < imm.vertex_format.attrib_ct);
assert(attrib->comp_type == COMP_F32);
assert(attrib->comp_ct == 2);
assert(imm.vertex_idx < imm.vertex_ct);
assert(imm.prim_type != PRIM_NONE); // make sure we're between a Begin/End pair
#endif
setAttribValueBit(attrib_id);
float* data = (float*)(imm.vertex_data + attrib->offset);
// printf("%s %td %p\n", __FUNCTION__, (GLubyte*)data - imm.buffer_data, data);
data[0] = x;
data[1] = y;
}
void immAttrib3f(unsigned attrib_id, float x, float y, float z)
{
Attrib* attrib = imm.vertex_format.attribs + attrib_id;
#if TRUST_NO_ONE
assert(attrib_id < imm.vertex_format.attrib_ct);
assert(attrib->comp_type == COMP_F32);
assert(attrib->comp_ct == 3);
assert(imm.vertex_idx < imm.vertex_ct);
assert(imm.prim_type != PRIM_NONE); // make sure we're between a Begin/End pair
#endif
setAttribValueBit(attrib_id);
float* data = (float*)(imm.vertex_data + attrib->offset);
// printf("%s %td %p\n", __FUNCTION__, (GLubyte*)data - imm.buffer_data, data);
data[0] = x;
data[1] = y;
data[2] = z;
}
void immAttrib4f(unsigned attrib_id, float x, float y, float z, float w)
{
Attrib* attrib = imm.vertex_format.attribs + attrib_id;
#if TRUST_NO_ONE
assert(attrib_id < imm.vertex_format.attrib_ct);
assert(attrib->comp_type == COMP_F32);
assert(attrib->comp_ct == 4);
assert(imm.vertex_idx < imm.vertex_ct);
assert(imm.prim_type != PRIM_NONE); // make sure we're between a Begin/End pair
#endif
setAttribValueBit(attrib_id);
float* data = (float*)(imm.vertex_data + attrib->offset);
// printf("%s %td %p\n", __FUNCTION__, (GLubyte*)data - imm.buffer_data, data);
data[0] = x;
data[1] = y;
data[2] = z;
data[3] = w;
}
void immAttrib2i(unsigned attrib_id, int x, int y)
{
Attrib* attrib = imm.vertex_format.attribs + attrib_id;
#if TRUST_NO_ONE
assert(attrib_id < imm.vertex_format.attrib_ct);
assert(attrib->comp_type == COMP_I32);
assert(attrib->comp_ct == 2);
assert(imm.vertex_idx < imm.vertex_ct);
assert(imm.prim_type != PRIM_NONE); // make sure we're between a Begin/End pair
#endif
setAttribValueBit(attrib_id);
int* data = (int*)(imm.vertex_data + attrib->offset);
data[0] = x;
data[1] = y;
}
void immAttrib2s(unsigned attrib_id, short x, short y)
{
Attrib* attrib = imm.vertex_format.attribs + attrib_id;
#if TRUST_NO_ONE
assert(attrib_id < imm.vertex_format.attrib_ct);
assert(attrib->comp_type == COMP_I16);
assert(attrib->comp_ct == 2);
assert(imm.vertex_idx < imm.vertex_ct);
assert(imm.prim_type != PRIM_NONE); // make sure we're between a Begin/End pair
#endif
setAttribValueBit(attrib_id);
short* data = (short*)(imm.vertex_data + attrib->offset);
data[0] = x;
data[1] = y;
}
void immAttrib3fv(unsigned attrib_id, const float data[3])
{
immAttrib3f(attrib_id, data[0], data[1], data[2]);
}
void immAttrib4fv(unsigned attrib_id, const float data[4])
{
immAttrib4f(attrib_id, data[0], data[1], data[2], data[3]);
}
void immAttrib3ub(unsigned attrib_id, unsigned char r, unsigned char g, unsigned char b)
{
Attrib* attrib = imm.vertex_format.attribs + attrib_id;
#if TRUST_NO_ONE
assert(attrib_id < imm.vertex_format.attrib_ct);
assert(attrib->comp_type == COMP_U8);
assert(attrib->comp_ct == 3);
assert(imm.vertex_idx < imm.vertex_ct);
assert(imm.prim_type != PRIM_NONE); // make sure we're between a Begin/End pair
#endif
setAttribValueBit(attrib_id);
GLubyte* data = imm.vertex_data + attrib->offset;
// printf("%s %td %p\n", __FUNCTION__, data - imm.buffer_data, data);
data[0] = r;
data[1] = g;
data[2] = b;
}
void immAttrib4ub(unsigned attrib_id, unsigned char r, unsigned char g, unsigned char b, unsigned char a)
{
Attrib* attrib = imm.vertex_format.attribs + attrib_id;
#if TRUST_NO_ONE
assert(attrib_id < imm.vertex_format.attrib_ct);
assert(attrib->comp_type == COMP_U8);
assert(attrib->comp_ct == 4);
assert(imm.vertex_idx < imm.vertex_ct);
assert(imm.prim_type != PRIM_NONE); // make sure we're between a Begin/End pair
#endif
setAttribValueBit(attrib_id);
GLubyte* data = imm.vertex_data + attrib->offset;
// printf("%s %td %p\n", __FUNCTION__, data - imm.buffer_data, data);
data[0] = r;
data[1] = g;
data[2] = b;
data[3] = a;
}
void immAttrib3ubv(unsigned attrib_id, const unsigned char data[3])
{
immAttrib3ub(attrib_id, data[0], data[1], data[2]);
}
void immAttrib4ubv(unsigned attrib_id, const unsigned char data[4])
{
immAttrib4ub(attrib_id, data[0], data[1], data[2], data[3]);
}
void immSkipAttrib(unsigned attrib_id)
{
#if TRUST_NO_ONE
assert(attrib_id < imm.vertex_format.attrib_ct);
assert(imm.vertex_idx < imm.vertex_ct);
assert(imm.prim_type != PRIM_NONE); // make sure we're between a Begin/End pair
#endif
setAttribValueBit(attrib_id);
}
static void immEndVertex(void) // and move on to the next vertex
{
#if TRUST_NO_ONE
assert(imm.prim_type != PRIM_NONE); // make sure we're between a Begin/End pair
assert(imm.vertex_idx < imm.vertex_ct);
#endif
// have all attribs been assigned values?
// if not, copy value from previous vertex
if (imm.unassigned_attrib_bits)
{
#if TRUST_NO_ONE
assert(imm.vertex_idx > 0); // first vertex must have all attribs specified
#endif
for (unsigned a_idx = 0; a_idx < imm.vertex_format.attrib_ct; ++a_idx)
{
if ((imm.unassigned_attrib_bits >> a_idx) & 1)
{
const Attrib* a = imm.vertex_format.attribs + a_idx;
// printf("copying %s from vertex %u to %u\n", a->name, imm.vertex_idx - 1, imm.vertex_idx);
GLubyte* data = imm.vertex_data + a->offset;
memcpy(data, data - imm.vertex_format.stride, a->sz);
// TODO: consolidate copy of adjacent attributes
}
}
}
imm.vertex_idx++;
imm.vertex_data += imm.vertex_format.stride;
imm.unassigned_attrib_bits = imm.attrib_binding.enabled_bits;
}
void immVertex2f(unsigned attrib_id, float x, float y)
{
immAttrib2f(attrib_id, x, y);
immEndVertex();
}
void immVertex3f(unsigned attrib_id, float x, float y, float z)
{
immAttrib3f(attrib_id, x, y, z);
immEndVertex();
}
void immVertex2i(unsigned attrib_id, int x, int y)
{
immAttrib2i(attrib_id, x, y);
immEndVertex();
}
void immVertex2s(unsigned attrib_id, short x, short y)
{
immAttrib2s(attrib_id, x, y);
immEndVertex();
}
void immVertex2fv(unsigned attrib_id, const float data[2])
{
immAttrib2f(attrib_id, data[0], data[1]);
immEndVertex();
}
void immVertex3fv(unsigned attrib_id, const float data[3])
{
immAttrib3f(attrib_id, data[0], data[1], data[2]);
immEndVertex();
}
void immVertex2iv(unsigned attrib_id, const int data[2])
{
immAttrib2i(attrib_id, data[0], data[1]);
immEndVertex();
}
// --- generic uniform functions ---
void immUniform1f(const char* name, float x)
{
int loc = glGetUniformLocation(imm.bound_program, name);
#if TRUST_NO_ONE
assert(loc != -1);
#endif
glUniform1f(loc, x);
}
void immUniform2f(const char* name, float x, float y)
{
int loc = glGetUniformLocation(imm.bound_program, name);
#if TRUST_NO_ONE
assert(loc != -1);
#endif
glUniform2f(loc, x, y);
}
void immUniform2fv(const char* name, const float data[2])
{
int loc = glGetUniformLocation(imm.bound_program, name);
#if TRUST_NO_ONE
assert(loc != -1);
#endif
glUniform2fv(loc, 1, data);
}
void immUniform3f(const char* name, float x, float y, float z)
{
int loc = glGetUniformLocation(imm.bound_program, name);
#if TRUST_NO_ONE
assert(loc != -1);
#endif
glUniform3f(loc, x, y, z);
}
void immUniform3fv(const char* name, const float data[3])
{
int loc = glGetUniformLocation(imm.bound_program, name);
#if TRUST_NO_ONE
assert(loc != -1);
#endif
glUniform3fv(loc, 1, data);
}
void immUniformArray3fv(const char* name, const float *data, int count)
{
int loc = glGetUniformLocation(imm.bound_program, name);
#if TRUST_NO_ONE
assert(loc != -1);
assert(count > 0);
#endif
glUniform3fv(loc, count, data);
}
void immUniform4f(const char* name, float x, float y, float z, float w)
{
int loc = glGetUniformLocation(imm.bound_program, name);
#if TRUST_NO_ONE
assert(loc != -1);
#endif
glUniform4f(loc, x, y, z, w);
}
void immUniform4fv(const char* name, const float data[4])
{
int loc = glGetUniformLocation(imm.bound_program, name);
#if TRUST_NO_ONE
assert(loc != -1);
#endif
glUniform4fv(loc, 1, data);
}
void immUniformMatrix4fv(const char* name, const float data[4][4])
{
int loc = glGetUniformLocation(imm.bound_program, name);
#if TRUST_NO_ONE
assert(loc != -1);
#endif
glUniformMatrix4fv(loc, 1, GL_FALSE, (float *)data);
}
void immUniform1i(const char* name, int x)
{
int loc = glGetUniformLocation(imm.bound_program, name);
#if TRUST_NO_ONE
assert(loc != -1);
#endif
glUniform1i(loc, x);
}
// --- convenience functions for setting "uniform vec4 color" ---
void immUniformColor4f(float r, float g, float b, float a)
{
immUniform4f("color", r, g, b, a);
}
void immUniformColor4fv(const float rgba[4])
{
immUniform4fv("color", rgba);
}
void immUniformColor3f(float r, float g, float b)
{
immUniform4f("color", r, g, b, 1.0f);
}
void immUniformColor3fv(const float rgb[3])
{
immUniform4f("color", rgb[0], rgb[1], rgb[2], 1.0f);
}
void immUniformColor3fvAlpha(const float rgb[3], float a)
{
immUniform4f("color", rgb[0], rgb[1], rgb[2], a);
}
// TODO: v-- treat as sRGB? --v
void immUniformColor3ub(unsigned char r, unsigned char g, unsigned char b)
{
const float scale = 1.0f / 255.0f;
immUniform4f("color", scale * r, scale * g, scale * b, 1.0f);
}
void immUniformColor4ub(unsigned char r, unsigned char g, unsigned char b, unsigned char a)
{
const float scale = 1.0f / 255.0f;
immUniform4f("color", scale * r, scale * g, scale * b, scale * a);
}
void immUniformColor3ubv(const unsigned char rgb[3])
{
immUniformColor3ub(rgb[0], rgb[1], rgb[2]);
}
void immUniformColor4ubv(const unsigned char rgba[4])
{
immUniformColor4ub(rgba[0], rgba[1], rgba[2], rgba[3]);
}

View File

@@ -0,0 +1,41 @@
// Gawain geometric primitives
//
// This code is part of the Gawain library, with modifications
// specific to integration with Blender.
//
// Copyright 2017 Mike Erwin
//
// This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0. If a copy of
// the MPL was not distributed with this file, You can obtain one at https://mozilla.org/MPL/2.0/.
#include "primitive.h"
PrimitiveClass prim_class_of_type(PrimitiveType prim_type)
{
static const PrimitiveClass classes[] =
{
[PRIM_NONE] = PRIM_CLASS_NONE,
[PRIM_POINTS] = PRIM_CLASS_POINT,
[PRIM_LINES] = PRIM_CLASS_LINE,
[PRIM_LINE_STRIP] = PRIM_CLASS_LINE,
[PRIM_LINE_LOOP] = PRIM_CLASS_LINE,
[PRIM_TRIANGLES] = PRIM_CLASS_SURFACE,
[PRIM_TRIANGLE_STRIP] = PRIM_CLASS_SURFACE,
[PRIM_TRIANGLE_FAN] = PRIM_CLASS_SURFACE,
#ifdef WITH_GL_PROFILE_COMPAT
[PRIM_QUADS] = PRIM_CLASS_SURFACE,
#endif
};
return classes[prim_type];
}
bool prim_type_belongs_to_class(PrimitiveType prim_type, PrimitiveClass prim_class)
{
if (prim_class == PRIM_CLASS_NONE && prim_type == PRIM_NONE)
return true;
return prim_class & prim_class_of_type(prim_type);
}

View File

@@ -0,0 +1,140 @@
// Gawain shader interface (C --> GLSL)
//
// This code is part of the Gawain library, with modifications
// specific to integration with Blender.
//
// Copyright 2017 Mike Erwin
//
// This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0. If a copy of
// the MPL was not distributed with this file, You can obtain one at https://mozilla.org/MPL/2.0/.
#include "shader_interface.h"
#include <stdlib.h>
#include <stddef.h>
#define DEBUG_SHADER_INTERFACE 0
#if DEBUG_SHADER_INTERFACE
#include <stdio.h>
#endif
#if 0
static const char* BuiltinUniform_name(BuiltinUniform u)
{
static const char* names[] =
{
[UNIFORM_NONE] = NULL,
[UNIFORM_MODELVIEW_3D] = "ModelViewMatrix",
[UNIFORM_PROJECTION_3D] = "ProjectionMatrix",
[UNIFORM_MVP_3D] = "ModelViewProjectionMatrix",
[UNIFORM_NORMAL_3D] = "NormalMatrix",
[UNIFORM_INV_NORMAL_3D] = "InverseNormalMatrix",
[UNIFORM_MODELVIEW_2D] = "ModelViewMatrix",
[UNIFORM_PROJECTION_2D] = "ProjectionMatrix",
[UNIFORM_MVP_2D] = "ModelViewProjectionMatrix",
[UNIFORM_COLOR] = "color",
[UNIFORM_CUSTOM] = NULL
};
return names[u];
}
#endif
static bool setup_builtin_uniform(ShaderInput* input, const char* name)
{
// TODO: reject DOUBLE, IMAGE, ATOMIC_COUNTER gl_types
// TODO: detect built-in uniforms (gl_type and name must match)
// if a match is found, use BuiltinUniform_name so name buffer space can be reclaimed
input->name = name;
input->builtin_type = UNIFORM_CUSTOM;
return false;
}
ShaderInterface* ShaderInterface_create(GLint program)
{
#if DEBUG_SHADER_INTERFACE
printf("%s {\n", __func__); // enter function
#endif
GLint uniform_ct, attrib_ct;
glGetProgramiv(program, GL_ACTIVE_UNIFORMS, &uniform_ct);
glGetProgramiv(program, GL_ACTIVE_ATTRIBUTES, &attrib_ct);
const GLint input_ct = uniform_ct + attrib_ct;
GLint max_uniform_name_len, max_attrib_name_len;
glGetProgramiv(program, GL_ACTIVE_UNIFORM_MAX_LENGTH, &max_uniform_name_len);
glGetProgramiv(program, GL_ACTIVE_ATTRIBUTE_MAX_LENGTH, &max_attrib_name_len);
const uint32_t name_buffer_len = uniform_ct * max_uniform_name_len + attrib_ct * max_attrib_name_len;
// allocate enough space for input counts, details for each input, and a buffer for name strings
ShaderInterface* shaderface = calloc(1, offsetof(ShaderInterface, inputs) + input_ct * sizeof(ShaderInput) + name_buffer_len);
char* name_buffer = (char*)shaderface + offsetof(ShaderInterface, inputs) + input_ct * sizeof(ShaderInput);
uint32_t name_buffer_offset = 0;
for (uint32_t i = 0; i < uniform_ct; ++i)
{
ShaderInput* input = shaderface->inputs + i;
GLsizei remaining_buffer = name_buffer_len - name_buffer_offset;
char* name = name_buffer + name_buffer_offset;
GLsizei name_len = 0;
glGetActiveUniform(program, i, remaining_buffer, &name_len, &input->size, &input->gl_type, name);
if (setup_builtin_uniform(input, name))
; // reclaim space from name buffer (don't advance offset)
else
name_buffer_offset += name_len + 1; // include NULL terminator
input->location = glGetUniformLocation(program, name);
#if DEBUG_SHADER_INTERFACE
printf("uniform[%u] '%s' at location %d\n", i, name, input->location);
#endif
}
for (uint32_t i = 0; i < attrib_ct; ++i)
{
ShaderInput* input = shaderface->inputs + uniform_ct + i;
GLsizei remaining_buffer = name_buffer_len - name_buffer_offset;
char* name = name_buffer + name_buffer_offset;
GLsizei name_len = 0;
glGetActiveAttrib(program, i, remaining_buffer, &name_len, &input->size, &input->gl_type, name);
// TODO: reject DOUBLE gl_types
input->name = name;
name_buffer_offset += name_len + 1; // include NULL terminator
input->location = glGetAttribLocation(program, name);
#if DEBUG_SHADER_INTERFACE
printf("attrib[%u] '%s' at location %d\n", i, name, input->location);
#endif
}
// TODO: realloc shaderface to shrink name buffer
// each input->name will need adjustment (except static built-in names)
#if DEBUG_SHADER_INTERFACE
printf("using %u of %u bytes from name buffer\n", name_buffer_offset, name_buffer_len);
printf("}\n"); // exit function
#endif
return shaderface;
}
void ShaderInterface_discard(ShaderInterface* shaderface)
{
// allocated as one chunk, so discard is simple
free(shaderface);
}

View File

@@ -0,0 +1,170 @@
// Gawain geometry batch
//
// This code is part of the Gawain library, with modifications
// specific to integration with Blender.
//
// Copyright 2016 Mike Erwin
//
// This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0. If a copy of
// the MPL was not distributed with this file, You can obtain one at https://mozilla.org/MPL/2.0/.
#include "vertex_buffer.h"
#include "buffer_id.h"
#include <stdlib.h>
#include <string.h>
#define KEEP_SINGLE_COPY 1
VertexBuffer* VertexBuffer_create(void)
{
VertexBuffer* verts = malloc(sizeof(VertexBuffer));
VertexBuffer_init(verts);
return verts;
}
VertexBuffer* VertexBuffer_create_with_format(const VertexFormat* format)
{
VertexBuffer* verts = VertexBuffer_create();
VertexFormat_copy(&verts->format, format);
if (!format->packed)
VertexFormat_pack(&verts->format);
return verts;
// this function might seem redundant, but there is potential for memory savings here...
// TODO: implement those memory savings
}
void VertexBuffer_init(VertexBuffer* verts)
{
memset(verts, 0, sizeof(VertexBuffer));
}
void VertexBuffer_init_with_format(VertexBuffer* verts, const VertexFormat* format)
{
VertexBuffer_init(verts);
VertexFormat_copy(&verts->format, format);
if (!format->packed)
VertexFormat_pack(&verts->format);
}
void VertexBuffer_discard(VertexBuffer* verts)
{
if (verts->vbo_id)
buffer_id_free(verts->vbo_id);
#if KEEP_SINGLE_COPY
else
#endif
if (verts->data)
free(verts->data);
free(verts);
}
unsigned VertexBuffer_size(const VertexBuffer* verts)
{
return vertex_buffer_size(&verts->format, verts->vertex_ct);
}
void VertexBuffer_allocate_data(VertexBuffer* verts, unsigned v_ct)
{
VertexFormat* format = &verts->format;
if (!format->packed)
VertexFormat_pack(format);
verts->vertex_ct = v_ct;
// Data initially lives in main memory. Will be transferred to VRAM when we "prime" it.
verts->data = malloc(VertexBuffer_size(verts));
}
void VertexBuffer_resize_data(VertexBuffer* verts, unsigned v_ct)
{
#if TRUST_NO_ONE
assert(verts->vertex_ct != v_ct); // allow this?
assert(verts->data != NULL); // has already been allocated
assert(verts->vbo_id == 0); // has not been sent to VRAM
#endif
verts->vertex_ct = v_ct;
verts->data = realloc(verts->data, VertexBuffer_size(verts));
// TODO: skip realloc if v_ct < existing vertex count
// extra space will be reclaimed, and never sent to VRAM (see VertexBuffer_prime)
}
void setAttrib(VertexBuffer* verts, unsigned a_idx, unsigned v_idx, const void* data)
{
const VertexFormat* format = &verts->format;
const Attrib* a = format->attribs + a_idx;
#if TRUST_NO_ONE
assert(a_idx < format->attrib_ct);
assert(v_idx < verts->vertex_ct);
assert(verts->data != NULL); // data must be in main mem
#endif
memcpy((GLubyte*)verts->data + a->offset + v_idx * format->stride, data, a->sz);
}
void fillAttrib(VertexBuffer* verts, unsigned a_idx, const void* data)
{
const VertexFormat* format = &verts->format;
const Attrib* a = format->attribs + a_idx;
#if TRUST_NO_ONE
assert(a_idx < format->attrib_ct);
#endif
const unsigned stride = a->sz; // tightly packed input data
fillAttribStride(verts, a_idx, stride, data);
}
void fillAttribStride(VertexBuffer* verts, unsigned a_idx, unsigned stride, const void* data)
{
const VertexFormat* format = &verts->format;
const Attrib* a = format->attribs + a_idx;
#if TRUST_NO_ONE
assert(a_idx < format->attrib_ct);
assert(verts->data != NULL); // data must be in main mem
#endif
const unsigned vertex_ct = verts->vertex_ct;
if (format->attrib_ct == 1 && stride == format->stride)
{
// we can copy it all at once
memcpy(verts->data, data, vertex_ct * a->sz);
}
else
{
// we must copy it per vertex
for (unsigned v = 0; v < vertex_ct; ++v)
memcpy((GLubyte*)verts->data + a->offset + v * format->stride, (const GLubyte*)data + v * stride, a->sz);
}
}
static void VertexBuffer_prime(VertexBuffer* verts)
{
const VertexFormat* format = &verts->format;
verts->vbo_id = buffer_id_alloc();
glBindBuffer(GL_ARRAY_BUFFER, verts->vbo_id);
// fill with delicious data & send to GPU the first time only
glBufferData(GL_ARRAY_BUFFER, vertex_buffer_size(format, verts->vertex_ct), verts->data, GL_STATIC_DRAW);
#if KEEP_SINGLE_COPY
// now that GL has a copy, discard original
free(verts->data);
verts->data = NULL;
#endif
}
void VertexBuffer_use(VertexBuffer* verts)
{
if (verts->vbo_id)
glBindBuffer(GL_ARRAY_BUFFER, verts->vbo_id);
else
VertexBuffer_prime(verts);
}

View File

@@ -0,0 +1,248 @@
// Gawain vertex format
//
// This code is part of the Gawain library, with modifications
// specific to integration with Blender.
//
// Copyright 2016 Mike Erwin
//
// This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0. If a copy of
// the MPL was not distributed with this file, You can obtain one at https://mozilla.org/MPL/2.0/.
#include "vertex_format.h"
#include <stdlib.h>
#include <string.h>
#define PACK_DEBUG 0
#if PACK_DEBUG
#include <stdio.h>
#endif
void VertexFormat_clear(VertexFormat* format)
{
#if TRUST_NO_ONE
memset(format, 0, sizeof(VertexFormat));
#else
format->attrib_ct = 0;
format->packed = false;
format->name_offset = 0;
#endif
}
void VertexFormat_copy(VertexFormat* dest, const VertexFormat* src)
{
// copy regular struct fields
memcpy(dest, src, sizeof(VertexFormat));
}
static unsigned comp_sz(VertexCompType type)
{
#if TRUST_NO_ONE
assert(type >= GL_BYTE && type <= GL_FLOAT);
#endif
const GLubyte sizes[] = {1,1,2,2,4,4,4};
return sizes[type - GL_BYTE];
}
static unsigned attrib_sz(const Attrib *a)
{
#if USE_10_10_10
if (a->comp_type == COMP_I10)
return 4; // always packed as 10_10_10_2
#endif
return a->comp_ct * comp_sz(a->comp_type);
}
static unsigned attrib_align(const Attrib *a)
{
#if USE_10_10_10
if (a->comp_type == COMP_I10)
return 4; // always packed as 10_10_10_2
#endif
unsigned c = comp_sz(a->comp_type);
if (a->comp_ct == 3 && c <= 2)
return 4 * c; // AMD HW can't fetch these well, so pad it out (other vendors too?)
else
return c; // most fetches are ok if components are naturally aligned
}
unsigned vertex_buffer_size(const VertexFormat* format, unsigned vertex_ct)
{
#if TRUST_NO_ONE
assert(format->packed && format->stride > 0);
#endif
return format->stride * vertex_ct;
}
static const char* copy_attrib_name(VertexFormat* format, const char* name)
{
// strncpy does 110% of what we need; let's do exactly 100%
char* name_copy = format->names + format->name_offset;
unsigned available = VERTEX_ATTRIB_NAMES_BUFFER_LEN - format->name_offset;
bool terminated = false;
for (unsigned i = 0; i < available; ++i)
{
const char c = name[i];
name_copy[i] = c;
if (c == '\0')
{
terminated = true;
format->name_offset += (i + 1);
break;
}
}
#if TRUST_NO_ONE
assert(terminated);
assert(format->name_offset <= VERTEX_ATTRIB_NAMES_BUFFER_LEN);
#endif
return name_copy;
}
unsigned add_attrib(VertexFormat* format, const char* name, VertexCompType comp_type, unsigned comp_ct, VertexFetchMode fetch_mode)
{
#if TRUST_NO_ONE
assert(format->attrib_ct < MAX_VERTEX_ATTRIBS); // there's room for more
assert(!format->packed); // packed means frozen/locked
assert(comp_ct >= 1 && comp_ct <= 4);
switch (comp_type)
{
case COMP_F32:
// float type can only kept as float
assert(fetch_mode == KEEP_FLOAT);
break;
#if USE_10_10_10
case COMP_I10:
// 10_10_10 format intended for normals (xyz) or colors (rgb)
// extra component packed.w can be manually set to { -2, -1, 0, 1 }
assert(comp_ct == 3 || comp_ct == 4);
assert(fetch_mode == NORMALIZE_INT_TO_FLOAT); // not strictly required, may relax later
break;
#endif
default:
// integer types can be kept as int or converted/normalized to float
assert(fetch_mode != KEEP_FLOAT);
}
#endif
const unsigned attrib_id = format->attrib_ct++;
Attrib* attrib = format->attribs + attrib_id;
attrib->name = copy_attrib_name(format, name);
attrib->comp_type = comp_type;
#if USE_10_10_10
attrib->comp_ct = (comp_type == COMP_I10) ? 4 : comp_ct; // system needs 10_10_10_2 to be 4 or BGRA
#else
attrib->comp_ct = comp_ct;
#endif
attrib->sz = attrib_sz(attrib);
attrib->offset = 0; // offsets & stride are calculated later (during pack)
attrib->fetch_mode = fetch_mode;
return attrib_id;
}
unsigned padding(unsigned offset, unsigned alignment)
{
const unsigned mod = offset % alignment;
return (mod == 0) ? 0 : (alignment - mod);
}
#if PACK_DEBUG
static void show_pack(unsigned a_idx, unsigned sz, unsigned pad)
{
const char c = 'A' + a_idx;
for (unsigned i = 0; i < pad; ++i)
putchar('-');
for (unsigned i = 0; i < sz; ++i)
putchar(c);
}
#endif
void VertexFormat_pack(VertexFormat* format)
{
// for now, attributes are packed in the order they were added,
// making sure each attrib is naturally aligned (add padding where necessary)
// later we can implement more efficient packing w/ reordering
// (keep attrib ID order, adjust their offsets to reorder in buffer)
// TODO:
// realloc just enough to hold the final combo string. And just enough to
// hold used attribs, not all 16.
Attrib* a0 = format->attribs + 0;
a0->offset = 0;
unsigned offset = a0->sz;
#if PACK_DEBUG
show_pack(0, a0->sz, 0);
#endif
for (unsigned a_idx = 1; a_idx < format->attrib_ct; ++a_idx)
{
Attrib* a = format->attribs + a_idx;
unsigned mid_padding = padding(offset, attrib_align(a));
offset += mid_padding;
a->offset = offset;
offset += a->sz;
#if PACK_DEBUG
show_pack(a_idx, a->sz, mid_padding);
#endif
}
unsigned end_padding = padding(offset, attrib_align(a0));
#if PACK_DEBUG
show_pack(0, 0, end_padding);
putchar('\n');
#endif
format->stride = offset + end_padding;
format->packed = true;
}
#if USE_10_10_10
// OpenGL ES packs in a different order as desktop GL but component conversion is the same.
// Of the code here, only struct PackedNormal needs to change.
#define SIGNED_INT_10_MAX 511
#define SIGNED_INT_10_MIN -512
static int clampi(int x, int min_allowed, int max_allowed)
{
#if TRUST_NO_ONE
assert(min_allowed <= max_allowed);
#endif
if (x < min_allowed)
return min_allowed;
else if (x > max_allowed)
return max_allowed;
else
return x;
}
static int quantize(float x)
{
int qx = x * 511.0f;
return clampi(qx, SIGNED_INT_10_MIN, SIGNED_INT_10_MAX);
}
PackedNormal convert_i10_v3(const float data[3])
{
PackedNormal n = { .x = quantize(data[0]), .y = quantize(data[1]), .z = quantize(data[2]) };
return n;
}
#endif // USE_10_10_10

View File

@@ -134,6 +134,8 @@ private:
/** The OpenGL drawing context */
NSOpenGLContext *m_openGLContext;
bool m_coreProfile;
//static CGLEWContext *s_cglewContext;
const bool m_debug;

View File

@@ -63,6 +63,23 @@ GHOST_ContextCGL::GHOST_ContextCGL(
m_debug(contextFlags)
{
assert(openGLView != nil);
// for now be very strict about OpenGL version requested
switch (contextMajorVersion) {
case 2:
assert(contextMinorVersion == 1);
assert(contextProfileMask == 0);
m_coreProfile = false;
break;
case 3:
// Apple didn't implement 3.0 or 3.1
assert(contextMinorVersion == 2);
assert(contextProfileMask == GL_CONTEXT_CORE_PROFILE_BIT);
m_coreProfile = true;
break;
default:
assert(false);
}
}
@@ -170,6 +187,7 @@ GHOST_TSuccess GHOST_ContextCGL::updateDrawingContext()
static void makeAttribList(
std::vector<NSOpenGLPixelFormatAttribute>& attribs,
bool coreProfile,
bool stereoVisual,
int numOfAASamples,
bool needAlpha,
@@ -178,6 +196,9 @@ static void makeAttribList(
{
attribs.clear();
attribs.push_back(NSOpenGLPFAOpenGLProfile);
attribs.push_back(coreProfile ? NSOpenGLProfileVersion3_2Core : NSOpenGLProfileVersionLegacy);
// Pixel Format Attributes for the windowed NSOpenGLContext
attribs.push_back(NSOpenGLPFADoubleBuffer);
@@ -190,8 +211,7 @@ static void makeAttribList(
attribs.push_back(NSOpenGLPFANoRecovery);
}
/* Removed to allow 10.4 builds, and 2 GPUs rendering is not used anyway */
//attribs.push_back(NSOpenGLPFAAllowOfflineRenderers);
attribs.push_back(NSOpenGLPFAAllowOfflineRenderers); // for automatic GPU switching
attribs.push_back(NSOpenGLPFADepthSize);
attribs.push_back((NSOpenGLPixelFormatAttribute) 32);
@@ -263,7 +283,7 @@ GHOST_TSuccess GHOST_ContextCGL::initializeDrawingContext()
NSOpenGLPixelFormat *pixelFormat;
// TODO: keep pixel format for subsequent windows/contexts instead of recreating each time
makeAttribList(attribs, m_stereoVisual, m_numOfAASamples, needAlpha, needStencil, softwareGL);
makeAttribList(attribs, m_coreProfile, m_stereoVisual, m_numOfAASamples, needAlpha, needStencil, softwareGL);
pixelFormat = [[NSOpenGLPixelFormat alloc] initWithAttributes:&attribs[0]];
@@ -274,7 +294,7 @@ GHOST_TSuccess GHOST_ContextCGL::initializeDrawingContext()
// (Now that I think about it, does WGL really require the code that it has for finding a lesser match?)
attribs.clear();
makeAttribList(attribs, m_stereoVisual, 0, needAlpha, needStencil, softwareGL);
makeAttribList(attribs, m_coreProfile, m_stereoVisual, 0, needAlpha, needStencil, softwareGL);
pixelFormat = [[NSOpenGLPixelFormat alloc] initWithAttributes:&attribs[0]];
}
@@ -316,7 +336,7 @@ GHOST_TSuccess GHOST_ContextCGL::initializeDrawingContext()
[m_openGLContext release];
// create software GL context
makeAttribList(attribs, m_stereoVisual, m_numOfAASamples, needAlpha, needStencil, softwareGL);
makeAttribList(attribs, m_coreProfile, m_stereoVisual, m_numOfAASamples, needAlpha, needStencil, softwareGL);
pixelFormat = [[NSOpenGLPixelFormat alloc] initWithAttributes:&attribs[0]];
m_openGLContext = [[NSOpenGLContext alloc] initWithFormat:pixelFormat shareContext:s_sharedOpenGLContext];
[pixelFormat release];

View File

@@ -255,9 +255,6 @@ const bool GLXEW_ARB_create_context_robustness =
if (m_contextMajorVersion != 0) {
attribs[i++] = GLX_CONTEXT_MAJOR_VERSION_ARB;
attribs[i++] = m_contextMajorVersion;
}
if (m_contextMinorVersion != 0) {
attribs[i++] = GLX_CONTEXT_MINOR_VERSION_ARB;
attribs[i++] = m_contextMinorVersion;
}
@@ -300,8 +297,8 @@ const bool GLXEW_ARB_create_context_robustness =
}
}
else {
/* Create legacy context */
m_context = glXCreateContext(m_display, m_visualInfo, s_sharedContext, True);
/* Don't create legacy context */
fprintf(stderr, "Warning! GLX_ARB_create_context not available.\n");
}
GHOST_TSuccess success;
@@ -328,8 +325,14 @@ const bool GLXEW_ARB_create_context_robustness =
version = glGetString(GL_VERSION);
if (!version || version[0] < '2' || ((version[0] == '2') && (version[2] < '1'))) {
fprintf(stderr, "Error! Blender requires OpenGL 2.1 to run. Try updating your drivers.\n");
#if 0 // enable this when Blender switches to 3.3 core profile
if (!version || version[0] < '3' || ((version[0] == '3') && (version[2] < '3'))) {
fprintf(stderr, "Error! Blender requires OpenGL 3.3 to run. Try updating your drivers.\n");
#else
// with Mesa, the closest thing to 3.3 compatibility profile is 3.0
if (!version || version[0] < '3') {
fprintf(stderr, "Error! Blender requires OpenGL 3.0 (soon 3.3) to run. Try updating your drivers.\n");
#endif
fflush(stderr);
/* ugly, but we get crashes unless a whole bunch of systems are patched. */
exit(0);

View File

@@ -962,7 +962,7 @@ GHOST_TSuccess GHOST_ContextWGL::initializeDrawingContext()
strcmp(renderer, "GDI Generic") == 0) && version[0] == '1' && version[2] == '1')
{
MessageBox(m_hWnd, "Your system does not use 3D hardware acceleration.\n"
"Blender requires a graphics driver with OpenGL 2.1 support.\n\n"
"Blender requires a graphics driver with OpenGL 3.3 support.\n\n"
"This may be caused by:\n"
"* A missing or faulty graphics driver installation.\n"
" Blender needs a graphics card driver to work correctly.\n"
@@ -973,8 +973,8 @@ GHOST_TSuccess GHOST_ContextWGL::initializeDrawingContext()
MB_OK | MB_ICONERROR);
exit(0);
}
else if (version[0] < '2' || (version[0] == '2' && version[2] < '1')) {
MessageBox(m_hWnd, "Blender requires a graphics driver with OpenGL 2.1 support.\n\n"
else if (version[0] < '3' || (version[0] == '3' && version[2] < '3')) {
MessageBox(m_hWnd, "Blender requires a graphics driver with OpenGL 3.3 support.\n\n"
"The program will now close.",
"Blender - Unsupported Graphics Driver!",
MB_OK | MB_ICONERROR);

View File

@@ -46,14 +46,6 @@
extern "C" WGLEWContext *wglewContext;
#endif
#ifndef GHOST_OPENGL_WGL_CONTEXT_FLAGS
# ifdef WITH_GPU_DEBUG
# define GHOST_OPENGL_WGL_CONTEXT_FLAGS WGL_CONTEXT_DEBUG_BIT_ARB
# else
# define GHOST_OPENGL_WGL_CONTEXT_FLAGS 0
# endif
#endif
#ifndef GHOST_OPENGL_WGL_RESET_NOTIFICATION_STRATEGY
#define GHOST_OPENGL_WGL_RESET_NOTIFICATION_STRATEGY 0
#endif

View File

@@ -1086,82 +1086,23 @@ GHOST_TSuccess GHOST_WindowCocoa::setOrder(GHOST_TWindowOrder order)
GHOST_Context *GHOST_WindowCocoa::newDrawingContext(GHOST_TDrawingContextType type)
{
if (type == GHOST_kDrawingContextTypeOpenGL) {
#if !defined(WITH_GL_EGL)
#if defined(WITH_GL_PROFILE_CORE)
GHOST_Context *context = new GHOST_ContextCGL(
m_wantStereoVisual,
m_wantNumOfAASamples,
m_window,
m_openGLView,
#if defined(WITH_GL_PROFILE_CORE)
GL_CONTEXT_CORE_PROFILE_BIT,
3, 2,
#else
0, // no profile bit
2, 1,
#endif
GHOST_OPENGL_CGL_CONTEXT_FLAGS,
GHOST_OPENGL_CGL_RESET_NOTIFICATION_STRATEGY);
#elif defined(WITH_GL_PROFILE_ES20)
GHOST_Context *context = new GHOST_ContextCGL(
m_wantStereoVisual,
m_wantNumOfAASamples,
m_window,
m_openGLView,
CGL_CONTEXT_ES2_PROFILE_BIT_EXT,
2, 0,
GHOST_OPENGL_CGL_CONTEXT_FLAGS,
GHOST_OPENGL_CGL_RESET_NOTIFICATION_STRATEGY);
#elif defined(WITH_GL_PROFILE_COMPAT)
GHOST_Context *context = new GHOST_ContextCGL(
m_wantStereoVisual,
m_wantNumOfAASamples,
m_window,
m_openGLView,
0, // profile bit
0, 0,
m_debug_context,
GHOST_OPENGL_CGL_RESET_NOTIFICATION_STRATEGY);
#else
# error
#endif
#else
#if defined(WITH_GL_PROFILE_CORE)
GHOST_Context *context = new GHOST_ContextEGL(
m_wantStereoVisual,
m_wantNumOfAASamples,
m_window,
m_openGLView,
EGL_CONTEXT_OPENGL_CORE_PROFILE_BIT,
3, 2,
GHOST_OPENGL_EGL_CONTEXT_FLAGS,
GHOST_OPENGL_EGL_RESET_NOTIFICATION_STRATEGY,
EGL_OPENGL_API);
#elif defined(WITH_GL_PROFILE_ES20)
GHOST_Context *context = new GHOST_ContextEGL(
m_wantStereoVisual,
m_wantNumOfAASamples,
m_window,
m_openGLView,
0, // profile bit
2, 0,
GHOST_OPENGL_EGL_CONTEXT_FLAGS,
GHOST_OPENGL_EGL_RESET_NOTIFICATION_STRATEGY,
EGL_OPENGL_ES_API);
#elif defined(WITH_GL_PROFILE_COMPAT)
GHOST_Context *context = new GHOST_ContextEGL(
m_wantStereoVisual,
m_wantNumOfAASamples,
m_window,
m_openGLView,
0, // profile bit
0, 0,
GHOST_OPENGL_EGL_CONTEXT_FLAGS,
GHOST_OPENGL_EGL_RESET_NOTIFICATION_STRATEGY,
EGL_OPENGL_API);
#else
# error
#endif
#endif
if (context->initializeDrawingContext())
return context;
else

View File

@@ -611,97 +611,37 @@ GHOST_TSuccess GHOST_WindowWin32::invalidate()
GHOST_Context *GHOST_WindowWin32::newDrawingContext(GHOST_TDrawingContextType type)
{
if (type == GHOST_kDrawingContextTypeOpenGL) {
#if !defined(WITH_GL_EGL)
const int profile_mask =
#if defined(WITH_GL_PROFILE_CORE)
GHOST_Context *context = new GHOST_ContextWGL(
m_wantStereoVisual,
m_wantAlphaBackground,
m_wantNumOfAASamples,
m_hWnd,
m_hDC,
WGL_CONTEXT_CORE_PROFILE_BIT_ARB,
3, 2,
GHOST_OPENGL_WGL_CONTEXT_FLAGS,
GHOST_OPENGL_WGL_RESET_NOTIFICATION_STRATEGY);
#elif defined(WITH_GL_PROFILE_ES20)
GHOST_Context *context = new GHOST_ContextWGL(
m_wantStereoVisual,
m_wantAlphaBackground,
m_wantNumOfAASamples,
m_hWnd,
m_hDC,
WGL_CONTEXT_ES2_PROFILE_BIT_EXT,
2, 0,
GHOST_OPENGL_WGL_CONTEXT_FLAGS,
GHOST_OPENGL_WGL_RESET_NOTIFICATION_STRATEGY);
WGL_CONTEXT_CORE_PROFILE_BIT_ARB;
#elif defined(WITH_GL_PROFILE_COMPAT)
WGL_CONTEXT_COMPATIBILITY_PROFILE_BIT_ARB;
#else
# error // must specify either core or compat at build time
#endif
GHOST_Context *context = new GHOST_ContextWGL(
m_wantStereoVisual,
m_wantAlphaBackground,
m_wantNumOfAASamples,
m_hWnd,
m_hDC,
#if 1
0, // profile bit
2, 1, // GL version requested
profile_mask,
#if 0
3, 3, // specific GL version requested
// AMD gives us exactly this version
// NVIDIA gives at least this version <-- desired behavior
#else
// switch to this for Blender 2.8 development
WGL_CONTEXT_COMPATIBILITY_PROFILE_BIT_ARB,
3, 2,
2, 1, // any GL version >= 2.1 (hopefully the latest)
// we check later to ensure it's >= 3.3 on Windows
// TODO(merwin): fix properly!
// 2.1 ignores the profile bit & is incompatible with core profile
// query version of initial dummy context, request that + profile + debug
#endif
(m_debug_context ? WGL_CONTEXT_DEBUG_BIT_ARB : 0),
GHOST_OPENGL_WGL_RESET_NOTIFICATION_STRATEGY);
#else
# error
#endif
#else
#if defined(WITH_GL_PROFILE_CORE)
GHOST_Context *context = new GHOST_ContextEGL(
m_wantStereoVisual,
m_wantNumOfAASamples,
m_hWnd,
m_hDC,
EGL_CONTEXT_OPENGL_CORE_PROFILE_BIT,
3, 2,
GHOST_OPENGL_EGL_CONTEXT_FLAGS,
GHOST_OPENGL_EGL_RESET_NOTIFICATION_STRATEGY,
EGL_OPENGL_API);
#elif defined(WITH_GL_PROFILE_ES20)
GHOST_Context *context = new GHOST_ContextEGL(
m_wantStereoVisual,
m_wantNumOfAASamples,
m_hWnd,
m_hDC,
0, // profile bit
2, 0,
GHOST_OPENGL_EGL_CONTEXT_FLAGS,
GHOST_OPENGL_EGL_RESET_NOTIFICATION_STRATEGY,
EGL_OPENGL_ES_API);
#elif defined(WITH_GL_PROFILE_COMPAT)
GHOST_Context *context = new GHOST_ContextEGL(
m_wantStereoVisual,
m_wantNumOfAASamples,
m_hWnd,
m_hDC,
#if 1
0, // profile bit
2, 1, // GL version requested
#else
// switch to this for Blender 2.8 development
EGL_CONTEXT_OPENGL_COMPATIBILITY_PROFILE_BIT,
3, 2,
#endif
GHOST_OPENGL_EGL_CONTEXT_FLAGS,
GHOST_OPENGL_EGL_RESET_NOTIFICATION_STRATEGY,
EGL_OPENGL_API);
#else
# error
#endif
#endif
if (context->initializeDrawingContext())
return context;
else

View File

@@ -1318,88 +1318,77 @@ GHOST_WindowX11::
GHOST_Context *GHOST_WindowX11::newDrawingContext(GHOST_TDrawingContextType type)
{
if (type == GHOST_kDrawingContextTypeOpenGL) {
#if !defined(WITH_GL_EGL)
// During development:
// try 4.x compatibility profile
// try 3.3 compatibility profile
// fall back to 3.0 if needed
//
// Final Blender 2.8:
// try 4.x core profile
// try 3.3 core profile
// no fallbacks
const int profile_mask =
#if defined(WITH_GL_PROFILE_CORE)
GHOST_Context *context = new GHOST_ContextGLX(
m_wantStereoVisual,
m_wantNumOfAASamples,
m_window,
m_display,
m_visualInfo,
(GLXFBConfig)m_fbconfig,
GLX_CONTEXT_CORE_PROFILE_BIT_ARB,
3, 2,
GHOST_OPENGL_GLX_CONTEXT_FLAGS | (m_is_debug_context ? GLX_CONTEXT_DEBUG_BIT_ARB : 0),
GHOST_OPENGL_GLX_RESET_NOTIFICATION_STRATEGY);
#elif defined(WITH_GL_PROFILE_ES20)
GHOST_Context *context = new GHOST_ContextGLX(
m_wantStereoVisual,
m_wantNumOfAASamples,
m_window,
m_display,
m_visualInfo,
(GLXFBConfig)m_fbconfig,
GLX_CONTEXT_ES2_PROFILE_BIT_EXT,
2, 0,
GHOST_OPENGL_GLX_CONTEXT_FLAGS | (m_is_debug_context ? GLX_CONTEXT_DEBUG_BIT_ARB : 0),
GHOST_OPENGL_GLX_RESET_NOTIFICATION_STRATEGY);
GLX_CONTEXT_CORE_PROFILE_BIT_ARB;
#elif defined(WITH_GL_PROFILE_COMPAT)
GHOST_Context *context = new GHOST_ContextGLX(
GLX_CONTEXT_COMPATIBILITY_PROFILE_BIT_ARB;
#else
# error // must specify either core or compat at build time
#endif
GHOST_Context *context;
for (int minor = 5; minor >= 0; --minor) {
context = new GHOST_ContextGLX(
m_wantStereoVisual,
m_wantNumOfAASamples,
m_window,
m_display,
m_visualInfo,
(GLXFBConfig)m_fbconfig,
profile_mask,
4, minor,
GHOST_OPENGL_GLX_CONTEXT_FLAGS | (m_is_debug_context ? GLX_CONTEXT_DEBUG_BIT_ARB : 0),
GHOST_OPENGL_GLX_RESET_NOTIFICATION_STRATEGY);
if (context->initializeDrawingContext())
return context;
else
delete context;
}
context = new GHOST_ContextGLX(
m_wantStereoVisual,
m_wantNumOfAASamples,
m_window,
m_display,
m_visualInfo,
(GLXFBConfig)m_fbconfig,
0, // profile bit
0, 0,
profile_mask,
3, 3,
GHOST_OPENGL_GLX_CONTEXT_FLAGS | (m_is_debug_context ? GLX_CONTEXT_DEBUG_BIT_ARB : 0),
GHOST_OPENGL_GLX_RESET_NOTIFICATION_STRATEGY);
#else
# error
#endif
#else
if (context->initializeDrawingContext())
return context;
else
delete context;
#if defined(WITH_GL_PROFILE_CORE)
GHOST_Context *context = new GHOST_ContextEGL(
// since that failed try 3.0 (mostly for Mesa, which doesn't implement compatibility profile)
context = new GHOST_ContextGLX(
m_wantStereoVisual,
m_wantNumOfAASamples,
m_window,
m_display,
EGL_CONTEXT_OPENGL_CORE_PROFILE_BIT,
3, 2,
GHOST_OPENGL_EGL_CONTEXT_FLAGS,
GHOST_OPENGL_EGL_RESET_NOTIFICATION_STRATEGY,
EGL_OPENGL_API);
#elif defined(WITH_GL_PROFILE_ES20)
GHOST_Context *context = new GHOST_ContextEGL(
m_wantStereoVisual,
m_wantNumOfAASamples,
m_window,
m_display,
0, // profile bit
2, 0,
GHOST_OPENGL_EGL_CONTEXT_FLAGS,
GHOST_OPENGL_EGL_RESET_NOTIFICATION_STRATEGY,
EGL_OPENGL_ES_API);
#elif defined(WITH_GL_PROFILE_COMPAT)
GHOST_Context *context = new GHOST_ContextEGL(
m_wantStereoVisual,
m_wantNumOfAASamples,
m_window,
m_display,
0, // profile bit
0, 0,
GHOST_OPENGL_EGL_CONTEXT_FLAGS,
GHOST_OPENGL_EGL_RESET_NOTIFICATION_STRATEGY,
EGL_OPENGL_API);
#else
# error
#endif
m_visualInfo,
(GLXFBConfig)m_fbconfig,
0, // no profile bit
3, 0,
GHOST_OPENGL_GLX_CONTEXT_FLAGS | (m_is_debug_context ? GLX_CONTEXT_DEBUG_BIT_ARB : 0),
GHOST_OPENGL_GLX_RESET_NOTIFICATION_STRATEGY);
#endif
if (context->initializeDrawingContext())
return context;
else

View File

@@ -203,7 +203,6 @@ target_link_libraries(gears_c
glewmx_lib
string_lib
${OPENGL_gl_LIBRARY}
${OPENGL_glu_LIBRARY}
${PLATFORM_LINKLIBS}
)
@@ -217,7 +216,6 @@ target_link_libraries(gears_cpp
glewmx_lib
string_lib
${OPENGL_gl_LIBRARY}
${OPENGL_glu_LIBRARY}
${PLATFORM_LINKLIBS}
)
@@ -248,7 +246,6 @@ target_link_libraries(multitest_c
guardedalloc_lib
wcwidth_lib
${OPENGL_gl_LIBRARY}
${OPENGL_glu_LIBRARY}
${FREETYPE_LIBRARY}
${ZLIB_LIBRARIES}
${PLATFORM_LINKLIBS}

View File

@@ -66,6 +66,7 @@ if(WITH_OPENCOLORIO)
endif()
data_to_c_simple(gpu_shader_display_transform.glsl SRC)
data_to_c_simple(gpu_shader_display_transform_vertex.glsl SRC)
endif()

View File

@@ -10,6 +10,15 @@ uniform float image_texture_width;
uniform float image_texture_height;
#endif
#if __VERSION__ < 130
varying vec2 texCoord_interp;
#define fragColor gl_FragColor
#else
in vec2 texCoord_interp;
out vec4 fragColor;
#define texture2D texture
#endif
#ifdef USE_CURVE_MAPPING
/* Curve mapping parameters
*
@@ -143,7 +152,7 @@ vec4 apply_dither(vec2 st, vec4 col)
void main()
{
vec4 col = texture2D(image_texture, gl_TexCoord[0].st);
vec4 col = texture2D(image_texture, texCoord_interp.st);
#ifdef USE_CURVE_MAPPING
col = curvemapping_evaluate_premulRGBF(col);
#endif
@@ -165,8 +174,8 @@ void main()
vec4 result = OCIODisplay(col, lut3d_texture);
#ifdef USE_DITHER
result = apply_dither(gl_TexCoord[0].st, result);
result = apply_dither(texCoord_interp.st, result);
#endif
gl_FragColor = result;
fragColor = result;
}

View File

@@ -0,0 +1,18 @@
uniform mat4 ModelViewProjectionMatrix;
#if __VERSION__ == 120
attribute vec2 texCoord;
attribute vec2 pos;
varying vec2 texCoord_interp;
#else
in vec2 texCoord;
in vec2 pos;
out vec2 texCoord_interp;
#endif
void main()
{
gl_Position = ModelViewProjectionMatrix * vec4(pos.xy, 0.0f, 1.0f);
texCoord_interp = texCoord;
}

View File

@@ -58,6 +58,7 @@ using namespace OCIO_NAMESPACE;
static const int LUT3D_EDGE_SIZE = 64;
extern "C" char datatoc_gpu_shader_display_transform_glsl[];
extern "C" char datatoc_gpu_shader_display_transform_vertex_glsl[];
/* **** OpenGL drawing routines using GLSL for color space transform ***** */
@@ -89,6 +90,7 @@ typedef struct OCIO_GLSLDrawState {
/* GLSL stuff */
GLuint ocio_shader;
GLuint vert_shader;
GLuint program;
/* Previous OpenGL state. */
@@ -116,14 +118,15 @@ static GLuint compileShaderText(GLenum shaderType, const char *text)
return shader;
}
static GLuint linkShaders(GLuint ocio_shader)
static GLuint linkShaders(GLuint ocio_shader, GLuint vert_shader)
{
if (!ocio_shader)
if (!ocio_shader || !vert_shader)
return 0;
GLuint program = glCreateProgram();
glAttachShader(program, ocio_shader);
glAttachShader(program, vert_shader);
glLinkProgram(program);
@@ -339,6 +342,25 @@ bool OCIOImpl::setupGLSLDraw(OCIO_GLSLDrawState **state_r, OCIO_ConstProcessorRc
glDeleteShader(state->ocio_shader);
}
if (state->vert_shader) {
glDeleteShader(state->vert_shader);
}
/* Vertex shader */
std::ostringstream osv;
if (supportGLSL13()) {
osv << "#version 130\n";
}
else {
osv << "#version 120\n";
}
osv << datatoc_gpu_shader_display_transform_vertex_glsl;
state->vert_shader = compileShaderText(GL_VERTEX_SHADER, osv.str().c_str());
/* Fragment shader */
std::ostringstream os;
if (supportGLSL13()) {
@@ -366,8 +388,8 @@ bool OCIOImpl::setupGLSLDraw(OCIO_GLSLDrawState **state_r, OCIO_ConstProcessorRc
state->ocio_shader = compileShaderText(GL_FRAGMENT_SHADER, os.str().c_str());
if (state->ocio_shader) {
state->program = linkShaders(state->ocio_shader);
if (state->ocio_shader && state->vert_shader) {
state->program = linkShaders(state->ocio_shader, state->vert_shader);
}
state->curve_mapping_used = use_curve_mapping;

View File

@@ -90,7 +90,7 @@ if NOT "%1" == "" (
) else if "%1" == "update" (
svn up ../lib/*
git pull --rebase
git submodule foreach git pull --rebase origin master
git submodule update --remote
goto EOF
) else if "%1" == "clean" (
set MUST_CLEAN=1

View File

@@ -2,6 +2,8 @@
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>LSMinimumSystemVersion</key>
<string>10.9.0</string>
<key>CFBundleDocumentTypes</key>
<array>
<dict>
@@ -47,5 +49,7 @@
<string>NSApplication</string>
<key>NSHighResolutionCapable</key>
<true/>
<key>NSSupportsAutomaticGraphicsSwitching</key>
<true/>
</dict>
</plist>

View File

@@ -103,9 +103,9 @@ def add_object_align_init(context, operator):
return location * rotation
def object_data_add(context, obdata, operator=None, use_active_layer=True, name=None):
def object_data_add(context, obdata, operator=None, name=None):
"""
Add an object using the view context and preference to to initialize the
Add an object using the view context and preference to initialize the
location, rotation and layer.
:arg context: The context to use.
@@ -117,52 +117,31 @@ def object_data_add(context, obdata, operator=None, use_active_layer=True, name=
:arg name: Optional name
:type name: string
:return: the newly created object in the scene.
:rtype: :class:`bpy.types.ObjectBase`
:rtype: :class:`bpy.types.Object`
"""
scene = context.scene
layer = context.render_layer
layer_collection = context.layer_collection
# ugh, could be made nicer
for ob in scene.objects:
ob.select = False
if not layer_collection:
# when there is no collection linked to this render_layer create one
scene_collection = scene.master_collection.collections.new("")
layer_collection = layer.collections.link(scene_collection)
else:
scene_collection = layer_collection.collection
bpy.ops.object.select_all(action='DESELECT')
if name is None:
name = "Object" if obdata is None else obdata.name
obj_new = bpy.data.objects.new(name, obdata)
base = scene.objects.link(obj_new)
base.select = True
v3d = None
if context.space_data and context.space_data.type == 'VIEW_3D':
v3d = context.space_data
if v3d and v3d.local_view:
base.layers_from_view(context.space_data)
if operator is not None and any(operator.layers):
base.layers = operator.layers
else:
if use_active_layer:
if v3d and v3d.local_view:
base.layers[scene.active_layer] = True
else:
if v3d and not v3d.lock_camera_and_layers:
base.layers = [True if i == v3d.active_layer
else False for i in range(len(v3d.layers))]
else:
base.layers = [True if i == scene.active_layer
else False for i in range(len(scene.layers))]
else:
if v3d:
base.layers_from_view(context.space_data)
if operator is not None:
operator.layers = base.layers
scene_collection.objects.link(obj_new)
obj_new.select_set(action='SELECT')
obj_new.matrix_world = add_object_align_init(context, operator)
obj_act = scene.objects.active
obj_act = layer.objects.active
# XXX
# caused because entering edit-mode does not add a empty undo slot!
@@ -174,8 +153,8 @@ def object_data_add(context, obdata, operator=None, use_active_layer=True, name=
_obdata = bpy.data.meshes.new(name)
obj_act = bpy.data.objects.new(_obdata.name, _obdata)
obj_act.matrix_world = obj_new.matrix_world
scene.objects.link(obj_act)
scene.objects.active = obj_act
scene_collection.objects.link(obj_act)
layer.objects.active = obj_act
bpy.ops.object.mode_set(mode='EDIT')
# need empty undo step
bpy.ops.ed.undo_push(message="Enter Editmode")
@@ -185,7 +164,7 @@ def object_data_add(context, obdata, operator=None, use_active_layer=True, name=
bpy.ops.mesh.select_all(action='DESELECT')
bpy.ops.object.mode_set(mode='OBJECT')
obj_act.select = True
obj_act.select_set(action='SELECT')
scene.update() # apply location
# scene.objects.active = obj_new
@@ -200,16 +179,14 @@ def object_data_add(context, obdata, operator=None, use_active_layer=True, name=
bpy.ops.object.join() # join into the active.
if obdata:
bpy.data.meshes.remove(obdata)
# base is freed, set to active object
base = scene.object_bases.active
bpy.ops.object.mode_set(mode='EDIT')
else:
scene.objects.active = obj_new
layer.objects.active = obj_new
if context.user_preferences.edit.use_enter_edit_mode:
bpy.ops.object.mode_set(mode='EDIT')
return base
return obj_new
class AddObjectHelper:
@@ -230,12 +207,6 @@ class AddObjectHelper:
name="Rotation",
subtype='EULER',
)
layers = BoolVectorProperty(
name="Layers",
size=20,
subtype='LAYER',
options={'HIDDEN', 'SKIP_SAVE'},
)
@classmethod
def poll(self, context):

View File

@@ -7,7 +7,7 @@ kc = wm.keyconfigs.new('3dsmax')
# Map Window
km = kc.keymaps.new('Window', space_type='EMPTY', region_type='WINDOW', modal=False)
kmi = km.keymap_items.new('wm.window_duplicate', 'W', 'PRESS', ctrl=True, alt=True)
kmi = km.keymap_items.new('wm.window_new', 'W', 'PRESS', ctrl=True, alt=True)
kmi = km.keymap_items.new('wm.read_homefile', 'N', 'PRESS', ctrl=True)
kmi = km.keymap_items.new('wm.save_homefile', 'U', 'PRESS', ctrl=True)
kmi = km.keymap_items.new('wm.call_menu', 'O', 'PRESS', shift=True, ctrl=True)
@@ -330,7 +330,6 @@ kmi = km.keymap_items.new('object.hide_view_set', 'H', 'PRESS', shift=True)
kmi.properties.unselected = True
kmi = km.keymap_items.new('object.hide_render_clear', 'H', 'PRESS', ctrl=True, alt=True)
kmi = km.keymap_items.new('object.hide_render_set', 'H', 'PRESS', ctrl=True)
kmi = km.keymap_items.new('object.move_to_layer', 'M', 'PRESS')
kmi = km.keymap_items.new('object.delete', 'X', 'PRESS')
kmi.properties.use_global = False
kmi = km.keymap_items.new('object.delete', 'X', 'PRESS', shift=True)

View File

@@ -8,7 +8,7 @@ kc = wm.keyconfigs.new(os.path.splitext(os.path.basename(__file__))[0])
# Map Window
km = kc.keymaps.new('Window', space_type='EMPTY', region_type='WINDOW', modal=False)
kmi = km.keymap_items.new('wm.window_duplicate', 'W', 'PRESS', ctrl=True, alt=True)
kmi = km.keymap_items.new('wm.window_new', 'W', 'PRESS', ctrl=True, alt=True)
kmi = km.keymap_items.new('wm.read_homefile', 'N', 'PRESS', ctrl=True)
kmi = km.keymap_items.new('wm.save_homefile', 'U', 'PRESS', ctrl=True)
kmi = km.keymap_items.new('wm.call_menu', 'O', 'PRESS', shift=True, ctrl=True)
@@ -384,7 +384,6 @@ kmi = km.keymap_items.new('object.hide_view_clear', 'H', 'PRESS', shift=True, ct
kmi = km.keymap_items.new('object.hide_view_set', 'H', 'PRESS', ctrl=True)
kmi = km.keymap_items.new('object.hide_view_set', 'H', 'PRESS', alt=True)
kmi.properties.unselected = True
kmi = km.keymap_items.new('object.move_to_layer', 'M', 'PRESS')
kmi = km.keymap_items.new('object.delete', 'BACK_SPACE', 'PRESS')
kmi = km.keymap_items.new('object.delete', 'DEL', 'PRESS')
kmi = km.keymap_items.new('wm.call_menu', 'A', 'PRESS', shift=True)

View File

@@ -235,7 +235,7 @@ class CLIP_OT_track_to_empty(Operator):
ob = None
ob = bpy.data.objects.new(name=track.name, object_data=None)
ob.select = True
ob.select_set(action='SELECT')
context.scene.objects.link(ob)
context.scene.objects.active = ob
@@ -509,7 +509,7 @@ object's movement caused by this constraint"""
# XXX, should probably use context.selected_editable_objects
# since selected objects can be from a lib or in hidden layer!
for ob in scene.objects:
if ob.select:
if ob.select_set(action='SELECT'):
self._bake_object(scene, ob)
return {'FINISHED'}

View File

@@ -104,7 +104,7 @@ class SCENE_OT_freestyle_fill_range_by_selection(bpy.types.Operator):
m.range_max = max_dist
return {'FINISHED'}
# Find selected mesh objects
selection = [ob for ob in scene.objects if ob.select and ob.type == 'MESH' and ob.name != ref.name]
selection = [ob for ob in scene.objects if ob.select_get() and ob.type == 'MESH' and ob.name != source.name]
if selection:
# Compute the min/max distance from the reference to mesh vertices
min_dist = sys.float_info.max

View File

@@ -81,16 +81,18 @@ class SelectPattern(Operator):
# Can be pose bones or objects
for item in items:
if pattern_match(item.name, self.pattern):
item.select = True
# hrmf, perhaps there should be a utility function for this.
if is_ebone:
item.select = True
item.select_head = True
item.select_tail = True
if item.use_connect:
item_parent = item.parent
if item_parent is not None:
item_parent.select_tail = True
else:
item.select_set(action='SELECT')
return {'FINISHED'}
@@ -136,7 +138,7 @@ class SelectCamera(Operator):
bpy.ops.object.select_all(action='DESELECT')
scene.objects.active = camera
camera.hide = False
camera.select = True
camera.select_set(action='SELECT')
return {'FINISHED'}
return {'CANCELLED'}
@@ -202,7 +204,7 @@ class SelectHierarchy(Operator):
bpy.ops.object.select_all(action='DESELECT')
for obj in select_new:
obj.select = True
obj.select_set(action='SELECT')
scene.objects.active = act_new
return {'FINISHED'}
@@ -644,8 +646,8 @@ class MakeDupliFace(Operator):
ob_new.use_dupli_faces_scale = True
ob_new.dupli_faces_scale = 1.0 / SCALE_FAC
ob_inst.select = True
ob_new.select = True
ob_inst.select_set(action='SELECT')
ob_new.select_set(action='SELECT')
def execute(self, context):
self._main(context)
@@ -664,7 +666,7 @@ class IsolateTypeRender(Operator):
for obj in context.visible_objects:
if obj.select:
if obj.select_get():
obj.hide_render = False
else:
if obj.type == act_type:
@@ -1029,8 +1031,8 @@ class LodGenerate(Operator):
for level in ob.lod_levels[1:]:
level.object.hide = level.object.hide_render = True
lod.select = False
ob.select = True
lod.select_set(action='DESELECT')
ob.select_set(action='SELECT')
scene.objects.active = ob
return {'FINISHED'}

View File

@@ -65,7 +65,7 @@ class CopyRigidbodySettings(Operator):
# deselect all but mesh objects
for o in context.selected_objects:
if o.type != 'MESH':
o.select = False
o.select_set(action='DESELECT')
elif o.rigid_body is None:
# Add rigidbody to object!
scene.objects.active = o
@@ -127,7 +127,7 @@ class BakeToKeyframes(Operator):
# filter objects selection
for obj in context.selected_objects:
if not obj.rigid_body or obj.rigid_body.type != 'ACTIVE':
obj.select = False
obj.select_set(action='DESELECT')
objects = context.selected_objects
@@ -260,7 +260,7 @@ class ConnectRigidBodies(Operator):
ob.location = loc
context.scene.objects.link(ob)
context.scene.objects.active = ob
ob.select = True
ob.select_set(action='SELECT')
bpy.ops.rigidbody.constraint_add()
con_obj = context.active_object
@@ -305,7 +305,7 @@ class ConnectRigidBodies(Operator):
# restore selection
bpy.ops.object.select_all(action='DESELECT')
for obj in objects:
obj.select = True
obj.select_set(action='SELECT')
scene.objects.active = obj_act
return {'FINISHED'}
else:

View File

@@ -28,6 +28,7 @@ if "bpy" in locals():
_modules = [
"properties_animviz",
"properties_collection",
"properties_constraint",
"properties_data_armature",
"properties_data_bone",

View File

@@ -0,0 +1,125 @@
# ##### 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 #####
# <pep8 compliant>
import bpy
from bpy.types import Panel
class CollectionButtonsPanel:
bl_space_type = 'PROPERTIES'
bl_region_type = 'WINDOW'
bl_context = "collection"
class COLLECTION_PT_context_collection(CollectionButtonsPanel, Panel):
bl_label = ""
bl_options = {'HIDE_HEADER'}
def draw(self, context):
layout = self.layout
space = context.space_data
collection = context.layer_collection
name = collection.name
if name == 'Master Collection':
layout.label(text=name, icon='COLLAPSEMENU')
else:
layout.prop(collection, "name", text="", icon='COLLAPSEMENU')
class COLLECTION_PT_clay_settings(CollectionButtonsPanel, Panel):
bl_label = "Render Settings"
COMPAT_ENGINES = {'BLENDER_CLAY'}
@classmethod
def poll(cls, context):
scene = context.scene
return scene and (scene.render.engine in cls.COMPAT_ENGINES)
def draw(self, context):
layout = self.layout
scene_props = context.scene.collection_properties['BLENDER_CLAY']
collection = context.layer_collection
collection_props = collection.engine_overrides['BLENDER_CLAY']
col = layout.column()
col.template_override_property(collection_props, scene_props, "matcap_icon", custom_template="icon_view")
col.template_override_property(collection_props, scene_props, "matcap_rotation")
col.template_override_property(collection_props, scene_props, "matcap_hue")
col.template_override_property(collection_props, scene_props, "matcap_saturation")
col.template_override_property(collection_props, scene_props, "matcap_value")
col.template_override_property(collection_props, scene_props, "ssao_factor_cavity")
col.template_override_property(collection_props, scene_props, "ssao_factor_edge")
col.template_override_property(collection_props, scene_props, "ssao_distance")
col.template_override_property(collection_props, scene_props, "ssao_attenuation")
class COLLECTION_PT_object_mode_settings(CollectionButtonsPanel, Panel):
bl_label = "Object Mode Settings"
@classmethod
def poll(cls, context):
ob = context.object
return ob and (ob.mode == 'OBJECT')
def draw(self, context):
layout = self.layout
scene_props = context.scene.collection_properties['ObjectMode']
collection = context.layer_collection
collection_props = collection.engine_overrides['ObjectMode']
col = layout.column()
col.template_override_property(collection_props, scene_props, "show_wire")
col.template_override_property(collection_props, scene_props, "show_backface_culling")
class COLLECTION_PT_edit_mode_settings(CollectionButtonsPanel, Panel):
bl_label = "Edit Mode Settings"
@classmethod
def poll(cls, context):
ob = context.object
return ob and (ob.mode == 'EDIT')
def draw(self, context):
layout = self.layout
scene_props = context.scene.collection_properties['EditMode']
collection = context.layer_collection
collection_props = collection.engine_overrides['EditMode']
col = layout.column()
col.template_override_property(collection_props, scene_props, "show_occlude_wire")
col.template_override_property(collection_props, scene_props, "backwire_opacity")
col.template_override_property(collection_props, scene_props, "face_normals_show")
col.template_override_property(collection_props, scene_props, "vert_normals_show")
col.template_override_property(collection_props, scene_props, "loop_normals_show")
col.template_override_property(collection_props, scene_props, "normals_length")
classes = (
COLLECTION_PT_context_collection,
COLLECTION_PT_clay_settings,
COLLECTION_PT_object_mode_settings,
COLLECTION_PT_edit_mode_settings,
)
if __name__ == "__main__": # only for live edit.
from bpy.utils import register_class
for cls in classes:
register_class(cls)

View File

@@ -37,7 +37,7 @@ class CAMERA_MT_presets(Menu):
bl_label = "Camera Presets"
preset_subdir = "camera"
preset_operator = "script.execute_preset"
COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_GAME'}
COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_GAME', 'BLENDER_CLAY'}
draw = Menu.draw_preset
@@ -45,14 +45,14 @@ class SAFE_AREAS_MT_presets(Menu):
bl_label = "Camera Presets"
preset_subdir = "safe_areas"
preset_operator = "script.execute_preset"
COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_GAME'}
COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_GAME', 'BLENDER_CLAY'}
draw = Menu.draw_preset
class DATA_PT_context_camera(CameraButtonsPanel, Panel):
bl_label = ""
bl_options = {'HIDE_HEADER'}
COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_GAME'}
COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_GAME', 'BLENDER_CLAY'}
def draw(self, context):
layout = self.layout
@@ -72,7 +72,7 @@ class DATA_PT_context_camera(CameraButtonsPanel, Panel):
class DATA_PT_lens(CameraButtonsPanel, Panel):
bl_label = "Lens"
COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_GAME'}
COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_GAME', 'BLENDER_CLAY'}
def draw(self, context):
layout = self.layout
@@ -183,7 +183,7 @@ class DATA_PT_camera_stereoscopy(CameraButtonsPanel, Panel):
class DATA_PT_camera(CameraButtonsPanel, Panel):
bl_label = "Camera"
COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_GAME'}
COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_GAME', 'BLENDER_CLAY'}
def draw(self, context):
layout = self.layout
@@ -217,7 +217,7 @@ class DATA_PT_camera(CameraButtonsPanel, Panel):
class DATA_PT_camera_dof(CameraButtonsPanel, Panel):
bl_label = "Depth of Field"
COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_GAME'}
COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_GAME', 'BLENDER_CLAY'}
def draw(self, context):
layout = self.layout
@@ -247,7 +247,7 @@ class DATA_PT_camera_dof(CameraButtonsPanel, Panel):
class DATA_PT_camera_display(CameraButtonsPanel, Panel):
bl_label = "Display"
COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_GAME'}
COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_GAME', 'BLENDER_CLAY'}
def draw(self, context):
layout = self.layout
@@ -277,7 +277,7 @@ class DATA_PT_camera_display(CameraButtonsPanel, Panel):
class DATA_PT_camera_safe_areas(CameraButtonsPanel, Panel):
bl_label = "Safe Areas"
bl_options = {'DEFAULT_CLOSED'}
COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_GAME'}
COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_GAME', 'BLENDER_CLAY'}
def draw_header(self, context):
cam = context.camera
@@ -293,7 +293,7 @@ class DATA_PT_camera_safe_areas(CameraButtonsPanel, Panel):
class DATA_PT_custom_props_camera(CameraButtonsPanel, PropertyPanel, Panel):
COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_GAME'}
COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_GAME', 'BLENDER_CLAY'}
_context_path = "object.data"
_property_type = bpy.types.Camera

View File

@@ -26,7 +26,7 @@ class LAMP_MT_sunsky_presets(Menu):
bl_label = "Sun & Sky Presets"
preset_subdir = "sunsky"
preset_operator = "script.execute_preset"
COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_GAME'}
COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_GAME', 'BLENDER_CLAY', 'BLENDER_EEVEE'}
draw = Menu.draw_preset
@@ -44,7 +44,7 @@ class DataButtonsPanel:
class DATA_PT_context_lamp(DataButtonsPanel, Panel):
bl_label = ""
bl_options = {'HIDE_HEADER'}
COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_GAME'}
COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_GAME', 'BLENDER_CLAY', 'BLENDER_EEVEE'}
def draw(self, context):
layout = self.layout
@@ -68,7 +68,7 @@ class DATA_PT_context_lamp(DataButtonsPanel, Panel):
class DATA_PT_preview(DataButtonsPanel, Panel):
bl_label = "Preview"
COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_GAME'}
COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_GAME', 'BLENDER_CLAY', 'BLENDER_EEVEE'}
def draw(self, context):
self.layout.template_preview(context.lamp)
@@ -76,7 +76,7 @@ class DATA_PT_preview(DataButtonsPanel, Panel):
class DATA_PT_lamp(DataButtonsPanel, Panel):
bl_label = "Lamp"
COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_GAME'}
COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_GAME', 'BLENDER_CLAY', 'BLENDER_EEVEE'}
def draw(self, context):
layout = self.layout
@@ -96,6 +96,7 @@ class DATA_PT_lamp(DataButtonsPanel, Panel):
sub.label(text="Falloff:")
sub.prop(lamp, "falloff_type", text="")
sub.prop(lamp, "distance")
sub.prop(lamp, "shadow_soft_size", text="Radius")
if lamp.falloff_type == 'LINEAR_QUADRATIC_WEIGHTED':
col.label(text="Attenuation Factors:")
@@ -312,7 +313,7 @@ class DATA_PT_shadow(DataButtonsPanel, Panel):
class DATA_PT_area(DataButtonsPanel, Panel):
bl_label = "Area Shape"
COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_GAME'}
COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_GAME', 'BLENDER_CLAY', 'BLENDER_EEVEE'}
@classmethod
def poll(cls, context):
@@ -338,7 +339,7 @@ class DATA_PT_area(DataButtonsPanel, Panel):
class DATA_PT_spot(DataButtonsPanel, Panel):
bl_label = "Spot Shape"
COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_GAME'}
COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_GAME', 'BLENDER_CLAY', 'BLENDER_EEVEE'}
@classmethod
def poll(cls, context):
@@ -374,7 +375,7 @@ class DATA_PT_spot(DataButtonsPanel, Panel):
class DATA_PT_falloff_curve(DataButtonsPanel, Panel):
bl_label = "Falloff Curve"
bl_options = {'DEFAULT_CLOSED'}
COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_GAME'}
COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_GAME', 'BLENDER_CLAY', 'BLENDER_EEVEE'}
@classmethod
def poll(cls, context):
@@ -390,7 +391,7 @@ class DATA_PT_falloff_curve(DataButtonsPanel, Panel):
class DATA_PT_custom_props_lamp(DataButtonsPanel, PropertyPanel, Panel):
COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_GAME'}
COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_GAME', 'BLENDER_CLAY', 'BLENDER_EEVEE'}
_context_path = "object.data"
_property_type = bpy.types.Lamp

View File

@@ -24,7 +24,7 @@ from rna_prop_ui import PropertyPanel
class MESH_MT_vertex_group_specials(Menu):
bl_label = "Vertex Group Specials"
COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_GAME'}
COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_GAME', 'BLENDER_CLAY'}
def draw(self, context):
layout = self.layout
@@ -48,7 +48,7 @@ class MESH_MT_vertex_group_specials(Menu):
class MESH_MT_shape_key_specials(Menu):
bl_label = "Shape Key Specials"
COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_GAME'}
COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_GAME', 'BLENDER_CLAY'}
def draw(self, context):
layout = self.layout
@@ -126,7 +126,7 @@ class MeshButtonsPanel:
class DATA_PT_context_mesh(MeshButtonsPanel, Panel):
bl_label = ""
bl_options = {'HIDE_HEADER'}
COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_GAME'}
COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_GAME', 'BLENDER_CLAY'}
def draw(self, context):
layout = self.layout
@@ -143,7 +143,7 @@ class DATA_PT_context_mesh(MeshButtonsPanel, Panel):
class DATA_PT_normals(MeshButtonsPanel, Panel):
bl_label = "Normals"
COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_GAME'}
COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_GAME', 'BLENDER_CLAY'}
def draw(self, context):
layout = self.layout
@@ -164,7 +164,7 @@ class DATA_PT_normals(MeshButtonsPanel, Panel):
class DATA_PT_texture_space(MeshButtonsPanel, Panel):
bl_label = "Texture Space"
bl_options = {'DEFAULT_CLOSED'}
COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_GAME'}
COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_GAME', 'BLENDER_CLAY'}
def draw(self, context):
layout = self.layout
@@ -183,7 +183,7 @@ class DATA_PT_texture_space(MeshButtonsPanel, Panel):
class DATA_PT_vertex_groups(MeshButtonsPanel, Panel):
bl_label = "Vertex Groups"
COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_GAME'}
COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_GAME', 'BLENDER_CLAY'}
@classmethod
def poll(cls, context):
@@ -229,7 +229,7 @@ class DATA_PT_vertex_groups(MeshButtonsPanel, Panel):
class DATA_PT_shape_keys(MeshButtonsPanel, Panel):
bl_label = "Shape Keys"
COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_GAME'}
COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_GAME', 'BLENDER_CLAY'}
@classmethod
def poll(cls, context):
@@ -322,7 +322,7 @@ class DATA_PT_shape_keys(MeshButtonsPanel, Panel):
class DATA_PT_uv_texture(MeshButtonsPanel, Panel):
bl_label = "UV Maps"
COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_GAME'}
COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_GAME', 'BLENDER_CLAY'}
def draw(self, context):
layout = self.layout
@@ -341,7 +341,7 @@ class DATA_PT_uv_texture(MeshButtonsPanel, Panel):
class DATA_PT_vertex_colors(MeshButtonsPanel, Panel):
bl_label = "Vertex Colors"
COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_GAME'}
COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_GAME', 'BLENDER_CLAY'}
def draw(self, context):
layout = self.layout
@@ -361,7 +361,7 @@ class DATA_PT_vertex_colors(MeshButtonsPanel, Panel):
class DATA_PT_customdata(MeshButtonsPanel, Panel):
bl_label = "Geometry Data"
bl_options = {'DEFAULT_CLOSED'}
COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_GAME'}
COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_GAME', 'BLENDER_CLAY'}
def draw(self, context):
layout = self.layout
@@ -387,7 +387,7 @@ class DATA_PT_customdata(MeshButtonsPanel, Panel):
class DATA_PT_custom_props_mesh(MeshButtonsPanel, PropertyPanel, Panel):
COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_GAME'}
COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_GAME', 'BLENDER_CLAY'}
_context_path = "object.data"
_property_type = bpy.types.Mesh

View File

@@ -64,6 +64,8 @@ class PHYSICS_PT_cloth(PhysicButtonsPanel, Panel):
split = layout.split(percentage=0.25)
col = split.column()
split.label(text="Presets:")
sub = split.row(align=True)
sub.menu("CLOTH_MT_presets", text=bpy.types.CLOTH_MT_presets.bl_label)

View File

@@ -584,6 +584,26 @@ class RENDER_PT_bake(RenderButtonsPanel, Panel):
sub.prop(rd, "bake_user_scale", text="User Scale")
class RENDER_PT_clay_collection_settings(RenderButtonsPanel, Panel):
bl_label = "Clay Collection Settings"
COMPAT_ENGINES = {'BLENDER_CLAY'}
def draw(self, context):
layout = self.layout
props = context.scene.collection_properties['BLENDER_CLAY']
col = layout.column()
col.template_icon_view(props, "matcap_icon")
col.prop(props, "matcap_rotation")
col.prop(props, "matcap_hue")
col.prop(props, "matcap_saturation")
col.prop(props, "matcap_value")
col.prop(props, "ssao_factor_cavity")
col.prop(props, "ssao_factor_edge")
col.prop(props, "ssao_distance")
col.prop(props, "ssao_attenuation")
classes = (
RENDER_MT_presets,
RENDER_MT_ffmpeg_presets,
@@ -599,6 +619,7 @@ classes = (
RENDER_PT_output,
RENDER_PT_encoding,
RENDER_PT_bake,
RENDER_PT_clay_collection_settings,
)
if __name__ == "__main__": # only for live edit.

View File

@@ -35,7 +35,7 @@ class RenderLayerButtonsPanel:
class RENDERLAYER_UL_renderlayers(UIList):
def draw_item(self, context, layout, data, item, icon, active_data, active_propname, index):
# assert(isinstance(item, bpy.types.SceneRenderLayer)
# assert(isinstance(item, bpy.types.SceneLayer)
layer = item
if self.layout_type in {'DEFAULT', 'COMPACT'}:
layout.prop(layer, "name", text="", icon_value=icon, emboss=False)
@@ -48,7 +48,7 @@ class RENDERLAYER_UL_renderlayers(UIList):
class RENDERLAYER_PT_layers(RenderLayerButtonsPanel, Panel):
bl_label = "Layer List"
bl_options = {'HIDE_HEADER'}
COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_GAME'}
COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_GAME', 'BLENDER_CLAY'}
def draw(self, context):
layout = self.layout
@@ -62,7 +62,7 @@ class RENDERLAYER_PT_layers(RenderLayerButtonsPanel, Panel):
row = layout.row()
col = row.column()
col.template_list("RENDERLAYER_UL_renderlayers", "", rd, "layers", rd.layers, "active_index", rows=2)
col.template_list("RENDERLAYER_UL_renderlayers", "", scene, "render_layers", scene.render_layers, "active_index", rows=2)
col = row.column()
sub = col.column(align=True)
@@ -71,103 +71,6 @@ class RENDERLAYER_PT_layers(RenderLayerButtonsPanel, Panel):
col.prop(rd, "use_single_layer", icon_only=True)
class RENDERLAYER_PT_layer_options(RenderLayerButtonsPanel, Panel):
bl_label = "Layer"
COMPAT_ENGINES = {'BLENDER_RENDER'}
def draw(self, context):
layout = self.layout
scene = context.scene
rd = scene.render
rl = rd.layers.active
split = layout.split()
col = split.column()
col.prop(scene, "layers", text="Scene")
col.label(text="")
col.prop(rl, "light_override", text="Lights")
col.prop(rl, "material_override", text="Material")
col = split.column()
col.prop(rl, "layers", text="Layer")
col.prop(rl, "layers_zmask", text="Mask Layer")
layout.separator()
layout.label(text="Include:")
split = layout.split()
col = split.column()
col.prop(rl, "use_zmask")
row = col.row()
row.prop(rl, "invert_zmask", text="Negate")
row.active = rl.use_zmask
col.prop(rl, "use_all_z")
col = split.column()
col.prop(rl, "use_solid")
col.prop(rl, "use_halo")
col.prop(rl, "use_ztransp")
col = split.column()
col.prop(rl, "use_sky")
col.prop(rl, "use_edge_enhance")
col.prop(rl, "use_strand")
if bpy.app.build_options.freestyle:
row = col.row()
row.prop(rl, "use_freestyle")
row.active = rd.use_freestyle
class RENDERLAYER_PT_layer_passes(RenderLayerButtonsPanel, Panel):
bl_label = "Passes"
bl_options = {'DEFAULT_CLOSED'}
COMPAT_ENGINES = {'BLENDER_RENDER'}
@staticmethod
def draw_pass_type_buttons(box, rl, pass_type):
# property names
use_pass_type = "use_pass_" + pass_type
exclude_pass_type = "exclude_" + pass_type
# draw pass type buttons
row = box.row()
row.prop(rl, use_pass_type)
row.prop(rl, exclude_pass_type, text="")
def draw(self, context):
layout = self.layout
scene = context.scene
rd = scene.render
rl = rd.layers.active
split = layout.split()
col = split.column()
col.prop(rl, "use_pass_combined")
col.prop(rl, "use_pass_z")
col.prop(rl, "use_pass_vector")
col.prop(rl, "use_pass_normal")
col.prop(rl, "use_pass_uv")
col.prop(rl, "use_pass_mist")
col.prop(rl, "use_pass_object_index")
col.prop(rl, "use_pass_material_index")
col.prop(rl, "use_pass_color")
col = split.column()
col.prop(rl, "use_pass_diffuse")
self.draw_pass_type_buttons(col, rl, "specular")
self.draw_pass_type_buttons(col, rl, "shadow")
self.draw_pass_type_buttons(col, rl, "emit")
self.draw_pass_type_buttons(col, rl, "ambient_occlusion")
self.draw_pass_type_buttons(col, rl, "environment")
self.draw_pass_type_buttons(col, rl, "indirect")
self.draw_pass_type_buttons(col, rl, "reflection")
self.draw_pass_type_buttons(col, rl, "refraction")
class RENDERLAYER_UL_renderviews(UIList):
def draw_item(self, context, layout, data, item, icon, active_data, active_propname, index):
# assert(isinstance(item, bpy.types.SceneRenderView)
@@ -230,8 +133,6 @@ class RENDERLAYER_PT_views(RenderLayerButtonsPanel, Panel):
classes = (
RENDERLAYER_UL_renderlayers,
RENDERLAYER_PT_layers,
RENDERLAYER_PT_layer_options,
RENDERLAYER_PT_layer_passes,
RENDERLAYER_UL_renderviews,
RENDERLAYER_PT_views,
)

View File

@@ -40,7 +40,7 @@ class INFO_HT_header(Header):
layout.operator("screen.back_to_previous", icon='SCREEN_BACK', text="Back to Previous")
layout.separator()
else:
layout.template_ID(context.window, "screen", new="screen.new", unlink="screen.delete")
layout.template_ID_preview(context.window, "screen", new="screen.new", unlink="screen.delete", rows=2, cols=6)
layout.template_ID(context.screen, "scene", new="scene.new", unlink="scene.delete")
layout.separator()
@@ -293,7 +293,7 @@ class INFO_MT_window(Menu):
layout = self.layout
layout.operator("wm.window_duplicate")
layout.operator("wm.window_new")
layout.operator("wm.window_fullscreen_toggle", icon='FULLSCREEN_ENTER')
layout.separator()

View File

@@ -60,6 +60,16 @@ class OUTLINER_HT_header(Header):
elif space.display_mode == 'ORPHAN_DATA':
layout.operator("outliner.orphans_purge")
elif space.display_mode in {'ACT_LAYER', 'MASTER_COLLECTION'}:
row = layout.row(align=True)
row.operator("outliner.collection_new", text="", icon='NEW')
if space.display_mode == 'ACT_LAYER':
row.operator("outliner.collection_override_new", text="", icon='LINK_AREA')
row.operator("outliner.collection_link", text="", icon='LINKED')
row.operator("outliner.collection_unlink", text="", icon='UNLINKED')
row.operator("outliner.collections_delete", text="", icon='X')
class OUTLINER_MT_editor_menus(Menu):
bl_idname = "OUTLINER_MT_editor_menus"
@@ -88,7 +98,8 @@ class OUTLINER_MT_view(Menu):
space = context.space_data
if space.display_mode not in {'DATABLOCKS', 'USER_PREFERENCES', 'KEYMAPS'}:
layout.prop(space, "use_sort_alpha")
if space.display_mode not in {'ACT_LAYER', 'MASTER_COLLECTION'}:
layout.prop(space, "use_sort_alpha")
layout.prop(space, "show_restrict_columns")
layout.separator()
layout.operator("outliner.show_active")

View File

@@ -635,7 +635,6 @@ class VIEW3D_MT_select_object(Menu):
layout.operator("object.select_all", text="Inverse").action = 'INVERT'
layout.operator("object.select_random", text="Random")
layout.operator("object.select_mirror", text="Mirror")
layout.operator("object.select_by_layer", text="Select All by Layer")
layout.operator_menu_enum("object.select_by_type", "type", text="Select All by Type...")
layout.operator("object.select_camera", text="Select Camera")
@@ -711,7 +710,6 @@ class VIEW3D_MT_select_particle(Menu):
layout = self.layout
layout.operator("view3d.select_border")
layout.operator("view3d.select_circle")
layout.separator()
@@ -1327,15 +1325,6 @@ class VIEW3D_MT_object(Menu):
layout.separator()
if is_local_view:
layout.operator_context = 'EXEC_REGION_WIN'
layout.operator("object.move_to_layer", text="Move out of Local View")
layout.operator_context = 'INVOKE_REGION_WIN'
else:
layout.operator("object.move_to_layer", text="Move to Layer...")
layout.menu("VIEW3D_MT_object_showhide")
layout.operator_menu_enum("object.convert", "target")
@@ -1614,17 +1603,6 @@ class VIEW3D_MT_object_quick_effects(Menu):
layout.operator("object.quick_fluid")
class VIEW3D_MT_object_showhide(Menu):
bl_label = "Show/Hide"
def draw(self, context):
layout = self.layout
layout.operator("object.hide_view_clear", text="Show Hidden")
layout.operator("object.hide_view_set", text="Hide Selected").unselected = False
layout.operator("object.hide_view_set", text="Hide Unselected").unselected = True
class VIEW3D_MT_make_single_user(Menu):
bl_label = "Make Single User"
@@ -3149,6 +3127,47 @@ class VIEW3D_MT_edit_gpencil_interpolate(Menu):
# ********** Panel **********
class VIEW3D_PT_viewport_debug(Panel):
bl_space_type = 'VIEW_3D'
bl_region_type = 'UI'
bl_label = "Modern Viewport"
bl_options = {'DEFAULT_CLOSED'}
@classmethod
def poll(cls, context):
view = context.space_data
return (view)
def draw_header(self, context):
view = context.space_data
self.layout.prop(view, "use_modern_viewport", text="")
def draw(self, context):
layout = self.layout
view = context.space_data
layout.active = view.use_modern_viewport
col = layout.column()
col.label(text="Placeholder for debugging options")
col.separator()
row = col.row()
row.active = not view.show_combined_depth
row.prop(view, "show_scene_depth")
row = col.row()
row.active = not view.show_scene_depth
row.prop(view, "show_combined_depth")
row = col.row(align=True)
row.active = view.show_scene_depth or view.show_combined_depth
row.prop(view, "debug_near")
row.prop(view, "debug_far")
col.label(text="Background:")
col.row(align=True).prop(view, "debug_background", expand=True)
class VIEW3D_PT_grease_pencil(GreasePencilDataPanel, Panel):
bl_space_type = 'VIEW_3D'
bl_region_type = 'UI'
@@ -3262,7 +3281,7 @@ class VIEW3D_PT_view3d_display(Panel):
@classmethod
def poll(cls, context):
view = context.space_data
return (view)
return (view) and not view.use_modern_viewport
def draw(self, context):
layout = self.layout
@@ -3362,6 +3381,11 @@ class VIEW3D_PT_view3d_shading(Panel):
bl_region_type = 'UI'
bl_label = "Shading"
@classmethod
def poll(cls, context):
view = context.space_data
return (view) and not view.use_modern_viewport
def draw(self, context):
layout = self.layout
@@ -3858,7 +3882,6 @@ classes = (
VIEW3D_MT_object_group,
VIEW3D_MT_object_constraints,
VIEW3D_MT_object_quick_effects,
VIEW3D_MT_object_showhide,
VIEW3D_MT_make_single_user,
VIEW3D_MT_make_links,
VIEW3D_MT_object_game,
@@ -3919,6 +3942,7 @@ classes = (
VIEW3D_MT_edit_armature_delete,
VIEW3D_MT_edit_gpencil_transform,
VIEW3D_MT_edit_gpencil_interpolate,
VIEW3D_PT_viewport_debug,
VIEW3D_PT_grease_pencil,
VIEW3D_PT_grease_pencil_palettecolor,
VIEW3D_PT_view3d_properties,

View File

@@ -18,7 +18,7 @@ bpy.ops.object.select_all(action='DESELECT')
for obj in selection:
obj.select = True
obj.select_set(action='SELECT')
# some exporters only use the active object
scene.objects.active = obj
@@ -31,7 +31,7 @@ for obj in selection:
## Can be used for multiple formats
# bpy.ops.export_scene.x3d(filepath=fn + ".x3d", use_selection=True)
obj.select = False
obj.select_set(action='DESELECT')
print("written:", fn)
@@ -39,4 +39,4 @@ for obj in selection:
scene.objects.active = obj_active
for obj in selection:
obj.select = True
obj.select_set(action='SELECT')

View File

@@ -67,7 +67,7 @@ def main(context, event):
# now we have the object under the mouse cursor,
# we could do lots of stuff but for the example just select.
if best_obj is not None:
best_obj.select = True
best_obj.select_set(action='SELECT')
context.scene.objects.active = best_obj

View File

@@ -54,6 +54,7 @@ set(SRC_DNA_INC
${CMAKE_CURRENT_SOURCE_DIR}/makesdna/DNA_key_types.h
${CMAKE_CURRENT_SOURCE_DIR}/makesdna/DNA_lamp_types.h
${CMAKE_CURRENT_SOURCE_DIR}/makesdna/DNA_lattice_types.h
${CMAKE_CURRENT_SOURCE_DIR}/makesdna/DNA_layer_types.h
${CMAKE_CURRENT_SOURCE_DIR}/makesdna/DNA_linestyle_types.h
${CMAKE_CURRENT_SOURCE_DIR}/makesdna/DNA_listBase.h
${CMAKE_CURRENT_SOURCE_DIR}/makesdna/DNA_material_types.h
@@ -100,6 +101,7 @@ add_subdirectory(windowmanager)
add_subdirectory(blenkernel)
add_subdirectory(blenlib)
add_subdirectory(bmesh)
add_subdirectory(draw)
add_subdirectory(render)
add_subdirectory(blenfont)
add_subdirectory(blentranslation)

View File

@@ -123,19 +123,19 @@ static bool object_is_shape(Object *ob)
}
}
static bool export_object(const ExportSettings * const settings, Object *ob)
static bool export_object(const ExportSettings * const settings, const Base * const ob_base)
{
if (settings->selected_only && !parent_selected(ob)) {
if (settings->selected_only && !object_selected(ob_base)) {
return false;
}
// FIXME Sybren: handle these cleanly (maybe just remove code), now using active scene layer instead.
if (settings->visible_layers_only && (ob_base->flag & BASE_VISIBLED) == 0) {
return false;
}
if (settings->visible_layers_only && !(settings->scene->lay & ob->lay)) {
return false;
}
if (settings->renderable_only && (ob->restrictflag & OB_RESTRICT_RENDER)) {
return false;
}
// if (settings->renderable_only && (ob->restrictflag & OB_RESTRICT_RENDER)) {
// return false;
// }
return true;
}
@@ -341,12 +341,10 @@ void AbcExporter::operator()(Main *bmain, float &progress, bool &was_canceled)
void AbcExporter::createTransformWritersHierarchy(EvaluationContext *eval_ctx)
{
Base *base = static_cast<Base *>(m_scene->base.first);
while (base) {
for (Base *base = static_cast<Base *>(m_settings.sl->object_bases.first); base; base = base->next) {
Object *ob = base->object;
if (export_object(&m_settings, ob)) {
if (export_object(&m_settings, base)) {
switch (ob->type) {
case OB_LAMP:
case OB_LATTICE:
@@ -356,53 +354,49 @@ void AbcExporter::createTransformWritersHierarchy(EvaluationContext *eval_ctx)
break;
default:
exploreTransform(eval_ctx, ob, ob->parent, NULL);
exploreTransform(eval_ctx, base, ob->parent, NULL);
}
}
base = base->next;
}
}
void AbcExporter::createTransformWritersFlat()
{
Base *base = static_cast<Base *>(m_scene->base.first);
while (base) {
for (Base *base = static_cast<Base *>(m_settings.sl->object_bases.first); base; base = base->next) {
Object *ob = base->object;
if (export_object(&m_settings, ob) && object_is_shape(ob)) {
if (!export_object(&m_settings, base)) {
std::string name = get_id_name(ob);
m_xforms[name] = new AbcTransformWriter(ob, m_writer->archive().getTop(), 0, m_trans_sampling_index, m_settings);
}
base = base->next;
}
}
void AbcExporter::exploreTransform(EvaluationContext *eval_ctx, Object *ob, Object *parent, Object *dupliObParent)
void AbcExporter::exploreTransform(EvaluationContext *eval_ctx, Base *ob_base, Object *parent, Object *dupliObParent)
{
Object *ob = ob_base->object;
if (export_object(&m_settings, ob) && object_is_shape(ob)) {
if (export_object(&m_settings, ob_base) && object_is_shape(ob)) {
createTransformWriter(ob, parent, dupliObParent);
}
ListBase *lb = object_duplilist(eval_ctx, m_scene, ob);
if (lb) {
DupliObject *link = static_cast<DupliObject *>(lb->first);
Object *dupli_ob = NULL;
Object *dupli_parent = NULL;
while (link) {
Base fake_base = *ob_base; // copy flags (like selection state) from the real object.
fake_base.next = fake_base.prev = NULL;
for (DupliObject *link = static_cast<DupliObject *>(lb->first); link; link = link->next) {
Object *dupli_ob = NULL;
Object *dupli_parent = NULL;
if (link->type == OB_DUPLIGROUP) {
dupli_ob = link->ob;
dupli_parent = (dupli_ob->parent) ? dupli_ob->parent : ob;
exploreTransform(eval_ctx, dupli_ob, dupli_parent, ob);
fake_base.object = dupli_ob;
exploreTransform(eval_ctx, &fake_base, dupli_parent, ob);
}
link = link->next;
}
}
@@ -460,44 +454,42 @@ void AbcExporter::createTransformWriter(Object *ob, Object *parent, Object *dupl
void AbcExporter::createShapeWriters(EvaluationContext *eval_ctx)
{
Base *base = static_cast<Base *>(m_scene->base.first);
while (base) {
Object *ob = base->object;
exploreObject(eval_ctx, ob, NULL);
base = base->next;
for (Base *base = static_cast<Base *>(m_settings.sl->object_bases.first); base; base = base->next) {
exploreObject(eval_ctx, base, NULL);
}
}
void AbcExporter::exploreObject(EvaluationContext *eval_ctx, Object *ob, Object *dupliObParent)
void AbcExporter::exploreObject(EvaluationContext *eval_ctx, Base *ob_base, Object *dupliObParent)
{
Object *ob = ob_base->object;
ListBase *lb = object_duplilist(eval_ctx, m_scene, ob);
createShapeWriter(ob, dupliObParent);
createShapeWriter(ob_base, dupliObParent);
if (lb) {
DupliObject *dupliob = static_cast<DupliObject *>(lb->first);
Base fake_base = *ob_base; // copy flags (like selection state) from the real object.
fake_base.next = fake_base.prev = NULL;
while (dupliob) {
for (DupliObject *dupliob = static_cast<DupliObject *>(lb->first); dupliob; dupliob = dupliob->next) {
if (dupliob->type == OB_DUPLIGROUP) {
exploreObject(eval_ctx, dupliob->ob, ob);
fake_base.object = dupliob->ob;
exploreObject(eval_ctx, &fake_base, ob);
}
dupliob = dupliob->next;
}
}
free_object_duplilist(lb);
}
void AbcExporter::createShapeWriter(Object *ob, Object *dupliObParent)
void AbcExporter::createShapeWriter(Base *ob_base, Object *dupliObParent)
{
Object *ob = ob_base->object;
if (!object_is_shape(ob)) {
return;
}
if (!export_object(&m_settings, ob)) {
if (!export_object(&m_settings, ob_base)) {
return;
}

View File

@@ -36,11 +36,14 @@ struct EvaluationContext;
struct Main;
struct Object;
struct Scene;
struct SceneLayer;
struct Base;
struct ExportSettings {
ExportSettings();
Scene *scene;
SceneLayer *sl; // Scene layer to export; all its objects will be exported, unless selected_only=true
bool selected_only;
bool visible_layers_only;
@@ -105,10 +108,10 @@ private:
void createTransformWritersHierarchy(EvaluationContext *eval_ctx);
void createTransformWritersFlat();
void createTransformWriter(Object *ob, Object *parent, Object *dupliObParent);
void exploreTransform(EvaluationContext *eval_ctx, Object *ob, Object *parent, Object *dupliObParent = NULL);
void exploreObject(EvaluationContext *eval_ctx, Object *ob, Object *dupliObParent);
void exploreTransform(EvaluationContext *eval_ctx, Base *ob_base, Object *parent, Object *dupliObParent);
void exploreObject(EvaluationContext *eval_ctx, Base *ob_base, Object *dupliObParent);
void createShapeWriters(EvaluationContext *eval_ctx);
void createShapeWriter(Object *ob, Object *dupliObParent);
void createShapeWriter(Base *ob_base, Object *dupliObParent);
AbcTransformWriter *getXForm(const std::string &name);

View File

@@ -35,6 +35,7 @@
extern "C" {
#include "DNA_object_types.h"
#include "DNA_layer_types.h"
#include "BLI_math.h"
@@ -60,6 +61,16 @@ std::string get_id_name(ID *id)
return name;
}
/**
* @brief get_object_dag_path_name returns the name under which the object
* will be exported in the Alembic file. It is of the form
* "[../grandparent/]parent/object" if dupli_parent is NULL, or
* "dupli_parent/[../grandparent/]parent/object" otherwise.
* @param ob
* @param dupli_parent
* @return
*/
std::string get_object_dag_path_name(Object *ob, Object *dupli_parent)
{
std::string name = get_id_name(ob);
@@ -78,31 +89,9 @@ std::string get_object_dag_path_name(Object *ob, Object *dupli_parent)
return name;
}
bool object_selected(Object *ob)
bool object_selected(const Base * const ob_base)
{
return ob->flag & SELECT;
}
bool parent_selected(Object *ob)
{
if (object_selected(ob)) {
return true;
}
bool do_export = false;
Object *parent = ob->parent;
while (parent != NULL) {
if (object_selected(parent)) {
do_export = true;
break;
}
parent = parent->parent;
}
return do_export;
return ob_base->flag & SELECT;
}
Imath::M44d convert_matrix(float mat[4][4])

View File

@@ -43,13 +43,13 @@ struct ImportSettings;
struct ID;
struct Object;
struct Base;
std::string get_id_name(ID *id);
std::string get_id_name(Object *ob);
std::string get_object_dag_path_name(Object *ob, Object *dupli_parent);
bool object_selected(Object *ob);
bool parent_selected(Object *ob);
bool object_selected(const Base * const ob_base);
Imath::M44d convert_matrix(float mat[4][4]);
void create_transform_matrix(float r_mat[4][4]);

View File

@@ -332,21 +332,37 @@ void ABC_export(
BLI_strncpy(job->filename, filepath, 1024);
job->settings.scene = job->scene;
/* Sybren: for now we only export the active scene layer.
* Later in the 2.8 development process this may be replaced by using
* a specific collection for Alembic I/O, which can then be toggled
* between "real" objects and cached Alembic files. */
job->settings.sl = CTX_data_scene_layer(C);
job->settings.frame_start = params->frame_start;
job->settings.frame_end = params->frame_end;
job->settings.frame_step_xform = params->frame_step_xform;
job->settings.frame_step_shape = params->frame_step_shape;
job->settings.shutter_open = params->shutter_open;
job->settings.shutter_close = params->shutter_close;
/* Sybren: For now this is ignored, until we can get selection
* detection working through Base pointers (instead of ob->flags). */
job->settings.selected_only = params->selected_only;
job->settings.export_face_sets = params->face_sets;
job->settings.export_normals = params->normals;
job->settings.export_uvs = params->uvs;
job->settings.export_vcols = params->vcolors;
job->settings.apply_subdiv = params->apply_subdiv;
job->settings.flatten_hierarchy = params->flatten_hierarchy;
/* Sybren: visible_layer & renderable only is ignored for now,
* to be replaced with collections later in the 2.8 dev process
* (also see note above). */
job->settings.visible_layers_only = params->visible_layers_only;
job->settings.renderable_only = params->renderable_only;
job->settings.use_subdiv_schema = params->use_subdiv_schema;
job->settings.export_ogawa = (params->compression_type == ABC_ARCHIVE_OGAWA);
job->settings.pack_uv = params->packuv;

View File

@@ -34,6 +34,9 @@
#include "BLI_compiler_attrs.h"
/* enable this only if needed (unused circa 2016) */
#define BLF_BLUR_ENABLE 0
struct rctf;
struct ColorManagedDisplay;
struct ResultBLF;
@@ -42,6 +45,7 @@ int BLF_init(int points, int dpi);
void BLF_exit(void);
void BLF_default_dpi(int dpi);
void BLF_default_set(int fontid);
int BLF_default(void); /* get default font ID so we can pass it to other functions */
void BLF_cache_clear(void);
@@ -61,6 +65,17 @@ void BLF_aspect(int fontid, float x, float y, float z);
void BLF_position(int fontid, float x, float y, float z);
void BLF_size(int fontid, int size, int dpi);
/* goal: small but useful color API */
void BLF_color4ubv(int fontid, const unsigned char rgba[4]);
void BLF_color3ubv(int fontid, const unsigned char rgb[3]);
void BLF_color3ubv_alpha(int fontid, const unsigned char rgb[3], unsigned char alpha);
void BLF_color3ub(int fontid, unsigned char r, unsigned char g, unsigned char b);
void BLF_color4f(int fontid, float r, float g, float b, float a);
void BLF_color4fv(int fontid, const float rgba[4]);
void BLF_color3f(int fontid, float r, float g, float b);
void BLF_color3fv_alpha(int fontid, const float rgb[3], float alpha);
/* also available: UI_FontThemeColor(fontid, colorid) */
/* Set a 4x4 matrix to be multiplied before draw the text.
* Remember that you need call BLF_enable(BLF_MATRIX)
* to enable this.
@@ -122,29 +137,16 @@ void BLF_width_and_height(int fontid, const char *str, size_t len, float *r_widt
*/
float BLF_fixed_width(int fontid) ATTR_WARN_UNUSED_RESULT;
/* and this two function return the width and height
* of the string, using the default font and both value
* are multiplied by the aspect of the font.
*/
void BLF_width_and_height_default(const char *str, size_t len, float *r_width, float *r_height) ATTR_NONNULL();
float BLF_width_default(const char *str, size_t len) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL();
float BLF_height_default(const char *str, size_t len) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL();
/* Set rotation for default font. */
void BLF_rotation_default(float angle);
/* Enable/disable options to the default font. */
void BLF_enable_default(int option);
void BLF_disable_default(int option);
/* By default, rotation and clipping are disable and
* have to be enable/disable using BLF_enable/disable.
*/
void BLF_rotation(int fontid, float angle);
void BLF_clipping(int fontid, float xmin, float ymin, float xmax, float ymax);
void BLF_clipping_default(float xmin, float ymin, float xmax, float ymax);
void BLF_wordwrap(int fontid, int wrap_width);
#if BLF_BLUR_ENABLE
void BLF_blur(int fontid, int size);
#endif
void BLF_enable(int fontid, int option);
void BLF_disable(int fontid, int option);

View File

@@ -50,13 +50,14 @@
#include "BLI_math.h"
#include "BLI_threads.h"
#include "BIF_gl.h"
#include "BLF_api.h"
#include "IMB_colormanagement.h"
#ifndef BLF_STANDALONE
#include "GPU_basic_shader.h"
#include "GPU_shader.h"
#include "GPU_matrix.h"
#include "GPU_immediate.h"
#endif
#include "blf_internal_types.h"
@@ -174,6 +175,12 @@ void BLF_default_set(int fontid)
}
}
int BLF_default(void)
{
ASSERT_DEFAULT_SET;
return global_font_default;
}
int BLF_load(const char *name)
{
FontBLF *font;
@@ -357,24 +364,6 @@ void BLF_disable(int fontid, int option)
}
}
void BLF_enable_default(int option)
{
FontBLF *font = blf_get(global_font_default);
if (font) {
font->flags |= option;
}
}
void BLF_disable_default(int option)
{
FontBLF *font = blf_get(global_font_default);
if (font) {
font->flags &= ~option;
}
}
void BLF_aspect(int fontid, float x, float y, float z)
{
FontBLF *font = blf_get(fontid);
@@ -453,6 +442,7 @@ void BLF_size(int fontid, int size, int dpi)
}
}
#if BLF_BLUR_ENABLE
void BLF_blur(int fontid, int size)
{
FontBLF *font = blf_get(fontid);
@@ -461,6 +451,77 @@ void BLF_blur(int fontid, int size)
font->blur = size;
}
}
#endif
void BLF_color4ubv(int fontid, const unsigned char rgba[4])
{
FontBLF *font = blf_get(fontid);
if (font) {
font->color[0] = rgba[0];
font->color[1] = rgba[1];
font->color[2] = rgba[2];
font->color[3] = rgba[3];
}
}
void BLF_color3ubv_alpha(int fontid, const unsigned char rgb[3], unsigned char alpha)
{
FontBLF *font = blf_get(fontid);
if (font) {
font->color[0] = rgb[0];
font->color[1] = rgb[1];
font->color[2] = rgb[2];
font->color[3] = alpha;
}
}
void BLF_color3ubv(int fontid, const unsigned char rgb[3])
{
BLF_color3ubv_alpha(fontid, rgb, 255);
}
void BLF_color3ub(int fontid, unsigned char r, unsigned char g, unsigned char b)
{
FontBLF *font = blf_get(fontid);
if (font) {
font->color[0] = r;
font->color[1] = g;
font->color[2] = b;
font->color[3] = 255;
}
}
void BLF_color4fv(int fontid, const float rgba[4])
{
FontBLF *font = blf_get(fontid);
if (font) {
rgba_float_to_uchar(font->color, rgba);
}
}
void BLF_color4f(int fontid, float r, float g, float b, float a)
{
float rgba[4] = { r, g, b, a };
BLF_color4fv(fontid, rgba);
}
void BLF_color3fv_alpha(int fontid, const float rgb[3], float alpha)
{
float rgba[4];
copy_v3_v3(rgba, rgb);
rgba[3] = alpha;
BLF_color4fv(fontid, rgba);
}
void BLF_color3f(int fontid, float r, float g, float b)
{
float rgba[4] = { r, g, b, 1.0f };
BLF_color4fv(fontid, rgba);
}
void BLF_draw_default(float x, float y, float z, const char *str, size_t len)
{
@@ -481,16 +542,7 @@ void BLF_draw_default_ascii(float x, float y, float z, const char *str, size_t l
BLF_draw_ascii(global_font_default, str, len); /* XXX, use real length */
}
void BLF_rotation_default(float angle)
{
FontBLF *font = blf_get(global_font_default);
if (font) {
font->angle = angle;
}
}
static void blf_draw_gl__start(FontBLF *font, GLint *mode)
static void blf_draw_gl__start(FontBLF *font)
{
/*
* The pixmap alignment hack is handle
@@ -500,52 +552,44 @@ static void blf_draw_gl__start(FontBLF *font, GLint *mode)
glEnable(GL_BLEND);
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
#ifndef BLF_STANDALONE
GPU_basic_shader_bind(GPU_SHADER_TEXTURE_2D | GPU_SHADER_USE_COLOR);
#endif
/* Save the current matrix mode. */
glGetIntegerv(GL_MATRIX_MODE, mode);
glMatrixMode(GL_TEXTURE);
glPushMatrix();
glLoadIdentity();
glMatrixMode(GL_MODELVIEW);
glPushMatrix();
gpuPushMatrix();
if (font->flags & BLF_MATRIX)
glMultMatrixf(font->m);
gpuMultMatrix3D(font->m);
glTranslate3fv(font->pos);
gpuTranslate3fv(font->pos);
if (font->flags & BLF_ASPECT)
glScalef(font->aspect[0], font->aspect[1], font->aspect[2]);
gpuScale3fv(font->aspect);
if (font->flags & BLF_ROTATION) /* radians -> degrees */
glRotatef(font->angle * (float)(180.0 / M_PI), 0.0f, 0.0f, 1.0f);
gpuRotateAxis(RAD2DEG(font->angle), 'Z'); /* TODO: use gpuRotate2D here? */
if (font->shadow || font->blur)
glGetFloatv(GL_CURRENT_COLOR, font->orig_col);
#ifndef BLF_STANDALONE
VertexFormat *format = immVertexFormat();
unsigned pos = add_attrib(format, "pos", GL_FLOAT, 2, KEEP_FLOAT);
unsigned texCoord = add_attrib(format, "texCoord", GL_FLOAT, 2, KEEP_FLOAT);
unsigned color = add_attrib(format, "color", GL_UNSIGNED_BYTE, 4, NORMALIZE_INT_TO_FLOAT);
BLI_assert(pos == BLF_POS_ID);
BLI_assert(texCoord == BLF_COORD_ID);
BLI_assert(color == BLF_COLOR_ID);
immBindBuiltinProgram(GPU_SHADER_TEXT);
#endif
/* always bind the texture for the first glyph */
font->tex_bind_state = -1;
}
static void blf_draw_gl__end(GLint mode)
static void blf_draw_gl__end(void)
{
glMatrixMode(GL_TEXTURE);
glPopMatrix();
glMatrixMode(GL_MODELVIEW);
glPopMatrix();
if (mode != GL_MODELVIEW)
glMatrixMode(mode);
gpuPopMatrix();
#ifndef BLF_STANDALONE
GPU_basic_shader_bind(GPU_SHADER_USE_COLOR);
immUnbindProgram();
#endif
glDisable(GL_BLEND);
}
@@ -554,23 +598,26 @@ void BLF_draw_ex(
struct ResultBLF *r_info)
{
FontBLF *font = blf_get(fontid);
GLint mode;
BLF_RESULT_CHECK_INIT(r_info);
if (font && font->glyph_cache) {
blf_draw_gl__start(font, &mode);
blf_draw_gl__start(font);
if (font->flags & BLF_WORD_WRAP) {
blf_font_draw__wrap(font, str, len, r_info);
}
else {
blf_font_draw(font, str, len, r_info);
}
blf_draw_gl__end(mode);
blf_draw_gl__end();
}
}
void BLF_draw(int fontid, const char *str, size_t len)
{
if (len == 0 || str[0] == '\0') {
return;
}
BLF_draw_ex(fontid, str, len, NULL);
}
@@ -579,12 +626,11 @@ void BLF_draw_ascii_ex(
struct ResultBLF *r_info)
{
FontBLF *font = blf_get(fontid);
GLint mode;
BLF_RESULT_CHECK_INIT(r_info);
if (font && font->glyph_cache) {
blf_draw_gl__start(font, &mode);
blf_draw_gl__start(font);
if (font->flags & BLF_WORD_WRAP) {
/* use non-ascii draw function for word-wrap */
blf_font_draw__wrap(font, str, len, r_info);
@@ -592,24 +638,31 @@ void BLF_draw_ascii_ex(
else {
blf_font_draw_ascii(font, str, len, r_info);
}
blf_draw_gl__end(mode);
blf_draw_gl__end();
}
}
void BLF_draw_ascii(int fontid, const char *str, size_t len)
{
if (len == 0 || str[0] == '\0') {
return;
}
BLF_draw_ascii_ex(fontid, str, len, NULL);
}
int BLF_draw_mono(int fontid, const char *str, size_t len, int cwidth)
{
if (len == 0 || str[0] == '\0') {
return 0;
}
FontBLF *font = blf_get(fontid);
GLint mode;
int columns = 0;
if (font && font->glyph_cache) {
blf_draw_gl__start(font, &mode);
blf_draw_gl__start(font);
columns = blf_font_draw_mono(font, str, len, cwidth);
blf_draw_gl__end(mode);
blf_draw_gl__end();
}
return columns;
@@ -689,14 +742,6 @@ void BLF_width_and_height(int fontid, const char *str, size_t len, float *r_widt
}
}
void BLF_width_and_height_default(const char *str, size_t len, float *r_width, float *r_height)
{
ASSERT_DEFAULT_SET;
BLF_size(global_font_default, global_font_points, global_font_dpi);
BLF_width_and_height(global_font_default, str, len, r_width, r_height);
}
float BLF_width_ex(
int fontid, const char *str, size_t len,
struct ResultBLF *r_info)
@@ -727,14 +772,6 @@ float BLF_fixed_width(int fontid)
return 0.0f;
}
float BLF_width_default(const char *str, size_t len)
{
ASSERT_DEFAULT_SET;
BLF_size(global_font_default, global_font_points, global_font_dpi);
return BLF_width(global_font_default, str, len);
}
float BLF_height_ex(
int fontid, const char *str, size_t len,
struct ResultBLF *r_info)
@@ -798,15 +835,6 @@ float BLF_ascender(int fontid)
return 0.0f;
}
float BLF_height_default(const char *str, size_t len)
{
ASSERT_DEFAULT_SET;
BLF_size(global_font_default, global_font_points, global_font_dpi);
return BLF_height(global_font_default, str, len);
}
void BLF_rotation(int fontid, float angle)
{
FontBLF *font = blf_get(fontid);
@@ -828,18 +856,6 @@ void BLF_clipping(int fontid, float xmin, float ymin, float xmax, float ymax)
}
}
void BLF_clipping_default(float xmin, float ymin, float xmax, float ymax)
{
FontBLF *font = blf_get(global_font_default);
if (font) {
font->clip_rec.xmin = xmin;
font->clip_rec.ymin = ymin;
font->clip_rec.xmax = xmax;
font->clip_rec.ymax = ymax;
}
}
void BLF_wordwrap(int fontid, int wrap_width)
{
FontBLF *font = blf_get(fontid);
@@ -855,7 +871,7 @@ void BLF_shadow(int fontid, int level, const float rgba[4])
if (font) {
font->shadow = level;
copy_v4_v4(font->shadow_col, rgba);
rgba_float_to_uchar(font->shadow_color, rgba);
}
}

View File

@@ -58,6 +58,8 @@
#include "BIF_gl.h"
#include "BLF_api.h"
#include "GPU_immediate.h"
#include "blf_internal_types.h"
#include "blf_internal.h"
@@ -172,6 +174,23 @@ static void blf_font_ensure_ascii_table(FontBLF *font)
} \
} (void)0
static unsigned verts_needed(const FontBLF *font, const char *str, size_t len)
{
unsigned length = (unsigned)((len == INT_MAX) ? strlen(str) : len);
unsigned quad_ct = 1;
if (font->flags & BLF_SHADOW) {
if (font->shadow == 0)
quad_ct += 1;
if (font->shadow <= 4)
quad_ct += 9; /* 3x3 kernel */
else
quad_ct += 25; /* 5x5 kernel */
}
return length * quad_ct * 4;
}
static void blf_font_draw_ex(
FontBLF *font, const char *str, size_t len, struct ResultBLF *r_info,
int pen_y)
@@ -187,6 +206,9 @@ static void blf_font_draw_ex(
blf_font_ensure_ascii_table(font);
immBeginAtMost(GL_QUADS, verts_needed(font, str, len));
/* at most because some glyphs might be clipped & not drawn */
while ((i < len) && str[i]) {
BLF_UTF8_NEXT_FAST(font, g, str, i, c, glyph_ascii_table);
@@ -204,6 +226,8 @@ static void blf_font_draw_ex(
g_prev = g;
}
immEnd();
if (r_info) {
r_info->lines = 1;
r_info->width = pen_x;
@@ -229,6 +253,8 @@ static void blf_font_draw_ascii_ex(
blf_font_ensure_ascii_table(font);
immBeginAtMost(GL_QUADS, verts_needed(font, str, len));
while ((c = *(str++)) && len--) {
BLI_assert(c < 128);
if ((g = glyph_ascii_table[c]) == NULL)
@@ -243,6 +269,8 @@ static void blf_font_draw_ascii_ex(
g_prev = g;
}
immEnd();
if (r_info) {
r_info->lines = 1;
r_info->width = pen_x;
@@ -265,6 +293,8 @@ int blf_font_draw_mono(FontBLF *font, const char *str, size_t len, int cwidth)
blf_font_ensure_ascii_table(font);
immBeginAtMost(GL_QUADS, verts_needed(font, str, len));
while ((i < len) && str[i]) {
BLF_UTF8_NEXT_FAST(font, g, str, i, c, glyph_ascii_table);
@@ -284,6 +314,8 @@ int blf_font_draw_mono(FontBLF *font, const char *str, size_t len, int cwidth)
pen_x += cwidth * col;
}
immEnd();
return columns;
}
@@ -901,8 +933,6 @@ void blf_font_free(FontBLF *font)
static void blf_font_fill(FontBLF *font)
{
unsigned int i;
font->aspect[0] = 1.0f;
font->aspect[1] = 1.0f;
font->aspect[2] = 1.0f;
@@ -910,9 +940,15 @@ static void blf_font_fill(FontBLF *font)
font->pos[1] = 0.0f;
font->angle = 0.0f;
for (i = 0; i < 16; i++)
for (int i = 0; i < 16; i++)
font->m[i] = 0;
/* annoying bright color so we can see where to add BLF_color calls */
font->color[0] = 255;
font->color[1] = 255;
font->color[2] = 0;
font->color[3] = 255;
font->clip_rec.xmin = 0.0f;
font->clip_rec.xmax = 0.0f;
font->clip_rec.ymin = 0.0f;
@@ -922,7 +958,9 @@ static void blf_font_fill(FontBLF *font)
font->size = 0;
BLI_listbase_clear(&font->cache);
font->glyph_cache = NULL;
#if BLF_BLUR_ENABLE
font->blur = 0;
#endif
font->max_tex_size = -1;
font->buf_info.fbuf = NULL;

View File

@@ -56,7 +56,7 @@
#include "BLF_api.h"
#ifndef BLF_STANDALONE
#include "GPU_basic_shader.h"
#include "GPU_immediate.h"
#endif
#include "blf_internal_types.h"
@@ -182,17 +182,6 @@ static void blf_glyph_cache_texture(FontBLF *font, GlyphCacheBLF *gc)
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
#ifndef BLF_STANDALONE
/* needed since basic shader doesn't support alpha-only textures,
* while we could add support this is only used in a few places
* (an alternative could be to have a simple shader for BLF). */
if (GLEW_ARB_texture_swizzle && GPU_basic_shader_use_glsl_get()) {
GLint swizzle_mask[] = {GL_ONE, GL_ONE, GL_ONE, GL_ALPHA};
glTexParameteriv(GL_TEXTURE_2D, GL_TEXTURE_SWIZZLE_RGBA, swizzle_mask);
}
#endif
glTexImage2D(GL_TEXTURE_2D, 0, GL_ALPHA8, gc->p2_width, gc->p2_height, 0, GL_ALPHA, GL_UNSIGNED_BYTE, NULL);
}
@@ -326,73 +315,73 @@ void blf_glyph_free(GlyphBLF *g)
MEM_freeN(g);
}
static void blf_texture_draw(float uv[2][2], float dx, float y1, float dx1, float y2)
static void blf_texture_draw(const unsigned char color[4], float uv[2][2], float dx, float y1, float dx1, float y2)
{
glBegin(GL_QUADS);
glTexCoord2f(uv[0][0], uv[0][1]);
glVertex2f(dx, y1);
glTexCoord2f(uv[0][0], uv[1][1]);
glVertex2f(dx, y2);
glTexCoord2f(uv[1][0], uv[1][1]);
glVertex2f(dx1, y2);
glTexCoord2f(uv[1][0], uv[0][1]);
glVertex2f(dx1, y1);
glEnd();
immAttrib2f(BLF_COORD_ID, uv[0][0], uv[0][1]);
immSkipAttrib(BLF_COLOR_ID); /* skip color of most vertices */
immVertex2f(BLF_POS_ID, dx, y1);
immAttrib2f(BLF_COORD_ID, uv[0][0], uv[1][1]);
immSkipAttrib(BLF_COLOR_ID);
immVertex2f(BLF_POS_ID, dx, y2);
immAttrib2f(BLF_COORD_ID, uv[1][0], uv[1][1]);
immSkipAttrib(BLF_COLOR_ID);
immVertex2f(BLF_POS_ID, dx1, y2);
immAttrib2f(BLF_COORD_ID, uv[1][0], uv[0][1]);
immAttrib4ubv(BLF_COLOR_ID, color); /* set color of provoking vertex */
immVertex2f(BLF_POS_ID, dx1, y1);
}
static void blf_texture5_draw(const float shadow_col[4], float uv[2][2], float x1, float y1, float x2, float y2)
static void blf_texture5_draw(const unsigned char color_in[4], float uv[2][2], float x1, float y1, float x2, float y2)
{
const float soft[25] = {1 / 60.0f, 1 / 60.0f, 2 / 60.0f, 1 / 60.0f, 1 / 60.0f,
1 / 60.0f, 3 / 60.0f, 5 / 60.0f, 3 / 60.0f, 1 / 60.0f,
2 / 60.0f, 5 / 60.0f, 8 / 60.0f, 5 / 60.0f, 2 / 60.0f,
1 / 60.0f, 3 / 60.0f, 5 / 60.0f, 3 / 60.0f, 1 / 60.0f,
1 / 60.0f, 1 / 60.0f, 2 / 60.0f, 1 / 60.0f, 1 / 60.0f};
const float *fp = soft;
float color[4];
unsigned char color[4];
float dx, dy;
color[0] = shadow_col[0];
color[1] = shadow_col[1];
color[2] = shadow_col[2];
color[0] = color_in[0];
color[1] = color_in[1];
color[2] = color_in[2];
const float alpha_in = (1 / 255.0f) * color_in[3];
for (dx = -2; dx < 3; dx++) {
for (dy = -2; dy < 3; dy++, fp++) {
color[3] = *(fp) * shadow_col[3];
glColor4fv(color);
blf_texture_draw(uv, x1 + dx, y1 + dy, x2 + dx, y2 + dy);
color[3] = FTOCHAR(*fp * alpha_in);
blf_texture_draw(color, uv, x1 + dx, y1 + dy, x2 + dx, y2 + dy);
}
}
glColor4fv(color);
}
static void blf_texture3_draw(const float shadow_col[4], float uv[2][2], float x1, float y1, float x2, float y2)
static void blf_texture3_draw(const unsigned char color_in[4], float uv[2][2], float x1, float y1, float x2, float y2)
{
const float soft[9] = {1 / 16.0f, 2 / 16.0f, 1 / 16.0f,
2 / 16.0f, 4 / 16.0f, 2 / 16.0f,
1 / 16.0f, 2 / 16.0f, 1 / 16.0f};
const float *fp = soft;
float color[4];
unsigned char color[4];
float dx, dy;
color[0] = shadow_col[0];
color[1] = shadow_col[1];
color[2] = shadow_col[2];
color[0] = color_in[0];
color[1] = color_in[1];
color[2] = color_in[2];
const float alpha_in = (1 / 255.0f) * color_in[3];
for (dx = -1; dx < 2; dx++) {
for (dy = -1; dy < 2; dy++, fp++) {
color[3] = *(fp) * shadow_col[3];
glColor4fv(color);
blf_texture_draw(uv, x1 + dx, y1 + dy, x2 + dx, y2 + dy);
color[3] = FTOCHAR(*fp * alpha_in);
blf_texture_draw(color, uv, x1 + dx, y1 + dy, x2 + dx, y2 + dy);
}
}
glColor4fv(color);
}
static void blf_glyph_calc_rect(rctf *rect, GlyphBLF *g, float x, float y)
@@ -449,14 +438,21 @@ void blf_glyph_render(FontBLF *font, GlyphBLF *g, float x, float y)
}
glPushClientAttrib(GL_CLIENT_PIXEL_STORE_BIT);
GLint lsb_first, row_length, alignment;
glGetIntegerv(GL_UNPACK_LSB_FIRST, &lsb_first);
glGetIntegerv(GL_UNPACK_ROW_LENGTH, &row_length);
glGetIntegerv(GL_UNPACK_ALIGNMENT, &alignment);
glPixelStorei(GL_UNPACK_LSB_FIRST, GL_FALSE);
glPixelStorei(GL_UNPACK_ROW_LENGTH, 0);
glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
glBindTexture(GL_TEXTURE_2D, g->tex);
glTexSubImage2D(GL_TEXTURE_2D, 0, g->xoff, g->yoff, g->width, g->height, GL_ALPHA, GL_UNSIGNED_BYTE, g->bitmap);
glPopClientAttrib();
glPixelStorei(GL_UNPACK_LSB_FIRST, lsb_first);
glPixelStorei(GL_UNPACK_ROW_LENGTH, row_length);
glPixelStorei(GL_UNPACK_ALIGNMENT, alignment);
g->uv[0][0] = ((float)g->xoff) / ((float)gc->p2_width);
g->uv[0][1] = ((float)g->yoff) / ((float)gc->p2_height);
@@ -486,39 +482,37 @@ void blf_glyph_render(FontBLF *font, GlyphBLF *g, float x, float y)
glBindTexture(GL_TEXTURE_2D, (font->tex_bind_state = g->tex));
}
/* TODO: blur & shadow in shader, single quad per glyph */
if (font->flags & BLF_SHADOW) {
rctf rect_ofs;
blf_glyph_calc_rect(&rect_ofs, g,
x + (float)font->shadow_x,
y + (float)font->shadow_y);
switch (font->shadow) {
case 3:
blf_texture3_draw(font->shadow_col, g->uv, rect_ofs.xmin, rect_ofs.ymin, rect_ofs.xmax, rect_ofs.ymax);
break;
case 5:
blf_texture5_draw(font->shadow_col, g->uv, rect_ofs.xmin, rect_ofs.ymin, rect_ofs.xmax, rect_ofs.ymax);
break;
default:
glColor4fv(font->shadow_col);
blf_texture_draw(g->uv, rect_ofs.xmin, rect_ofs.ymin, rect_ofs.xmax, rect_ofs.ymax);
break;
if (font->shadow == 0) {
blf_texture_draw(font->shadow_color, g->uv, rect_ofs.xmin, rect_ofs.ymin, rect_ofs.xmax, rect_ofs.ymax);
}
else if (font->shadow <= 4) {
blf_texture3_draw(font->shadow_color, g->uv, rect_ofs.xmin, rect_ofs.ymin, rect_ofs.xmax, rect_ofs.ymax);
}
else {
blf_texture5_draw(font->shadow_color, g->uv, rect_ofs.xmin, rect_ofs.ymin, rect_ofs.xmax, rect_ofs.ymax);
}
glColor4fv(font->orig_col);
}
#if BLF_BLUR_ENABLE
switch (font->blur) {
case 3:
blf_texture3_draw(font->orig_col, g->uv, rect.xmin, rect.ymin, rect.xmax, rect.ymax);
blf_texture3_draw(font->color, g->uv, rect.xmin, rect.ymin, rect.xmax, rect.ymax);
break;
case 5:
blf_texture5_draw(font->orig_col, g->uv, rect.xmin, rect.ymin, rect.xmax, rect.ymax);
blf_texture5_draw(font->color, g->uv, rect.xmin, rect.ymin, rect.xmax, rect.ymax);
break;
default:
blf_texture_draw(g->uv, rect.xmin, rect.ymin, rect.xmax, rect.ymax);
break;
blf_texture_draw(font->color, g->uv, rect.xmin, rect.ymin, rect.xmax, rect.ymax);
}
return;
#else
blf_texture_draw(font->color, g->uv, rect.xmin, rect.ymin, rect.xmax, rect.ymax);
#endif
}

View File

@@ -37,6 +37,11 @@ struct GlyphBLF;
struct GlyphCacheBLF;
struct rctf;
/* vertex attribute IDs (fixed IDs so we don't have to pass them around) */
#define BLF_POS_ID 0
#define BLF_COORD_ID 1
#define BLF_COLOR_ID 2
unsigned int blf_next_p2(unsigned int x);
unsigned int blf_hash(unsigned int val);

View File

@@ -175,8 +175,10 @@ typedef struct FontBLF {
/* angle in radians. */
float angle;
#if 0 /* BLF_BLUR_ENABLE */
/* blur: 3 or 5 large kernel */
int blur;
#endif
/* shadow level. */
int shadow;
@@ -186,10 +188,10 @@ typedef struct FontBLF {
int shadow_y;
/* shadow color. */
float shadow_col[4];
unsigned char shadow_color[4];
/* store color here when drawing shadow or blur. */
float orig_col[4];
/* main text color. */
unsigned char color[4];
/* Multiplied this matrix with the current one before
* draw the text! see blf_draw__start.

View File

@@ -387,9 +387,6 @@ struct DerivedMesh {
/** Draw all vertices as bgl points (no options) */
void (*drawVerts)(DerivedMesh *dm);
/** Draw edges in the UV mesh (if exists) */
void (*drawUVEdges)(DerivedMesh *dm);
/** Draw all edges as lines (no options)
*
* Also called for *final* editmode DerivedMeshes

View File

@@ -97,7 +97,6 @@ void BKE_armature_where_is(struct bArmature *arm);
void BKE_armature_where_is_bone(struct Bone *bone, struct Bone *prevbone, const bool use_recursion);
void BKE_pose_clear_pointers(struct bPose *pose);
void BKE_pose_rebuild(struct Object *ob, struct bArmature *arm);
void BKE_pose_rebuild_ex(struct Object *ob, struct bArmature *arm, const bool sort_bones);
void BKE_pose_where_is(struct Scene *scene, struct Object *ob);
void BKE_pose_where_is_bone(struct Scene *scene, struct Object *ob, struct bPoseChannel *pchan, float ctime, bool do_extra);
void BKE_pose_where_is_bone_tail(struct bPoseChannel *pchan);

View File

@@ -27,8 +27,8 @@
/* these lines are grep'd, watch out for our not-so-awesome regex
* and keep comment above the defines.
* Use STRINGIFY() rather than defining with quotes */
#define BLENDER_VERSION 278
#define BLENDER_SUBVERSION 4
#define BLENDER_VERSION 280
#define BLENDER_SUBVERSION 0
/* Several breakages with 270, e.g. constraint deg vs rad */
#define BLENDER_MINVERSION 270
#define BLENDER_MINSUBVERSION 6

View File

@@ -44,6 +44,7 @@ struct Object;
struct RegionView3D;
struct RenderData;
struct Scene;
struct SceneLayer;
struct rctf;
struct View3D;
struct GPUFXSettings;
@@ -127,7 +128,7 @@ void BKE_camera_view_frame(
float r_vec[4][3]);
bool BKE_camera_view_frame_fit_to_scene(
struct Scene *scene, struct View3D *v3d, struct Object *camera_ob,
struct Scene *scene, struct SceneLayer *sl, struct Object *camera_ob,
float r_co[3], float *r_scale);
bool BKE_camera_view_frame_fit_to_coords(
const struct Scene *scene,

View File

@@ -0,0 +1,100 @@
/*
* ***** 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.
*
* Contributor(s): Dalai Felinto
*
* ***** END GPL LICENSE BLOCK *****
*/
#ifndef __BKE_COLLECTION_H__
#define __BKE_COLLECTION_H__
/** \file blender/blenkernel/BKE_collection.h
* \ingroup bke
*/
#include "BLI_ghash.h"
#include "BLI_iterator.h"
#include "DNA_listBase.h"
#ifdef __cplusplus
extern "C" {
#endif
struct Iterator;
struct SceneCollection;
struct Object;
struct Base;
struct Main;
struct Scene;
struct SceneCollection *BKE_collection_add(struct Scene *scene, struct SceneCollection *sc_parent, const char *name);
bool BKE_collection_remove(struct Scene *scene, struct SceneCollection *sc);
struct SceneCollection *BKE_collection_master(const struct Scene *scene);
void BKE_collection_rename(const struct Scene *scene, struct SceneCollection *sc, const char *name);
void BKE_collection_master_free(struct Scene *scene);
void BKE_collection_object_add(const struct Scene *scene, struct SceneCollection *sc, struct Object *object);
void BKE_collection_object_add_from(struct Scene *scene, struct Object *ob_src, struct Object *ob_dst);
void BKE_collection_object_remove(struct Main *bmain, const struct Scene *scene, struct SceneCollection *sc, struct Object *object, const bool free_us);
void BKE_collections_object_remove(struct Main *bmain, struct Scene *scene, struct Object *object, const bool free_us);
void BKE_collection_object_move(const struct Scene *scene, struct SceneCollection *sc_dst, struct SceneCollection *sc_src, struct Object *ob);
void BKE_collection_reinsert_after(const struct Scene *scene, struct SceneCollection *sc_reinsert, struct SceneCollection *sc_after);
void BKE_collection_reinsert_into(struct SceneCollection *sc_reinsert, struct SceneCollection *sc_into);
bool BKE_collection_move_above(const struct Scene *scene, struct SceneCollection *sc_dst, struct SceneCollection *sc_src);
bool BKE_collection_move_below(const struct Scene *scene, struct SceneCollection *sc_dst, struct SceneCollection *sc_src);
bool BKE_collection_move_into(const struct Scene *scene, struct SceneCollection *sc_dst, struct SceneCollection *sc_src);
typedef void (*BKE_scene_objects_Cb)(struct Object *ob, void *data);
typedef void (*BKE_scene_collections_Cb)(struct SceneCollection *ob, void *data);
void BKE_scene_collections_callback(struct Scene *scene, BKE_scene_collections_Cb callback, void *data);
void BKE_scene_objects_callback(struct Scene *scene, BKE_scene_objects_Cb callback, void *data);
/* iterators */
void BKE_scene_collections_Iterator_begin(struct Iterator *iter, void *data_in);
void BKE_scene_collections_Iterator_next(struct Iterator *iter);
void BKE_scene_collections_Iterator_end(struct Iterator *iter);
void BKE_scene_objects_Iterator_begin(struct Iterator *iter, void *data_in);
void BKE_scene_objects_Iterator_next(struct Iterator *iter);
void BKE_scene_objects_Iterator_end(struct Iterator *iter);
#define FOREACH_SCENE_COLLECTION(scene, _instance) \
ITER_BEGIN(BKE_scene_collections_Iterator_begin, \
BKE_scene_collections_Iterator_next, \
BKE_scene_collections_Iterator_end, \
scene, SceneCollection *, _instance)
#define FOREACH_SCENE_COLLECTION_END \
ITER_END
#define FOREACH_SCENE_OBJECT(scene, _instance) \
ITER_BEGIN(BKE_scene_objects_Iterator_begin, \
BKE_scene_objects_Iterator_next, \
BKE_scene_objects_Iterator_end, \
scene, Object *, _instance)
#define FOREACH_SCENE_OBJECT_END \
ITER_END
#ifdef __cplusplus
}
#endif
#endif /* __BKE_COLLECTION_H__ */

View File

@@ -40,12 +40,17 @@ extern "C" {
struct ARegion;
struct bScreen;
struct CacheFile;
struct Depsgraph;
struct LayerCollection;
struct ListBase;
struct Main;
struct Object;
struct Base;
struct PointerRNA;
struct ReportList;
struct Scene;
struct SceneCollection;
struct SceneLayer;
struct ScrArea;
struct SpaceLink;
struct View3D;
@@ -239,6 +244,9 @@ int ctx_data_list_count(const bContext *C, int (*func)(const bContext *, ListBas
struct Main *CTX_data_main(const bContext *C);
struct Scene *CTX_data_scene(const bContext *C);
struct LayerCollection *CTX_data_layer_collection(const bContext *C);
struct SceneCollection *CTX_data_scene_collection(const bContext *C);
struct SceneLayer *CTX_data_scene_layer(const bContext *C);
struct ToolSettings *CTX_data_tool_settings(const bContext *C);
const char *CTX_data_mode_string(const bContext *C);
@@ -296,6 +304,7 @@ int CTX_data_visible_gpencil_layers(const bContext *C, ListBase *list);
int CTX_data_editable_gpencil_layers(const bContext *C, ListBase *list);
int CTX_data_editable_gpencil_strokes(const bContext *C, ListBase *list);
struct Depsgraph *CTX_data_depsgraph(const bContext *C);
#ifdef __cplusplus
}

View File

@@ -44,6 +44,7 @@
extern "C" {
#endif
struct Depsgraph;
struct ID;
struct Main;
struct Object;
@@ -174,6 +175,10 @@ const char *DAG_get_node_name(struct Scene *scene, void *node_v);
short DAG_get_eval_flags_for_object(struct Scene *scene, void *object);
bool DAG_is_acyclic(struct Scene *scene);
/* ************************ DAG ********************* */
struct Object *DAG_get_object(struct Depsgraph *depsgraph, struct Object *ob);
#ifdef __cplusplus
}
#endif

View File

@@ -33,6 +33,7 @@
* \author nzc
*/
struct BaseLegacy;
struct Base;
struct EvaluationContext;
struct Group;
@@ -44,8 +45,8 @@ void BKE_group_free(struct Group *group);
struct Group *BKE_group_add(struct Main *bmain, const char *name);
struct Group *BKE_group_copy(struct Main *bmain, struct Group *group);
void BKE_group_make_local(struct Main *bmain, struct Group *group, const bool lib_local);
bool BKE_group_object_add(struct Group *group, struct Object *ob, struct Scene *scene, struct Base *base);
bool BKE_group_object_unlink(struct Group *group, struct Object *ob, struct Scene *scene, struct Base *base);
bool BKE_group_object_add(struct Group *group, struct Object *ob);
bool BKE_group_object_unlink(struct Group *group, struct Object *ob);
struct Group *BKE_group_object_find(struct Group *group, struct Object *ob);
bool BKE_group_object_exists(struct Group *group, struct Object *ob);
bool BKE_group_object_cyclic_check(struct Main *bmain, struct Object *object, struct Group *group);

View File

@@ -0,0 +1,239 @@
/*
* ***** 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.
*
* Contributor(s): Blender Foundation, Dalai Felinto
*
* ***** END GPL LICENSE BLOCK *****
*/
#ifndef __BKE_LAYER_H__
#define __BKE_LAYER_H__
/** \file blender/blenkernel/BKE_layer.h
* \ingroup bke
*/
#include "BKE_collection.h"
#ifdef __cplusplus
extern "C" {
#endif
#define TODO_LAYER_SYNC /* syncing of SceneCollection and LayerCollection trees*/
#define TODO_LAYER_SYNC_FILTER /* syncing of filter_objects across all trees */
#define TODO_LAYER_OVERRIDE /* CollectionOverride */
#define TODO_LAYER_CONTEXT /* get/set current (context) SceneLayer */
#define TODO_LAYER_BASE /* BaseLegacy to Base related TODO */
#define TODO_LAYER_OPERATORS /* collection mamanger and property panel operators */
#define TODO_LAYER_DEPSGRAPH /* placeholder for real Depsgraph fix */
#define TODO_LAYER /* generic todo */
#define ROOT_PROP "root"
struct EvaluationContext;
struct LayerCollection;
struct ID;
struct IDProperty;
struct ListBase;
struct Main;
struct Object;
struct Base;
struct RenderEngine;
struct Scene;
struct SceneCollection;
struct SceneLayer;
struct SceneLayer *BKE_scene_layer_render_active(const struct Scene *scene);
struct SceneLayer *BKE_scene_layer_context_active(struct Scene *scene);
struct SceneLayer *BKE_scene_layer_add(struct Scene *scene, const char *name);
bool BKE_scene_layer_remove(struct Main *bmain, struct Scene *scene, struct SceneLayer *sl);
void BKE_scene_layer_free(struct SceneLayer *sl);
void BKE_scene_layer_engine_set(struct SceneLayer *sl, const char *engine);
void BKE_scene_layer_selected_objects_tag(struct SceneLayer *sl, const int tag);
struct SceneLayer *BKE_scene_layer_find_from_collection(const struct Scene *scene, struct LayerCollection *lc);
struct Base *BKE_scene_layer_base_find(struct SceneLayer *sl, struct Object *ob);
void BKE_scene_layer_base_deselect_all(struct SceneLayer *sl);
void BKE_scene_layer_base_select(struct SceneLayer *sl, struct Base *selbase);
void BKE_layer_collection_free(struct SceneLayer *sl, struct LayerCollection *lc);
struct LayerCollection *BKE_layer_collection_active(struct SceneLayer *sl);
int BKE_layer_collection_count(struct SceneLayer *sl);
int BKE_layer_collection_findindex(struct SceneLayer *sl, const struct LayerCollection *lc);
bool BKE_layer_collection_move_above(const struct Scene *scene, struct LayerCollection *lc_dst, struct LayerCollection *lc_src);
bool BKE_layer_collection_move_below(const struct Scene *scene, struct LayerCollection *lc_dst, struct LayerCollection *lc_src);
bool BKE_layer_collection_move_into(const struct Scene *scene, struct LayerCollection *lc_dst, struct LayerCollection *lc_src);
void BKE_layer_collection_resync(const struct Scene *scene, const struct SceneCollection *sc);
struct LayerCollection *BKE_collection_link(struct SceneLayer *sl, struct SceneCollection *sc);
void BKE_collection_unlink(struct SceneLayer *sl, struct LayerCollection *lc);
bool BKE_scene_layer_has_collection(struct SceneLayer *sl, const struct SceneCollection *sc);
bool BKE_scene_has_object(struct Scene *scene, struct Object *ob);
/* syncing */
void BKE_layer_sync_new_scene_collection(struct Scene *scene, const struct SceneCollection *sc_parent, struct SceneCollection *sc);
void BKE_layer_sync_object_link(const struct Scene *scene, struct SceneCollection *sc, struct Object *ob);
void BKE_layer_sync_object_unlink(const struct Scene *scene, struct SceneCollection *sc, struct Object *ob);
/* override */
void BKE_collection_override_datablock_add(struct LayerCollection *lc, const char *data_path, struct ID *id);
/* engine settings */
typedef void (*CollectionEngineSettingsCB)(struct RenderEngine *engine, struct IDProperty *props);
struct IDProperty *BKE_layer_collection_engine_get(struct LayerCollection *lc, const int type, const char *engine_name);
struct IDProperty *BKE_object_collection_engine_get(struct Object *ob, const int type, const char *engine_name);
void BKE_layer_collection_engine_settings_callback_register(struct Main *bmain, const char *engine_name, CollectionEngineSettingsCB func);
void BKE_layer_collection_engine_settings_callback_free(void);
void BKE_layer_collection_engine_settings_create(struct IDProperty *root);
void BKE_collection_engine_property_add_float(struct IDProperty *props, const char *name, float value);
void BKE_collection_engine_property_add_int(struct IDProperty *props, const char *name, int value);
void BKE_collection_engine_property_add_bool(struct IDProperty *props, const char *name, bool value);
int BKE_collection_engine_property_value_get_int(struct IDProperty *props, const char *name);
float BKE_collection_engine_property_value_get_float(struct IDProperty *props, const char *name);
bool BKE_collection_engine_property_value_get_bool(struct IDProperty *props, const char *name);
void BKE_collection_engine_property_value_set_int(struct IDProperty *props, const char *name, int value);
void BKE_collection_engine_property_value_set_float(struct IDProperty *props, const char *name, float value);
void BKE_collection_engine_property_value_set_bool(struct IDProperty *props, const char *name, bool value);
/* evaluation */
void BKE_layer_eval_layer_collection_pre(struct EvaluationContext *eval_ctx,
struct Scene *scene,
struct SceneLayer *scene_layer);
void BKE_layer_eval_layer_collection(struct EvaluationContext *eval_ctx,
struct Scene *scene,
struct LayerCollection *layer_collection,
struct LayerCollection *parent_layer_collection);
void BKE_layer_eval_layer_collection_post(struct EvaluationContext *eval_ctx,
struct SceneLayer *scene_layer);
/* iterators */
void BKE_selected_objects_Iterator_begin(Iterator *iter, void *data_in);
void BKE_selected_objects_Iterator_next(Iterator *iter);
void BKE_selected_objects_Iterator_end(Iterator *iter);
void BKE_visible_objects_Iterator_begin(Iterator *iter, void *data_in);
void BKE_visible_objects_Iterator_next(Iterator *iter);
void BKE_visible_objects_Iterator_end(Iterator *iter);
void BKE_visible_bases_Iterator_begin(Iterator *iter, void *data_in);
void BKE_visible_bases_Iterator_next(Iterator *iter);
void BKE_visible_bases_Iterator_end(Iterator *iter);
#define FOREACH_SELECTED_OBJECT(sl, _instance) \
ITER_BEGIN(BKE_selected_objects_Iterator_begin, \
BKE_selected_objects_Iterator_next, \
BKE_selected_objects_Iterator_end, \
sl, Object *, _instance)
#define FOREACH_SELECTED_OBJECT_END \
ITER_END
#define FOREACH_VISIBLE_OBJECT(sl, _instance) \
ITER_BEGIN(BKE_visible_objects_Iterator_begin, \
BKE_visible_objects_Iterator_next, \
BKE_visible_objects_Iterator_end, \
sl, Object *, _instance)
#define FOREACH_VISIBLE_OBJECT_END \
ITER_END
#define FOREACH_VISIBLE_BASE(sl, _instance) \
ITER_BEGIN(BKE_visible_bases_Iterator_begin, \
BKE_visible_bases_Iterator_next, \
BKE_visible_bases_Iterator_end, \
sl, Base *, _instance)
#define FOREACH_VISIBLE_BASE_END \
ITER_END
#define FOREACH_OBJECT(sl, _instance) \
{ \
Object *_instance; \
Base *base; \
for (base = (sl)->object_bases.first; base; base = base->next) { \
_instance = base->object;
#define FOREACH_OBJECT_END \
} \
}
#define FOREACH_OBJECT_FLAG(scene, sl, flag, _instance) \
{ \
IteratorBeginCb func_begin; \
IteratorCb func_next, func_end; \
void *data_in; \
\
if (flag == SELECT) { \
func_begin = &BKE_selected_objects_Iterator_begin; \
func_next = &BKE_selected_objects_Iterator_next; \
func_end = &BKE_selected_objects_Iterator_end; \
data_in = (sl); \
} \
else { \
func_begin = BKE_scene_objects_Iterator_begin; \
func_next = BKE_scene_objects_Iterator_next; \
func_end = BKE_scene_objects_Iterator_end; \
data_in = (scene); \
} \
ITER_BEGIN(func_begin, func_next, func_end, data_in, Object *, _instance)
#define FOREACH_OBJECT_FLAG_END \
ITER_END \
}
/* temporary hacky solution waiting for CoW depsgraph implementation */
#define DEG_OBJECT_ITER(sl_, instance_) \
{ \
/* flush all the depsgraph data to objects */ \
Object *instance_; \
Base *base_; \
for (base_ = (sl_)->object_bases.first; base_; base_ = base_->next) { \
if ((base_->flag & BASE_VISIBLED) != 0) { \
instance_ = base_->object; \
instance_->base_flag = base_->flag; \
instance_->base_collection_properties = base_->collection_properties;
#define DEG_OBJECT_ITER_END \
} \
} \
}
#ifdef __cplusplus
}
#endif
#endif /* __BKE_LAYER_H__ */

View File

@@ -0,0 +1,50 @@
/*
* ***** 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) 2017 by Blender Foundation.
* All rights reserved.
*
* Contributor(s): Blender Foundation, Mike Erwin, Dalai Felinto
*
* ***** END GPL LICENSE BLOCK *****
*/
#ifndef __BKE_MESH_RENDER_H__
#define __BKE_MESH_RENDER_H__
/** \file BKE_mesh_render.h
* \ingroup bke
*/
struct Batch;
struct Mesh;
void BKE_mesh_batch_cache_dirty(struct Mesh *me);
void BKE_mesh_batch_selection_dirty(struct Mesh *me);
void BKE_mesh_batch_cache_clear(struct Mesh *me);
void BKE_mesh_batch_cache_free(struct Mesh *me);
struct Batch *BKE_mesh_batch_cache_get_all_edges(struct Mesh *me);
struct Batch *BKE_mesh_batch_cache_get_all_triangles(struct Mesh *me);
struct Batch *BKE_mesh_batch_cache_get_triangles_with_normals(struct Mesh *me);
struct Batch *BKE_mesh_batch_cache_get_points_with_normals(struct Mesh *me);
struct Batch *BKE_mesh_batch_cache_get_all_verts(struct Mesh *me);
struct Batch *BKE_mesh_batch_cache_get_fancy_edges(struct Mesh *me);
struct Batch *BKE_mesh_batch_cache_get_overlay_triangles(struct Mesh *me);
struct Batch *BKE_mesh_batch_cache_get_overlay_loose_edges(struct Mesh *me);
struct Batch *BKE_mesh_batch_cache_get_overlay_loose_verts(struct Mesh *me);
struct Batch *BKE_mesh_batch_cache_get_overlay_facedots(struct Mesh *me);
#endif /* __BKE_MESH_RENDER_H__ */

View File

@@ -260,15 +260,6 @@ typedef struct ModifierTypeInfo {
*/
bool (*isDisabled)(struct ModifierData *md, int userRenderParams);
/* Add the appropriate relations to the DEP graph depending on the
* modifier data.
*
* This function is optional.
*/
void (*updateDepgraph)(struct ModifierData *md, struct DagForest *forest,
struct Main *bmain, struct Scene *scene,
struct Object *ob, struct DagNode *obNode);
/* Add the appropriate relations to the dependency graph.
*
* This function is optional.

View File

@@ -687,6 +687,13 @@ bool BKE_node_tree_iter_step(struct NodeTreeIterStore *ntreeiter,
}
/** \} */
/* -------------------------------------------------------------------- */
/** \name Node Tree
*/
void BKE_nodetree_remove_layer_n(struct bNodeTree *ntree, struct Scene *scene, const int layer_index);
/* -------------------------------------------------------------------- */
/** \name Shader Nodes
*/

View File

@@ -35,9 +35,10 @@ extern "C" {
#include "BLI_compiler_attrs.h"
struct Base;
struct BaseLegacy;
struct EvaluationContext;
struct Scene;
struct SceneLayer;
struct Object;
struct BoundBox;
struct View3D;
@@ -89,9 +90,9 @@ struct Object *BKE_object_add_only_object(
int type, const char *name)
ATTR_NONNULL(1) ATTR_RETURNS_NONNULL;
struct Object *BKE_object_add(
struct Main *bmain, struct Scene *scene,
struct Main *bmain, struct Scene *scene, struct SceneLayer *sl,
int type, const char *name)
ATTR_NONNULL(1, 2) ATTR_RETURNS_NONNULL;
ATTR_NONNULL(1, 2, 3) ATTR_RETURNS_NONNULL;
void *BKE_object_obdata_add_from_type(
struct Main *bmain,
int type, const char *name)
@@ -101,9 +102,9 @@ void BKE_object_lod_add(struct Object *ob);
void BKE_object_lod_sort(struct Object *ob);
bool BKE_object_lod_remove(struct Object *ob, int level);
void BKE_object_lod_update(struct Object *ob, const float camera_position[3]);
bool BKE_object_lod_is_usable(struct Object *ob, struct Scene *scene);
struct Object *BKE_object_lod_meshob_get(struct Object *ob, struct Scene *scene);
struct Object *BKE_object_lod_matob_get(struct Object *ob, struct Scene *scene);
bool BKE_object_lod_is_usable(struct Object *ob, struct SceneLayer *sl);
struct Object *BKE_object_lod_meshob_get(struct Object *ob, struct SceneLayer *sl);
struct Object *BKE_object_lod_matob_get(struct Object *ob, struct SceneLayer *sl);
struct Object *BKE_object_copy_ex(struct Main *bmain, struct Object *ob, bool copy_caches);
struct Object *BKE_object_copy(struct Main *bmain, struct Object *ob);
@@ -115,7 +116,7 @@ bool BKE_object_obdata_is_libdata(struct Object *ob);
void BKE_object_obdata_size_init(struct Object *ob, const float scale);
void BKE_object_scale_to_mat3(struct Object *ob, float mat[3][3]);
void BKE_object_rot_to_mat3(struct Object *ob, float mat[3][3], bool use_drot);
void BKE_object_rot_to_mat3(const struct Object *ob, float mat[3][3], bool use_drot);
void BKE_object_mat3_to_rot(struct Object *ob, float mat[3][3], bool use_compat);
void BKE_object_to_mat3(struct Object *ob, float mat[3][3]);
void BKE_object_to_mat4(struct Object *ob, float mat[4][4]);
@@ -152,8 +153,7 @@ bool BKE_object_minmax_dupli(struct Scene *scene, struct Object *ob, float r_min
void BKE_object_foreach_display_point(struct Object *ob, float obmat[4][4],
void (*func_cb)(const float[3], void *), void *user_data);
void BKE_scene_foreach_display_point(struct Scene *scene,
struct View3D *v3d,
const short flag,
struct SceneLayer *sl,
void (*func_cb)(const float[3], void *), void *user_data);
bool BKE_object_parent_loop_check(const struct Object *parent, const struct Object *ob);
@@ -255,9 +255,9 @@ typedef enum eObjectSet {
OB_SET_ALL /* All Objects */
} eObjectSet;
struct LinkNode *BKE_object_relational_superset(struct Scene *scene, eObjectSet objectSet, eObRelationTypes includeFilter);
struct LinkNode *BKE_object_relational_superset(struct SceneLayer *scene_layer, eObjectSet objectSet, eObRelationTypes includeFilter);
struct LinkNode *BKE_object_groups(struct Object *ob);
void BKE_object_groups_clear(struct Scene *scene, struct Base *base, struct Object *object);
void BKE_object_groups_clear(struct Object *object);
struct KDTree *BKE_object_as_kdtree(struct Object *ob, int *r_tot);

View File

@@ -36,8 +36,9 @@ void *BKE_outliner_treehash_create_from_treestore(struct BLI_mempool *treestore)
/* full rebuild for already allocated hashtable */
void *BKE_outliner_treehash_rebuild_from_treestore(void *treehash, struct BLI_mempool *treestore);
/* full rebuild for already allocated hashtable */
/* Add/remove hashtable elements */
void BKE_outliner_treehash_add_element(void *treehash, struct TreeStoreElem *elem);
void BKE_outliner_treehash_remove_element(void *treehash, struct TreeStoreElem *elem);
/* find first unused element with specific type, nr and id */
struct TreeStoreElem *BKE_outliner_treehash_lookup_unused(void *treehash, short type, short nr, struct ID *id);

View File

@@ -52,6 +52,7 @@ struct PaletteColor;
struct PBVH;
struct ReportList;
struct Scene;
struct SceneLayer;
struct Sculpt;
struct StrokeCache;
struct Tex;
@@ -89,8 +90,8 @@ typedef enum OverlayControlFlags {
PAINT_OVERLAY_OVERRIDE_PRIMARY | \
PAINT_OVERLAY_OVERRIDE_CURSOR)
void BKE_paint_invalidate_overlay_tex(struct Scene *scene, const struct Tex *tex);
void BKE_paint_invalidate_cursor_overlay(struct Scene *scene, struct CurveMapping *curve);
void BKE_paint_invalidate_overlay_tex(struct Scene *scene, struct SceneLayer *sl, const struct Tex *tex);
void BKE_paint_invalidate_cursor_overlay(struct Scene *scene, struct SceneLayer *sl, struct CurveMapping *curve);
void BKE_paint_invalidate_overlay_all(void);
OverlayControlFlags BKE_paint_get_overlay_flags(void);
void BKE_paint_reset_overlay_invalid(OverlayControlFlags flag);
@@ -120,7 +121,7 @@ void BKE_paint_cavity_curve_preset(struct Paint *p, int preset);
short BKE_paint_object_mode_from_paint_mode(PaintMode mode);
struct Paint *BKE_paint_get_active_from_paintmode(struct Scene *sce, PaintMode mode);
struct Paint *BKE_paint_get_active(struct Scene *sce);
struct Paint *BKE_paint_get_active(struct Scene *sce, struct SceneLayer *sl);
struct Paint *BKE_paint_get_active_from_context(const struct bContext *C);
PaintMode BKE_paintmode_get_active_from_context(const struct bContext *C);
struct Brush *BKE_paint_brush(struct Paint *paint);

View File

@@ -38,14 +38,17 @@ extern "C" {
#endif
struct AviCodecData;
struct Base;
struct BaseLegacy;
struct EvaluationContext;
struct Main;
struct Object;
struct Base;
struct QuicktimeCodecData;
struct RenderData;
struct SceneRenderLayer;
struct Scene;
struct SceneCollection;
struct SceneLayer;
struct UnitSettings;
struct Main;
@@ -70,13 +73,15 @@ void BKE_scene_free(struct Scene *sce);
void BKE_scene_init(struct Scene *sce);
struct Scene *BKE_scene_add(struct Main *bmain, const char *name);
void BKE_scene_remove_rigidbody_object(struct Scene *scene, struct Object *ob);
/* base functions */
struct Base *BKE_scene_base_find_by_name(struct Scene *scene, const char *name);
struct Base *BKE_scene_base_find(struct Scene *scene, struct Object *ob);
struct Base *BKE_scene_base_add(struct Scene *sce, struct Object *ob);
void BKE_scene_base_unlink(struct Scene *sce, struct Base *base);
struct BaseLegacy *BKE_scene_base_find_by_name(struct Scene *scene, const char *name);
struct BaseLegacy *BKE_scene_base_find(struct Scene *scene, struct Object *ob);
struct BaseLegacy *BKE_scene_base_add(struct Scene *sce, struct Object *ob);
void BKE_scene_base_unlink(struct Scene *sce, struct BaseLegacy *base);
void BKE_scene_base_deselect_all(struct Scene *sce);
void BKE_scene_base_select(struct Scene *sce, struct Base *selbase);
void BKE_scene_base_select(struct Scene *sce, struct BaseLegacy *selbase);
/* Scene base iteration function.
* Define struct here, so no need to bother with alloc/free it.
@@ -90,10 +95,14 @@ typedef struct SceneBaseIter {
} SceneBaseIter;
int BKE_scene_base_iter_next(struct EvaluationContext *eval_ctx, struct SceneBaseIter *iter,
struct Scene **scene, int val, struct Base **base, struct Object **ob);
struct Scene **scene, int val, struct BaseLegacy **base, struct Object **ob);
void BKE_scene_base_flag_to_objects(struct Scene *scene);
void BKE_scene_base_flag_to_objects(struct SceneLayer *sl);
void BKE_scene_base_flag_from_objects(struct Scene *scene);
void BKE_scene_base_flag_sync_from_base(struct BaseLegacy *base);
void BKE_scene_base_flag_sync_from_object(struct BaseLegacy *base);
void BKE_scene_object_base_flag_sync_from_base(struct Base *base);
void BKE_scene_object_base_flag_sync_from_object(struct Base *base);
void BKE_scene_set_background(struct Main *bmain, struct Scene *sce);
struct Scene *BKE_scene_set_name(struct Main *bmain, const char *name);
@@ -103,6 +112,8 @@ void BKE_scene_groups_relink(struct Scene *sce);
void BKE_scene_make_local(struct Main *bmain, struct Scene *sce, const bool lib_local);
struct Scene *BKE_scene_find_from_collection(const struct Main *bmain, const struct SceneCollection *scene_collection);
struct Object *BKE_scene_camera_find(struct Scene *sc);
#ifdef DURIAN_CAMERA_SWITCH
struct Object *BKE_scene_camera_switch_find(struct Scene *scene); // DURIAN_CAMERA_SWITCH

View File

@@ -49,6 +49,7 @@ struct bScreen;
struct uiLayout;
struct uiList;
struct wmKeyConfig;
struct wmManipulatorMap;
struct wmNotifier;
struct wmWindow;
struct wmWindowManager;
@@ -96,6 +97,9 @@ typedef struct SpaceType {
/* on startup, define dropboxes for spacetype+regions */
void (*dropboxes)(void);
/* initialize manipulator-map-types and manipulator-group-types with the region */
void (*manipulators)(void);
/* return context data */
int (*context)(const struct bContext *, const char *, struct bContextDataResult *);
@@ -284,6 +288,8 @@ void BKE_spacedata_id_unref(struct ScrArea *sa, struct SpaceLink *sl, struct ID
struct ARegion *BKE_area_region_copy(struct SpaceType *st, struct ARegion *ar);
void BKE_area_region_free(struct SpaceType *st, struct ARegion *ar);
void BKE_screen_area_free(struct ScrArea *sa);
/* Manipulator-maps of a region need to be freed with the region. Uses callback to avoid low-level call. */
void BKE_region_callback_free_manipulatormap_set(void (*callback)(struct wmManipulatorMap *));
struct ARegion *BKE_area_find_region_type(struct ScrArea *sa, int type);
struct ARegion *BKE_area_find_region_active_win(struct ScrArea *sa);
@@ -302,8 +308,8 @@ unsigned int BKE_screen_view3d_layer_all(const struct bScreen *sc) ATTR_WARN_UNU
void BKE_screen_view3d_sync(struct View3D *v3d, struct Scene *scene);
void BKE_screen_view3d_scene_sync(struct bScreen *sc);
void BKE_screen_view3d_main_sync(ListBase *screen_lb, struct Scene *scene);
void BKE_screen_view3d_twmode_remove(struct View3D *v3d, const int i);
void BKE_screen_view3d_main_twmode_remove(ListBase *screen_lb, struct Scene *scene, const int i);
void BKE_screen_view3d_transform_orientation_remove(struct View3D *v3d, const int i);
void BKE_screen_view3d_main_transform_orientation_remove(ListBase *screen_lb, struct Scene *scene, const int i);
void BKE_screen_gpu_fx_validate(struct GPUFXSettings *fx_settings);
/* zoom factor conversion */

View File

@@ -421,7 +421,7 @@ struct Sequence *BKE_sequencer_add_movie_strip(struct bContext *C, ListBase *seq
/* view3d draw callback, run when not in background view */
typedef struct ImBuf *(*SequencerDrawView)(
struct Scene *, struct Object *, int, int,
struct Scene *, struct SceneLayer *sl, struct Object *, int, int,
unsigned int, int, bool, bool, bool,
int, int, bool, const char *,
struct GPUFX *, struct GPUOffScreen *, char[256]);

View File

@@ -30,6 +30,7 @@ set(INC
../blenloader
../blentranslation
../depsgraph
../draw
../gpu
../ikplugin
../imbuf
@@ -85,6 +86,7 @@ set(SRC
intern/camera.c
intern/cdderivedmesh.c
intern/cloth.c
intern/collection.c
intern/collision.c
intern/colortools.c
intern/constraint.c
@@ -133,6 +135,7 @@ set(SRC
intern/mesh_evaluate.c
intern/mesh_mapping.c
intern/mesh_remap.c
intern/mesh_render.c
intern/mesh_validate.c
intern/modifier.c
intern/modifiers_bmesh.c
@@ -156,6 +159,7 @@ set(SRC
intern/pbvh_bmesh.c
intern/pointcache.c
intern/property.c
intern/layer.c
intern/report.c
intern/rigidbody.c
intern/sca.c
@@ -213,6 +217,7 @@ set(SRC
BKE_ccg.h
BKE_cdderivedmesh.h
BKE_cloth.h
BKE_collection.h
BKE_collision.h
BKE_colortools.h
BKE_constraint.h
@@ -257,6 +262,7 @@ set(SRC
BKE_mesh.h
BKE_mesh_mapping.h
BKE_mesh_remap.h
BKE_mesh_render.h
BKE_modifier.h
BKE_movieclip.h
BKE_multires.h
@@ -272,6 +278,7 @@ set(SRC
BKE_pbvh.h
BKE_pointcache.h
BKE_property.h
BKE_layer.h
BKE_report.h
BKE_rigidbody.h
BKE_sca.h
@@ -535,8 +542,4 @@ endif()
# set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} /WX")
#endif()
if(WITH_LEGACY_DEPSGRAPH)
add_definitions(-DWITH_LEGACY_DEPSGRAPH)
endif()
blender_add_lib(bf_blenkernel "${SRC}" "${INC}" "${INC_SYS}")

View File

@@ -76,8 +76,8 @@ static DerivedMesh *navmesh_dm_createNavMeshForVisualization(DerivedMesh *dm);
#include "BLI_sys_types.h" /* for intptr_t support */
#include "GPU_buffers.h"
#include "GPU_glew.h"
#include "GPU_shader.h"
#include "GPU_immediate.h"
#ifdef WITH_OPENSUBDIV
# include "BKE_depsgraph.h"
@@ -317,7 +317,7 @@ void DM_init(
dm->numPolyData = numPolys;
DM_init_funcs(dm);
dm->needsFree = 1;
dm->auto_bump_scale = -1.0f;
dm->dirty = 0;
@@ -377,6 +377,7 @@ int DM_release(DerivedMesh *dm)
if (dm->needsFree) {
bvhcache_free(&dm->bvhCache);
GPU_drawobject_free(dm);
CustomData_free(&dm->vertData, dm->numVertData);
CustomData_free(&dm->edgeData, dm->numEdgeData);
CustomData_free(&dm->faceData, dm->numTessFaceData);
@@ -3937,7 +3938,6 @@ BLI_INLINE void navmesh_intToCol(int i, float col[3])
static void navmesh_drawColored(DerivedMesh *dm)
{
int a, glmode;
MVert *mvert = (MVert *)CustomData_get_layer(&dm->vertData, CD_MVERT);
MFace *mface = (MFace *)CustomData_get_layer(&dm->faceData, CD_MFACE);
int *polygonIdx = (int *)CustomData_get_layer(&dm->polyData, CD_RECAST);
@@ -3952,34 +3952,42 @@ static void navmesh_drawColored(DerivedMesh *dm)
dm->drawEdges(dm, 0, 1);
#endif
/* if (GPU_buffer_legacy(dm) ) */ /* TODO - VBO draw code, not high priority - campbell */
{
DEBUG_VBO("Using legacy code. drawNavMeshColored\n");
glBegin(glmode = GL_QUADS);
for (a = 0; a < dm->numTessFaceData; a++, mface++) {
int new_glmode = mface->v4 ? GL_QUADS : GL_TRIANGLES;
int pi = polygonIdx[a];
if (pi <= 0) {
zero_v3(col);
}
else {
navmesh_intToCol(pi, col);
}
VertexFormat *format = immVertexFormat();
unsigned pos = add_attrib(format, "pos", COMP_F32, 3, KEEP_FLOAT);
unsigned color = add_attrib(format, "color", COMP_F32, 3, KEEP_FLOAT);
if (new_glmode != glmode) {
glEnd();
glBegin(glmode = new_glmode);
}
glColor3fv(col);
glVertex3fv(mvert[mface->v1].co);
glVertex3fv(mvert[mface->v2].co);
glVertex3fv(mvert[mface->v3].co);
if (mface->v4) {
glVertex3fv(mvert[mface->v4].co);
}
immBindBuiltinProgram(GPU_SHADER_3D_FLAT_COLOR);
/* Note: batch drawing API would let us share vertices */
immBeginAtMost(PRIM_TRIANGLES, dm->numTessFaceData * 6);
for (int a = 0; a < dm->numTessFaceData; a++, mface++) {
int pi = polygonIdx[a];
if (pi <= 0) {
zero_v3(col);
}
else {
navmesh_intToCol(pi, col);
}
immSkipAttrib(color);
immVertex3fv(pos, mvert[mface->v1].co);
immSkipAttrib(color);
immVertex3fv(pos, mvert[mface->v2].co);
immAttrib3fv(color, col);
immVertex3fv(pos, mvert[mface->v3].co);
if (mface->v4) {
/* this tess face is a quad, so draw the other triangle */
immSkipAttrib(color);
immVertex3fv(pos, mvert[mface->v1].co);
immSkipAttrib(color);
immVertex3fv(pos, mvert[mface->v3].co);
immAttrib3fv(color, col);
immVertex3fv(pos, mvert[mface->v4].co);
}
glEnd();
}
immEnd();
immUnbindProgram();
}
static void navmesh_DM_drawFacesTex(

View File

@@ -283,7 +283,7 @@ void animviz_get_object_motionpaths(Object *ob, ListBase *targets)
/* tweak the object ordering to trick depsgraph into making MotionPath calculations run faster */
static void motionpaths_calc_optimise_depsgraph(Scene *scene, ListBase *targets)
{
Base *base, *baseNext;
BaseLegacy *base, *baseNext;
MPathTarget *mpt;
/* make sure our temp-tag isn't already in use */
@@ -321,7 +321,7 @@ static void motionpaths_calc_update_scene(Scene *scene)
BKE_scene_update_for_newframe(G.main->eval_ctx, G.main, scene, scene->lay);
}
else { /* otherwise we can optimize by restricting updates */
Base *base, *last = NULL;
BaseLegacy *base, *last = NULL;
/* only stuff that moves or needs display still */
DAG_scene_update_flags(G.main, scene, scene->lay, true, false);

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