localPosition giving world coordinates #32470

Closed
opened 2012-09-03 00:49:58 +02:00 by Will Nielsen · 12 comments

Category: Python

%%%Object A is parented to object B.
Start the game engine and printing A.localPosition gives WORLD coordinates.

If you do realtime parenting in the game engine then localPosition will give you LOCAL coordinates.

So...

A is parented to B.

Start the game.

print( A.localPosition ) --> gives you A's WORLD coordinates

Do:
A.setParent( B ) ### A.setParent( A.parent) also works ###
print( B.localPosition ) --> Will then give you A's LOCAL coordinates


Tested on official linux build 2.63 and on linux test build r49666

I tested localOrientation and localScale and they work correctly giving you local values without needing to reset the parent in realtime.

%%%

**Category**: Python %%%Object A is parented to object B. Start the game engine and printing A.localPosition gives WORLD coordinates. If you do realtime parenting in the game engine then localPosition will give you LOCAL coordinates. So... A is parented to B. Start the game. print( A.localPosition ) --> gives you A's WORLD coordinates Do: A.setParent( B ) ### A.setParent( A.parent) also works ### print( B.localPosition ) --> Will then give you A's LOCAL coordinates **** Tested on official linux build 2.63 and on linux test build r49666 I tested localOrientation and localScale and they work correctly giving you local values without needing to reset the parent in realtime. %%%
Author

Changed status to: 'Open'

Changed status to: 'Open'
Author

%%%I made a typo:
"print( B.localPosition ) --> Will then give you A's LOCAL coordinates"
should be:
"print( A.localPosition ) --> Will then give you A's LOCAL coordinates"%%%

%%%I made a typo: "print( B.localPosition ) --> Will then give you A's LOCAL coordinates" should be: "print( A.localPosition ) --> Will then give you A's LOCAL coordinates"%%%

%%%Moved from Blender 2.6 Bug Tracker to Game Engine%%%

%%%Moved from Blender 2.6 Bug Tracker to Game Engine%%%

%%%confirmed the bug%%%

%%%confirmed the bug%%%
Member

%%%I don't think this is a bug, or if it is one, parenting in Blender must be modified.

Will you got this problem because you parented B to A with A in some other location (or with some other transformation) than the origin (than the identity matrix).
when you do this, you have then to :

. select B,
. shift S, 'cursor to selected' (= at B world position)
. alt-P, 'clear parent inverse'
. SHIFT S, 'selection to cursor' ( B goes back to position)

B local coordinates are now ok.

it's not intuitive at all I agree, and I don't see the need to keep world coord by default when altP

also, in the Blender ui the transform location of parented object displays world coodinates if you did not 'clear parent inverse' as below :
when you rotate or rescale A, the displayed coordinates are neither the world ones (not updated because parented) nor the local ones.
but B.matrix_local.decompose()- [x] in bpy returns the right local location vector... so there's no match between the ui and the bpy.

for me either this ticket :

A/ should be closed, and Blender parenting process should be revised :
. 'clear parent inverse' by default when alt-P so we don't care about A position ....or A parents btw.....,
. keep the current way but as an alt-P option, like : 'parent it with world coordinates for some guru need'

  • bpy and ui info about local position will match,

  • bpy and bge newcomers don't need anymore to figure out what is the trick, which was really like an initiation ritual, something you earn because you search, work, and test a lot,

  • no need to check any of your bone-parented empties when there's a distance calculation bug in your game.................

if A, this ticket should be moved to the Blender tracker

B/ BGE retrieve the local matrix from the bpy B.matrix_local call
but this is still confusing since the info won't match between BGE/BPY and the ui

%%%

%%%I don't think this is a bug, or if it is one, parenting in Blender must be modified. Will you got this problem because you parented B to A with A in some other location (or with some other transformation) than the origin (than the identity matrix). when you do this, you have then to : . select B, . shift S, 'cursor to selected' (= at B world position) . alt-P, 'clear parent inverse' . SHIFT S, 'selection to cursor' ( B goes back to position) B local coordinates are now ok. it's not intuitive at all I agree, and I don't see the need to keep world coord by default when altP also, in the Blender ui the transform location of parented object displays world coodinates if you did not 'clear parent inverse' as below : when you rotate or rescale A, the displayed coordinates are neither the world ones (not updated because parented) nor the local ones. but B.matrix_local.decompose()- [x] in bpy returns the right local location vector... so there's no match between the ui and the bpy. for me either this ticket : A/ should be closed, and Blender parenting process should be revised : . 'clear parent inverse' by default when alt-P so we don't care about A position ....or A parents btw....., . keep the current way but as an alt-P option, like : 'parent it with world coordinates for some guru need' - > bpy and ui info about local position will match, - > bpy and bge newcomers don't need anymore to figure out what is the trick, which was really like an initiation ritual, something you earn because you search, work, and test a lot, - > no need to check any of your bone-parented empties when there's a distance calculation bug in your game................. if A, this ticket should be moved to the Blender tracker B/ BGE retrieve the local matrix from the bpy B.matrix_local call but this is still confusing since the info won't match between BGE/BPY and the ui %%%
Member

Added subscriber: @JorgeBernalMartinez

Added subscriber: @JorgeBernalMartinez
Member

Added subscriber: @Moguri

Added subscriber: @Moguri
Member

@ideasman42, @dfelinto @Moguri

for me this is not a bug as the parenting using world coordinates is the way that blender has to do parenting from long time ago (as described very well by @littleneo including the initiation ritual :-)).

But, we have the following discrepancy: realtime parenting do the parenting in local coordinates.

Then, which is the path we have to follow? Add a new option in CTRL + P --> Set Parent to Object (local coordinates)?

@ideasman42, @dfelinto @Moguri for me this is not a bug as the parenting using world coordinates is the way that blender has to do parenting from long time ago (as described very well by @littleneo including the initiation ritual :-)). But, we have the following discrepancy: realtime parenting do the parenting in local coordinates. Then, which is the path we have to follow? Add a new option in CTRL + P --> Set Parent to Object (local coordinates)?

Added subscriber: @panzergame

Added subscriber: @panzergame

the report can be closed ?

the report can be closed ?

Changed status from 'Open' to: 'Resolved'

Changed status from 'Open' to: 'Resolved'
Porteries Tristan self-assigned this 2016-04-03 15:26:16 +02:00

As @littleneo and @JorgeBernalMartinez explain it's not bug, since there's 7 months without activity of the @k9crunch, i close the task.

As @littleneo and @JorgeBernalMartinez explain it's not bug, since there's 7 months without activity of the @k9crunch, i close the task.
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
6 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#32470
No description provided.