BGE KX_GameObject new 'worldDimensions' and 'localDimensions' properties accessible from Python API #42017
Labels
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
7 Participants
Notifications
Due Date
No due date set.
Dependencies
No dependencies set.
Reference: blender/blender#42017
Loading…
Reference in New Issue
No description provided.
Delete Branch "%!s(<nil>)"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
The Python API misses a "dimensions" property on KX_GameObject. This patch addresses this issue. I don't know if it's the best implementation, but it works.
There are two new functions now:
KX_GameObject:NodeGetWorldDimensions and
KX_GameObject:NodeGetLocalDimensions used to create the new Python accessible variables:
Both new attributes are of type MT_Vector3.
I could not find a simple way to add this to SG_Spatial so instead I'm just calculating the dimensions on the fly in KX_GameObject.KX_GameObject.patch
Changed status to: 'Open'
Added subscriber: @razvanc87
Added subscribers: @Moguri, @brita, @Sergey
KX_GameObject.patch
Just a quick update:
dummy_dimensions
are changed to positive values now.Added subscriber: @solarlune
Added subscriber: @dr.sybren
If I read the code correctly,
KX_GameObject::NodeGetWorldDimensions()
results in a transformation of the world bounding box to local coordinates, only to convert it back to world coordinates. Seems like a waste.I don't disagree. It's my first try at changing / looking at the Blender code so if anyone has a better idea, please do implement it. Also I need to point out that this won't work for font objects which is a shame. So again, if anyone else knows how to do it or if it's possible then you're more than welcome.
What is the motivation for this? Why would this be useful?
You are returning the dimensions of the bounding box, which is axis aligned and may not correspond to the actual dimensions.
It could be better to store the object's dimensions from Blender during the DataConversion step and try to make sure it doesn't change.
@brita storing the bounding box during conversion only works when the object doesn't deform. I'm also curious for the motivation.
@dr.sybren I meant storing the dimensions during conversion, because blender does take into account the object space, instead of a bb.
Then for what could change that in runtime... scaling an object? or if it is a softbody or cases that don't even come up to mind easily. So I foresee an easily broken property, without further motivation I'd say not to add.
So, for the motivation, I decided to make a dimension property available in BGE because I was programatically creating a tiled map with hexagons and to place the hexagons well obviously I needed to get have the dimensions. It seemed rather weird not to be able to get such a basic property from BGE. The workaround at the time for me was to create the hexagon at the proper dimensions and then apply the scaling and use the scale in BGE instead.
And for the rest... the way I did it I was pretty sure wasn't the correct way to do it, but I had to try anyway.
@brita I was thinking about human characters. When you walk, your bounding box keeps changing in size all the time.
@razvanc87 your "workaround" would actually be my first approach ;-)
@dr.sybren but that only mean that the programmer needs to be careful and aware of this and update the dimensions every frame he makes calculations based on it, no?
@razvanc87 I would also programatically do a grid and place scaled objects there. So all good..
as to have to update the dimensions every frame, are your hexagons changing? It is totally scenario dependent.
@dr.sybren anything rotating about would be changing the dimensions of the GE AABB all the time, and I can not foretell if that is what you want or not, or in what coordinate set.
I'd say that to handle this on top of bge instead of inside is best.
@brita I was just making a point to @dr.sybren's statement about the bounding box changes shapes. I didn't need this for my specific scenario
Added subscriber: @JorgeBernalMartinez
Added subscriber: @Blendify
@razvanc87 can you add this to the differential tool?
Hi, it's been so long I thought this was dropped. OK... I just did, I hope I did it right: https://developer.blender.org/D1513
Yes thank you this should get in the master sooner now
Changed status from 'Open' to: 'Resolved'
See reply in the patch.