Driver evaluates to wrong value. #40747

Closed
opened 2014-06-21 20:01:04 +02:00 by Gustav Nilsson · 7 comments

System Information
Windows 8.1 64-bit, Nvidia GTX 580 3GB

Blender Version
Broken: 2.70 - 19e627c, 2.71RC2 - a19c1be

Short description of error

The driver expression "var == 5" evaluates to False when the variable value is 5.

Exact steps for others to reproduce the error

BugReport.blend

Using the file Iincluded

When playing the animation, the cube starts appearing and diappering on certain frames,
when it should be visible on every frame.

I have a driver activating and deactivating a mask modifier based on the position of an empty.

In the driver, the expression "var == 5" is sometimes evaluated to False,
even though the variable value is always 5.000.

The frames it fails on seems to differ between the two Blender versions I tried.

In Blender 2.70, on frame 76, the variable value is exactly 5,
which I can confirm by writing just "var" as the expression, and getting an even 5 as a result.

But the expression "var == 5" returns a 0.

Switching from Local Space to Transform Space,
makes the expression "var == 5" alaways evaluate to True, stopping the cube from disappearing.

The value of the variable is displayed as 5.000 when both using
Local Space and Transform space, but only Transform Space works.

To recreate the issue from scratch.

Add three objects.

Parent Object 1 and Object 2 to Object 3.

Move "Object 2" 5 units along Z.

Add a driver to Object 1 with Transform Channel variable that uses the Z location of Object 2 in Local Space.

Set the expression to var == 5 (the same height as Object 2 has).

Moving Object 3 makes the expression "var == 5" evaluate to False on certain frames.

Changing from Local Space to Transform Space stops the problem.

**System Information** Windows 8.1 64-bit, Nvidia GTX 580 3GB **Blender Version** Broken: 2.70 - 19e627c, 2.71RC2 - a19c1be **Short description of error** The driver expression "var == 5" evaluates to False when the variable value is 5. **Exact steps for others to reproduce the error** [BugReport.blend](https://archive.blender.org/developer/F95194/BugReport.blend) *Using the file Iincluded* When playing the animation, the cube starts appearing and diappering on certain frames, when it should be visible on every frame. I have a driver activating and deactivating a mask modifier based on the position of an empty. In the driver, the expression "var == 5" is sometimes evaluated to False, even though the variable value is always 5.000. The frames it fails on seems to differ between the two Blender versions I tried. In Blender 2.70, on frame 76, the variable value is exactly 5, which I can confirm by writing just "var" as the expression, and getting an even 5 as a result. But the expression "var == 5" returns a 0. Switching from Local Space to Transform Space, makes the expression "var == 5" alaways evaluate to True, stopping the cube from disappearing. The value of the variable is displayed as 5.000 when both using Local Space and Transform space, but only Transform Space works. *To recreate the issue from scratch.* Add three objects. Parent Object 1 and Object 2 to Object 3. Move "Object 2" 5 units along Z. Add a driver to Object 1 with Transform Channel variable that uses the Z location of Object 2 in Local Space. Set the expression to var == 5 (the same height as Object 2 has). Moving Object 3 makes the expression "var == 5" evaluate to False on certain frames. Changing from Local Space to Transform Space stops the problem.
Author

Changed status to: 'Open'

Changed status to: 'Open'
Author

Added subscriber: @GustavN

Added subscriber: @GustavN

Changed status from 'Open' to: 'Archived'

Changed status from 'Open' to: 'Archived'
Bastien Montagne self-assigned this 2014-06-21 21:21:29 +02:00

You are facing the infamous float precision issue (though it would be same thing with doubles, actually). Just have a look at the console, you'll that often, value is actually e.g. 5.000000476837158, not 5.0.

This is a universal issue with floating numbers - exact equality is often not really usable, you should rather check difference between the two numbers is below a given threshold, e.g. you can use this expression:

abs(var - 5.0) < 1e-4

Anyway, thanks for the report, but this is not a bug.

You are facing the infamous float precision issue (though it would be same thing with doubles, actually). Just have a look at the console, you'll that often, value is actually e.g. `5.000000476837158`, not `5.0`. This is a universal issue with floating numbers - exact equality is often not really usable, you should rather check difference between the two numbers is below a given threshold, e.g. you can use this expression: ``` abs(var - 5.0) < 1e-4 ``` Anyway, thanks for the report, but this is not a bug.
Author

Thanks for clarifying the issue (and providing a solution)! I'm sorry for taking up your time.

May I just ask why this doesn't happen when using Transform Space? I thought the only difference between Local Space and Transform Space was the inclusion of constraints. If this is a rounding error, shouldn't it happen for both spaces and not just Local Space?

Thanks for clarifying the issue (and providing a solution)! I'm sorry for taking up your time. May I just ask why this doesn't happen when using Transform Space? I thought the only difference between Local Space and Transform Space was the inclusion of constraints. If this is a rounding error, shouldn't it happen for both spaces and not just Local Space?

Well, transform space contains the “raw” data, without any matrix manipulation in-between, hence its values have suffered no deviation at all. Local space has gone at least across one matrix creation/reading, so…

Well, transform space contains the “raw” data, without any matrix manipulation in-between, hence its values have suffered no deviation at all. Local space has gone at least across one matrix creation/reading, so…
Author

Awesome! Now I understand why it behaved like it did.

Thanks again! :D

Awesome! Now I understand why it behaved like it did. Thanks again! :D
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#40747
No description provided.