70 Commits

Author SHA1 Message Date
Sebastian Parborg
7fcf2e7d4a Fix T74577: world_to_camera_view broken for off-axis projection
The issue was that the projection would be inverted.
So if you shifted 0.1 along the y axis, world_to_camera_view would act
as if you had shited it -0.1 along the y axis.
2020-05-19 16:27:09 +02:00
Philipp Oeser
dbf48758d9 Fix T73681: Python exception adding Empty objects via object_data_add
with "Enter Edit Mode" enabled

It is valild to add Empties this way, but we cannot enter editmode on
those.
2020-02-10 10:31:02 +01:00
Campbell Barton
f52d60a21d Fix bpy.extras.object_data_add use without an active space 2019-12-11 16:13:44 +11:00
Campbell Barton
a05be009a5 Cleanup: remove unused object_image_guess
This made sense when we had tex-face feature,
since it's removed & unused, remove this function too.

D6079 by @alm
2019-10-29 23:41:17 +11:00
Brecht Van Lommel
604fdb6e85 Spelling fixes in comments and descriptions, patch by luzpaz
Differential Revision: https://developer.blender.org/D3744
2019-07-31 14:27:35 +02:00
Philipp Oeser
77f92b8cb7 Update for Depsgraph API changes
Reviewers: sergey

Differential Revision: https://developer.blender.org/D4881
2019-05-17 12:38:05 +02:00
Campbell Barton
2896ce7bc7 Fix using non-euler cursor orientation
Missed in 06fe2a5e0c5d6
2019-05-16 13:50:00 +10:00
Hans Goudey
06fe2a5e0c Objects: new 3D cursor alignment option when adding objects
The choices are now World, View and 3D Cursor.

This breaks Python API compatibility, add-ons that add objects with this
parameter will need to be updated.

Differential Revision: https://developer.blender.org/D4706
2019-05-15 18:10:58 +02:00
Campbell Barton
7465a5db3b Cleanup: unused args/vars/imports in modules 2019-05-09 13:11:36 +10:00
Campbell Barton
3633a79789 Cleanup: correct misleading classmethod arg 2019-04-19 07:36:07 +02:00
Campbell Barton
ad9addbf46 Cleanup: unused imports 2019-03-17 21:00:56 +11:00
Campbell Barton
af0ab15e1d Fix T62436: New added Torus won't appear in Local View
Add Object.local_view_get/set

Alternate fix which supports removing from local view & checking
if an object is in local view.
Also avoids redundant refresh.

Matches 2.7x Object.layer_local_view capabilities more closely,
without exposing the flag directly.
2019-03-13 10:52:25 +11:00
Campbell Barton
3ea7a5d869 Revert "Fix T62436: New added Torus won't appear in Local View"
This reverts commit 9054b39b27c4198f436329f78af43fe3f3175508.

Using the region data to find the screen & space-data doesn't make sense
since local-view is space-data there is no reason to pass in a region
argument, then lookup the space-data.

There was no way to remove an object or check it's local view state
as there was in 2.7x.

This can be made closer to 2.7x API and simplified.
2019-03-13 10:52:25 +11:00
Dalai Felinto
9054b39b27 Fix T62436: New added Torus won't appear in Local View
I had to add a region3d.local_view_add(ob) for the API.
2019-03-12 17:28:45 -03:00
Campbell Barton
69665bc7f0 RNA: move cursor into own struct
Without this it's impractical to subscribe to any change to the cursor.

Fixes T61969 by having gizmos update on any change to the cursor.
2019-03-01 12:41:40 +11:00
Campbell Barton
0b9a65151d Fix T60410: Crash adjusting torus w/ enter edit-mode preference 2019-01-15 21:36:50 +11:00
Campbell Barton
63fcbfc3a7 RNA: naming, user-preferences -> preferences 2018-12-21 12:55:02 +11:00
Campbell Barton
7493848008 3D View: remove 3D cursor
Use 3D cursor from the scene (was previously used for local-view).
2018-11-26 14:02:09 +11:00
Bastien Montagne
fd65ebf39a Fix T57776: Error when adding a Torus to the scene.
Not all Object.select_set() cases had been updated to new API... Tsst. ;)
2018-11-11 11:22:38 +01:00
Bastien Montagne
7b38df41ae Fix/cleanup RNA viewlayer API.
RNA's ViewLayer would present 'first level' of layer collection as a
list (collection property), when it is actually now only a single item,
same as the scene's master collection.

Note: did not try to update view_layer python tests, those are already
fully broken for quiet some time I guess (they still assume
view_layer.collections to be mutable e.g.)...
2018-11-06 17:20:49 +01:00
Bastien Montagne
defbe14077 Fix object_utils.py's matrix multiplication (use new @ syntax). 2018-09-10 18:03:40 +02:00
Campbell Barton
4b6fa4d897 PyAPI: update scripts for matrix multiply operator
Operators:
- add torus
- align objects
- bake physics
- make dupli faces
- smart project

Templates:
- 3D view ray cast

Other:
- Methods for bones/edit-bones
2018-08-12 15:22:58 +10:00
Brecht Van Lommel
31c49493d1 Fix incorrect active object setting in scripts. 2018-07-24 11:27:05 +02:00
Campbell Barton
09aa799e53 PyAPI: Use annotations for RNA definitions
- Logical use of fields since they define type information.
- Avoids using ordered-dict metaclass.

