Cursor centering is wrong when the selected vertices distribution is not uniform #65616

Closed
opened 2019-06-07 20:00:53 +02:00 by kursad k · 5 comments
Member

System Information
Operating system: Win 10
Graphics card: Intel

Blender Version
Broken: version: 2.80 (sub 74), branch: blender2.7, commit date: 2019-06-06 00:27, hash: 8b2b79c210, type: Release

Hi

I feel like Cursor to Selected is not making good desicions when centering the cursor. Please see the .blend file and the image for how the issue looks like

  • Open the blend file

  • Tab to edit mode

  • The current selection is there

  • Press "Shift+S" for cursor menu, then choose "Cursor to selection"

As you see in the image(just after cursor to selection) the cursor is wrongly centered on Y axis

blender_yy9WvCpbf9.png

wrong.blend

**System Information** Operating system: Win 10 Graphics card: Intel **Blender Version** Broken: version: 2.80 (sub 74), branch: blender2.7, commit date: 2019-06-06 00:27, hash: 8b2b79c2108b, type: Release Hi I feel like Cursor to Selected is not making good desicions when centering the cursor. Please see the .blend file and the image for how the issue looks like - Open the blend file - Tab to edit mode - The current selection is there - Press "Shift+S" for cursor menu, then choose "Cursor to selection" As you see in the image(just after cursor to selection) the cursor is wrongly centered on Y axis ![blender_yy9WvCpbf9.png](https://archive.blender.org/developer/F7092421/blender_yy9WvCpbf9.png) [wrong.blend](https://archive.blender.org/developer/F7092420/wrong.blend)
Author
Member

Added subscriber: @kursadk

Added subscriber: @kursadk
Author
Member

I just tested this with Python API, and the issue seems to be the result of the center being calculated by averaging the vert locations. Using bounding box of the selected vertices produces much better middle positioning.

Here is a relevant test code to see the issue. If you use c (averaged locations, enable in the code) for the cursor location, it will be the same as the internal cursor to selection which produces the wrong results when the vertices are not uniformly distributed.

Using Bbox to locate the center seems to be better for these situations.

import bpy
import numpy as np
import bmesh
from mathutils import Vector

C=bpy.context
ob=C.object
m=ob.matrix_world


bm=bmesh.from_edit_mesh(ob.data)


verts=np.array([m@v.co for v in bm.verts if v.select])

l=len(verts)

print("\n"*3)
#print(v_np[:,0].mean(), v_np[:,1].mean(),v_np[:,2].mean() )

x_min = verts[:,0].min()
y_min = verts[:,1].min()
z_min = verts[:,2].min()

x_max = verts[:,0].max()
y_max = verts[:,1].max()
z_max = verts[:,2].max()

c=np.array( [verts[:,0].sum()/l, verts[:,1].sum()/l, verts[:,2].sum()/l] )


print(c)
- AVERAGED POSITIONS
- bpy.context.scene.cursor.location=c

#BOUNDING BOX
bpy.context.scene.cursor.location=Vector( ( (x_min+x_max)/2,
                                        (y_min+y_max)/2,
                                        (z_min+z_max)/2 )
                                        )

I just tested this with Python API, and the issue seems to be the result of the center being calculated by averaging the vert locations. Using bounding box of the selected vertices produces much better middle positioning. Here is a relevant test code to see the issue. If you use `c` (averaged locations, enable in the code) for the cursor location, it will be the same as the internal cursor to selection which produces the wrong results when the vertices are not uniformly distributed. Using Bbox to locate the center seems to be better for these situations. ``` import bpy import numpy as np import bmesh from mathutils import Vector C=bpy.context ob=C.object m=ob.matrix_world bm=bmesh.from_edit_mesh(ob.data) verts=np.array([m@v.co for v in bm.verts if v.select]) l=len(verts) print("\n"*3) #print(v_np[:,0].mean(), v_np[:,1].mean(),v_np[:,2].mean() ) x_min = verts[:,0].min() y_min = verts[:,1].min() z_min = verts[:,2].min() x_max = verts[:,0].max() y_max = verts[:,1].max() z_max = verts[:,2].max() c=np.array( [verts[:,0].sum()/l, verts[:,1].sum()/l, verts[:,2].sum()/l] ) print(c) - AVERAGED POSITIONS - bpy.context.scene.cursor.location=c #BOUNDING BOX bpy.context.scene.cursor.location=Vector( ( (x_min+x_max)/2, (y_min+y_max)/2, (z_min+z_max)/2 ) ) ```
kursad k changed title from Wrong cursor centering on Y axis to Cursor centering is wrong when the selected vertices distribution is not uniform 2019-06-08 18:45:18 +02:00

Added subscriber: @ZedDB

Added subscriber: @ZedDB

Changed status from 'Open' to: 'Archived'

Changed status from 'Open' to: 'Archived'
Sebastian Parborg self-assigned this 2019-06-14 14:25:37 +02:00

This is not a but. This is how it is programmed to work. So this is a feature request and should go to: https://blender.community/c/rightclickselect/

This is not a but. This is how it is programmed to work. So this is a feature request and should go to: https://blender.community/c/rightclickselect/
Sign in to join this conversation.
No Label
Interest
Alembic
Interest
Animation & Rigging
Interest
Asset Browser
Interest
Asset Browser Project Overview
Interest
Audio
Interest
Automated Testing
Interest
Blender Asset Bundle
Interest
BlendFile
Interest
Collada
Interest
Compatibility
Interest
Compositing
Interest
Core
Interest
Cycles
Interest
Dependency Graph
Interest
Development Management
Interest
EEVEE
Interest
EEVEE & Viewport
Interest
Freestyle
Interest
Geometry Nodes
Interest
Grease Pencil
Interest
ID Management
Interest
Images & Movies
Interest
Import Export
Interest
Line Art
Interest
Masking
Interest
Metal
Interest
Modeling
Interest
Modifiers
Interest
Motion Tracking
Interest
Nodes & Physics
Interest
OpenGL
Interest
Overlay
Interest
Overrides
Interest
Performance
Interest
Physics
Interest
Pipeline, Assets & IO
Interest
Platforms, Builds & Tests
Interest
Python API
Interest
Render & Cycles
Interest
Render Pipeline
Interest
Sculpt, Paint & Texture
Interest
Text Editor
Interest
Translations
Interest
Triaging
Interest
Undo
Interest
USD
Interest
User Interface
Interest
UV Editing
Interest
VFX & Video
Interest
Video Sequencer
Interest
Virtual Reality
Interest
Vulkan
Interest
Wayland
Interest
Workbench
Interest: X11
Legacy
Blender 2.8 Project
Legacy
Milestone 1: Basic, Local Asset Browser
Legacy
OpenGL Error
Meta
Good First Issue
Meta
Papercut
Meta
Retrospective
Meta
Security
Module
Animation & Rigging
Module
Core
Module
Development Management
Module
EEVEE & Viewport
Module
Grease Pencil
Module
Modeling
Module
Nodes & Physics
Module
Pipeline, Assets & IO
Module
Platforms, Builds & Tests
Module
Python API
Module
Render & Cycles
Module
Sculpt, Paint & Texture
Module
Triaging
Module
User Interface
Module
VFX & Video
Platform
FreeBSD
Platform
Linux
Platform
macOS
Platform
Windows
Priority
High
Priority
Low
Priority
Normal
Priority
Unbreak Now!
Status
Archived
Status
Confirmed
Status
Duplicate
Status
Needs Info from Developers
Status
Needs Information from User
Status
Needs Triage
Status
Resolved
Type
Bug
Type
Design
Type
Known Issue
Type
Patch
Type
Report
Type
To Do
No Milestone
No project
No Assignees
2 Participants
Notifications
Due Date
The due date is invalid or out of range. Please use the format 'yyyy-mm-dd'.

No due date set.

Dependencies

No dependencies set.

Reference: blender/blender#65616
No description provided.