Patch to allow recording of static objects in game engine #35183

Closed
opened 2013-05-02 09:08:21 +02:00 by James Yonan · 9 comments

%%%This patch addresses a limitation in the "Record Animation" feature of the Blender Game Engine, where the motion of static objects animated by logic bricks is not recorded.

The patch allows for recording of the motion of static objects via a checkbox on the Physics panel. All static objects are given a new checkbox called "Record Animation" that appears under the "Actor" and "Ghost" checkboxes on the Physics panel. This checkbox only appears for static objects. When checked, the motion of the static object will be recorded, whenever game-engine recording is enabled via Game>Record Animation.

I've attached the patch as well as a sample blender project. The project is a simple game with a dynamic ball resting on a static cube. When the game is played, the static cube will oscillate back and forth causing the dynamic ball on top to eventually fall off. If you try to record the animation, only the motion of the dynamic ball will be recorded. However if you build blender with this patch, and check the "Record Animation" checkbox in the physics panel for the static cube, both objects will be properly recorded.

Dalai Felinto comment:

My only concern with the patch (and we are better off discussing that in the tracker) is that I would probably have a m_animate property
(instead of objprop.m_static_animate). This way we don't need to check IsDynamic() inside RecordAnimation(). That also means that if you have a dynamic object and temporary disable its Dynamics (via logic bricks) the object will still has its movements recorded, which I think it's reasonable (it may already happen, not sure if the actuator affects the result of IsDynamic() - too late now for me to check the code.

My response:

So you're saying that KX_GameObject::SetStaticAnimate should instead become SetAnimate that would set m_animate member?

But then how should KX_GameObject::SetPhysicsController (how m_bDyna is normally set) interact with the m_animate member? Should it irreversibly set m_animate to true for dynamic objects so that they will be recorded even if the object later loses the dynamic attribute?

James
%%%

%%%This patch addresses a limitation in the "Record Animation" feature of the Blender Game Engine, where the motion of static objects animated by logic bricks is not recorded. The patch allows for recording of the motion of static objects via a checkbox on the Physics panel. All static objects are given a new checkbox called "Record Animation" that appears under the "Actor" and "Ghost" checkboxes on the Physics panel. This checkbox only appears for static objects. When checked, the motion of the static object will be recorded, whenever game-engine recording is enabled via Game>Record Animation. I've attached the patch as well as a sample blender project. The project is a simple game with a dynamic ball resting on a static cube. When the game is played, the static cube will oscillate back and forth causing the dynamic ball on top to eventually fall off. If you try to record the animation, only the motion of the dynamic ball will be recorded. However if you build blender with this patch, and check the "Record Animation" checkbox in the physics panel for the static cube, both objects will be properly recorded. Dalai Felinto comment: My only concern with the patch (and we are better off discussing that in the tracker) is that I would probably have a m_animate property (instead of objprop.m_static_animate). This way we don't need to check IsDynamic() inside RecordAnimation(). That also means that if you have a dynamic object and temporary disable its Dynamics (via logic bricks) the object will still has its movements recorded, which I think it's reasonable (it may already happen, not sure if the actuator affects the result of IsDynamic() - too late now for me to check the code. My response: So you're saying that KX_GameObject::SetStaticAnimate should instead become SetAnimate that would set m_animate member? But then how should KX_GameObject::SetPhysicsController (how m_bDyna is normally set) interact with the m_animate member? Should it irreversibly set m_animate to true for dynamic objects so that they will be recorded even if the object later loses the dynamic attribute? James %%%
Author

Changed status to: 'Open'

Changed status to: 'Open'
Author

%%%Updated patch (blender-static-animate-2.patch):

Changed variable naming to "record animation" such as m_record_animation or m_bRecordAnimation (removed mention of "static") to better communicate that the flag only controls animation recording, not animation itself. For example, a static object might be animated but not recorded if the new checkbox for "Record Animation" in the Physics panel is not checked.

Decoupled m_bRecordAnimation from m_bDyna in KX_GameObject so that m_bDyna or IsDynamic() do not need to be referenced in order to evaluate isRecordAnimation()

Record animation is now enabled in two places in KX_ConvertBulletObject() when

  1. object is dynamic, or

  2. object's "Record Animation" checkbox is checked

KX_ConvertBulletObject() only enables animation recording, never disables it, so an object that dynamically changes its physics type during a game engine session will continue to be recorded if it was initially a dynamic object.

Note that "record animation" flag only causes animation recording if the user has also selected game-engine recording via Game>Record Animation in UI.
%%%

%%%Updated patch (blender-static-animate-2.patch): Changed variable naming to "record animation" such as m_record_animation or m_bRecordAnimation (removed mention of "static") to better communicate that the flag only controls animation recording, not animation itself. For example, a static object might be animated but not recorded if the new checkbox for "Record Animation" in the Physics panel is not checked. Decoupled m_bRecordAnimation from m_bDyna in KX_GameObject so that m_bDyna or IsDynamic() do not need to be referenced in order to evaluate isRecordAnimation() Record animation is now enabled in two places in KX_ConvertBulletObject() when 1. object is dynamic, or 2. object's "Record Animation" checkbox is checked KX_ConvertBulletObject() only enables animation recording, never disables it, so an object that dynamically changes its physics type during a game engine session will continue to be recorded if it was initially a dynamic object. Note that "record animation" flag only causes animation recording if the user has also selected game-engine recording via Game>Record Animation in UI. %%%
Author

%%%For an example of what this patch can do, see:

http://youtu.be/I__iUXl7iNc

In this animation, all of the moving objects (other than the marbles themselves) are static objects whose motion is controlled by logic bricks.

The patch allows the motion of these static objects to be recorded.
%%%

%%%For an example of what this patch can do, see: http://youtu.be/I__iUXl7iNc In this animation, all of the moving objects (other than the marbles themselves) are static objects whose motion is controlled by logic bricks. The patch allows the motion of these static objects to be recorded. %%%
Author
[blender-static-animate-3.patch](https://archive.blender.org/developer/F29786/blender-static-animate-3.patch) Rebased to 2.69.
Member

Added subscriber: @z0r

Added subscriber: @z0r
Member

This looks pretty good to me, and I think it's a good feature to add. But it has been a while since I looked at BGE code. I would need to look more deeply at ResetPhysicsObjectsAnimationIpo and resetNoneDynamicObjectToIpo before I could say I'm 100% OK with it; hopefully I can do that soon.

At this stage I suggest two changes:

  1. Move OB_RECORD_ANIMATION inside the enum that precedes it, and set it to 1 << 23.
  2. If this feature only makes sense for non-dynamic objects, maybe the field should be disabled in the UI for dynamic objects.

Feel free to object if I've misunderstood anything about your patch :)

This looks pretty good to me, and I think it's a good feature to add. But it has been a while since I looked at BGE code. I would need to look more deeply at `ResetPhysicsObjectsAnimationIpo` and `resetNoneDynamicObjectToIpo` before I could say I'm 100% OK with it; hopefully I can do that soon. At this stage I suggest two changes: 1. Move `OB_RECORD_ANIMATION` inside the enum that precedes it, and set it to `1 << 23`. 1. If this feature only makes sense for non-dynamic objects, maybe the field should be [disabled in the UI ](http://www.blender.org/documentation/blender_python_api_2_69_1/bpy.types.UILayout.html#bpy.types.UILayout.enabled) for dynamic objects. Feel free to object if I've misunderstood anything about your patch :)
Author

blender-static-animate-4.patch

Okay, I moved OB_RECORD_ANIMATION inside the enum that precedes it, and set it to 1 << 23.

Yes, the feature only makes sense for non-dynamic objects. The code already hides the "Record Animation" checkbox in the UI for dynamic objects.

James

[blender-static-animate-4.patch](https://archive.blender.org/developer/F32331/blender-static-animate-4.patch) Okay, I moved `OB_RECORD_ANIMATION` inside the enum that precedes it, and set it to `1 << 23`. Yes, the feature only makes sense for non-dynamic objects. The code already hides the "Record Animation" checkbox in the UI for dynamic objects. James
Campbell Barton self-assigned this 2013-12-09 11:58:16 +01:00

Changed status from 'Open' to: 'Resolved'

Changed status from 'Open' to: 'Resolved'

Committed 1831c930a5

Also added Python api access.

Added more comprehensive description to release log:
http://wiki.blender.org/index.php/Dev:Ref/Release_Notes/2.70/Game_Engine

Committed 1831c930a5 Also added Python api access. Added more comprehensive description to release log: http://wiki.blender.org/index.php/Dev:Ref/Release_Notes/2.70/Game_Engine
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
3 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#35183
No description provided.