Properties using regular assignments will print a warning and load,
however the order is undefined.
2018-07-11 22:18:09 +02:00
Campbell Barton
105192e5a2 Cleanup: pep8 2018-07-03 07:13:27 +02:00
Campbell Barton
00fc1d70a7 Merge branch 'master' into blender2.8 2018-07-03 06:58:34 +02:00
Campbell Barton
b66aa0b0a6 Cleanup: pep8 2018-07-03 06:48:44 +02:00
Brecht Van Lommel
2094b45447 3D Viewport: make shading and overlay DNA match UI names.
We should use consistent naming between the internal code and UI whenever
possible, only reason not to is file compatibility.
2018-05-05 15:54:36 +02:00
Campbell Barton
1c24c04e60 Remove workspace object mode, reverts changes w/ 2.8
This caused too many problems syncing object modes
with multiple objects/windows/workspaces, see: D3130 for details.
2018-04-05 18:21:14 +02:00
Campbell Barton
345c6298e9 Object Mode: move to workspace struct
- Read-only access can often use EvaluationContext.object_mode
- Write access to go to WorkSpace.object_mode.
- Some TODO's remain (marked as "TODO/OBMODE")
- Add-ons will need updating
  (context.active_object.mode -> context.workspace.object_mode)
- There will be small/medium issues that still need resolving
  this does work on a basic level though.

See D3037
2018-02-08 21:14:26 +11:00
Campbell Barton
3cb19a3d89 Merge branch 'master' into blender2.8 2017-11-29 18:06:24 +11:00
Campbell Barton
ad7fb1c028 Cleanup: Python imports
Split over lines to diff more easily.
2017-11-29 18:05:41 +11:00
Dalai Felinto
3abe8b3292 Rename any instance of scene layer or render layer in code with view layer
The RenderResult struct still has a listbase of RenderLayer, but that's ok
since this is strictly for rendering.

* Subversion bump (to 2.80.2)
* DNA low level doversion (renames) - only for .blend created since 2.80 started

Note: We can't use DNA_struct_elem_find or get file version in init_structDNA,
so we are manually iterating over the array of the SDNA elements instead.

Note 2: This doversion change with renames can be reverted in a few months. But
so far it's required for 2.8 files created between October 2016 and now.

Reviewers: campbellbarton, sergey

Differential Revision: https://developer.blender.org/D2927
2017-11-23 07:48:23 -02:00
Dalai Felinto
4525357a3a Fix crash when adding Torus in edit mode 2017-05-19 15:33:50 +02: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
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
Campbell Barton
b8710e1468 Fix UV layer bug in object_utils.object_data_add()
Adding a torus in edit-mode, with 'Generate UVs'
for example would either create another UV layer with the default name or
switch to the default UV layer name if it exists.

Now use the existing UV layer if present.
2016-11-19 06:57:55 +11:00
Bastien Montagne
216a3a3826 Fix T49743: Adding torus in edit mode local mode shows error
The 'local' layers were not correctly set when redoing 'add object'
addons using object_utils.py helper (we always want to restore layers
from view in local view, even if we set 'real' layers from operator
afterwards).
2016-10-27 13:23:29 +02:00
Sergey Sharybin
17603b9f01 Fix objects added via py being on the wrong layer when viewport is decoupled from scene 2016-10-11 15:35:14 +02:00
Campbell Barton
c34993160d Fix T46220: Add torus has no 'layers' option
Add layers property for all operators using AddObjectHelper
2015-09-24 01:05:55 +10:00
Campbell Barton
18f228d593 update hand written rst docs
- minor corrections
- link to new manual
- wrap lines at 120
2015-06-18 08:00:46 +10:00
Campbell Barton
847ec075eb Cleanup: pep8 2015-05-17 17:26:01 +10:00
Lukas Tönne
1e02a5ff43 Fix for object_utils.object_data_add: Now supports None obdata for
creating empties.

The documentation says None is a valid argument for obdata (making
empties), but this would cause an exception. Now obdata is only used
when it is defined. An optional name argument can be passed to override
obdata.name as well.
2014-12-10 17:22:26 +01:00
Campbell Barton
88f126f2eb Fix missing include 2014-07-22 11:53:24 +10:00
Campbell Barton
aea00c7a81 Code cleanup: style 2014-02-13 08:52:12 +11:00
Sergey Sharybin
be09e694b1 Fix #37338: Add objects from addon work in a Linked Scene
Added a poll function to add object helper which checks
whether scene is linked or not.

All the primitives which are delivered from this helper
will work properly for linked scenes. If there're still
primitives which are not delivered from this class, well
nothing i can do now.
2013-11-07 08:40:47 +00:00
Campbell Barton
6895a9f11f fix [#36713] crash from adding gear from 'extra objects' addon 2013-09-12 21:01:27 +00:00
Campbell Barton
564902582c rename world_to_camera -> world_to_camera_view 2013-06-16 14:35:15 +00:00
Campbell Barton
93ba74c20a minor edits to world_to_camera() utility function, include Z so you can tell if the points in font of the camera and avoid divide by zero. 2013-06-13 14:07:36 +00:00
Campbell Barton
f173ff531c handy function for getting the 2d camera coords for a worldspace location.
bpy_extras.object_utils.world_to_camera(scene, obj, coord)
2013-06-13 13:51:01 +00:00