Login
Username:

Password:

Remember me



Lost Password?

Register now!
Main Menu
H3D.org Feeds
H3D.org Forum Index
   Programming Issues
     Is this a bug in CoordinateDeformer with multiple haptic devices?
Register To Post

Threaded | Newest First Previous Topic | Next Topic | Bottom
Poster Thread
cgunn
Posted on: 2012/1/4 10:00
Just can't stay away
Joined: 2004/12/7
From: Canberra, Australia
Posts: 98
Is this a bug in CoordinateDeformer with multiple haptic devices?
CoordinateDeformer::deformPoints has the following code (sorry about the formatting - this editor removes indents):

if( is_touched[0] ) {
H3DFloat distance = (resting_points[i] - touch_points[0]).length();
offset = ( penetration_points[0] - touch_points[0] ) * f->get( distance );
}
H3DFloat max_depth_sqr = offset * offset;

for( unsigned int j = 1; j < nr_devices; j++ ) {
if( is_touched[j] ) {
H3DFloat d = (resting_points[i] - touch_points[j] ).length();
Vec3f o = ( penetration_points[j] - touch_points[j] ) * f->get( d );
if( o*o > max_depth_sqr ) {
offset = o;
}
}
}

Note that max_depth_sqr is not reset when a new offset is assigned (near the end). This seems to result in the only last offset value being used, not the one that is the largest. Especially when device[0] is not touching, but device[1] is touching. Then max_depth_sqr stays as 0.0 the whole time. So the very last touching device's offset is used, not the greatest.
This results in unexpected behavior with multiple devices.
Seems like a bug, but I'm not sure.
karlu
Posted on: 2012/1/4 20:38
Guru
Joined: 2004/12/2
From: Sweden
Posts: 758
Re: Is this a bug in CoordinateDeformer with multiple haptic devices?
Definitely sounds like a bug to me. Can you fix it? Maybe you just have to add max_depth_sqr = o*o to inside the condition? It looks a bit strange that only the largest offset should be used. I would suggest a combination of all involved devices instead.

Use the code tags next time, that will save the indentation. Click the less-than-larger-than button in the editor.


----------------
KJ Lundin Palmerius
C Research
Linköping University, Sweden

Markus
Posted on: 2012/1/4 23:26
Webmaster
Joined: 2006/3/27
From: SenseGraphics
Posts: 1903
Re: Is this a bug in CoordinateDeformer with multiple haptic devices?
Looks odd to me as well, would have to test it when I have two devices. Currently I have none.
Strange that noone has noticed it before.
karlu
Posted on: 2012/1/5 1:31
Guru
Joined: 2004/12/2
From: Sweden
Posts: 758
Re: Is this a bug in CoordinateDeformer with multiple haptic devices?
Noone has noticed probably because very few have dual setups.


----------------
KJ Lundin Palmerius
C Research
Linköping University, Sweden

cgunn
Posted on: 2012/1/5 8:02
Just can't stay away
Joined: 2004/12/7
From: Canberra, Australia
Posts: 98
Re: Is this a bug in CoordinateDeformer with multiple haptic devices?
To fix it, not sure what is intended in the code. Why is device[0] being treated differently to any other devices?
karlu
Posted on: 2012/1/5 15:07
Guru
Joined: 2004/12/2
From: Sweden
Posts: 758
Re: Is this a bug in CoordinateDeformer with multiple haptic devices?
There are two ways to find the maximum value. Either you start with a value you know is lower than any value that may be and iterate over all devices, or you start with the value of the first device (if you know one exists) and iterate over the rest of them. The loop is not treating the first device differently, just treating it first. I would not recommend this way of coding since it includes unnecessary duplication of code and may confuse some readers.

You could, for the patch, replace the treatment of the first device with setting max_value to -1 and set the iteration to include index zero.


----------------
KJ Lundin Palmerius
C Research
Linköping University, Sweden

cgunn
Posted on: 2012/1/6 7:59
Just can't stay away
Joined: 2004/12/7
From: Canberra, Australia
Posts: 98
Re: Is this a bug in CoordinateDeformer with multiple haptic devices?
I have a version of CoordinateDeformer that averages the effects of all devices, but cannot submit it as a patch yet as i am having a lot of trouble building H3D with the latest svn update. It seems to need a different external directory contents that I can't find to download. The current svn update gets compilation errors when built against the External that is inside the H3DAPI download from the web site. Where should I be getting External from? I can see a separate download for 64 bit external, but not for 32 bit.
Markus
Posted on: 2012/1/9 15:16
Webmaster
Joined: 2006/3/27
From: SenseGraphics
Posts: 1903
Re: Is this a bug in CoordinateDeformer with multiple haptic devices?
It says in the comment for the External only download that it is for use with 64 and 32 bit Windows. Use that one and it should work ( with the exception of building with entact support, disable that in C-make when generating the project).
cgunn
Posted on: 2012/1/10 14:49
Just can't stay away
Joined: 2004/12/7
From: Canberra, Australia
Posts: 98
Re: Is this a bug in CoordinateDeformer with multiple haptic devices?
OK. Got it and built OK now.
Will put my CoordDeformer.cpp as a patch into the bug report system.
Threaded | Newest First Previous Topic | Next Topic | Top

Register To Post
 



(C) 2012 SenseGraphics AB    ---    Powered by XOOPS