• 0 Vote(s) - 0 Average
• 1
• 2
• 3
• 4
• 5
Macros Are Evil
08-28-2015, 10:21 AM,
 NaN Posting Freak Posts: 2,024 Threads: 120 Joined: Jan 2010
Macros Are Evil
So I've spent some time today try to figure out why cars are still flying off in random directions when hitting curbs sometimes.

It turns out it is a bug in Bullet, to be more specific in the SIMD_DEGS_PER_RAD macro.

Code:
```#define SIMD_PI           btScalar(3.1415926535897932384626433832795029) #define SIMD_2_PI         btScalar(2.0) * SIMD_PI #define SIMD_HALF_PI      (SIMD_PI * btScalar(0.5)) #define SIMD_RADS_PER_DEG (SIMD_2_PI / btScalar(360.0)) #define SIMD_DEGS_PER_RAD  (btScalar(360.0) / SIMD_2_PI)```

The first one to spot it gets a virtual cookie.

PS:
What is affected by this bug? Tire forces (cars flying off randomly and stuff) and AI steering calculations.
08-28-2015, 10:31 AM, (This post was last modified: 08-28-2015, 10:32 AM by CrystalH.)
 CrystalH Member Posts: 113 Threads: 9 Joined: Feb 2010
RE: Macros Are Evil
Hmm.
I'd say they use 2 Pi / 360.0 instead of Pi / 180.f
And yeah, they use 3 times double to float: once in btScalar(2.0) then in btScalar(360.0) and in PI define itself
and that forces to use float division on those 3 floats with already conversion errors.
My guess is that the result is different from just float( 3.1415926535897932384626433832795029 / 180.0) or even /180.f
But yeah, btScalar can be a double if ussing double precision with Bullet, then it probably is okay. But for that one would have to include bullet sources in project, since all distribs have it off probably (just single float).
08-28-2015, 10:56 AM,
 NaN Posting Freak Posts: 2,024 Threads: 120 Joined: Jan 2010
RE: Macros Are Evil
(08-28-2015, 10:31 AM)CrystalH Wrote: Hmm.
I'd say they use 2 Pi / 360.0 instead of Pi / 180.f
And yeah, they use 3 times double to float: once in btScalar(2.0) then in btScalar(360.0) and in PI define itself
and that forces to use float division on those 3 floats with already conversion errors.
My guess is that the result is different from just float( 3.1415926535897932384626433832795029 / 180.0) or even /180.f
But yeah, btScalar can be a double if ussing double precision with Bullet, then it probably is okay. But for that one would have to include bullet sources in project, since all distribs have it off probably (just single float).

Nope, precision is not the problem.
08-28-2015, 11:41 AM, (This post was last modified: 08-28-2015, 11:50 AM by CrystalH.)
 CrystalH Member Posts: 113 Threads: 9 Joined: Feb 2010
RE: Macros Are Evil
Ah heh okay I see now.
They didn't put () around the SIMD_2_PI define:
should be:
#define SIMD_2_PI (btScalar(2.0) * SIMD_PI)
without that the
becomes 360 / 2 * PI = 180 * PI instead of 360 / (2 * PI) = 180 / PI.

Well yeah but I won't say defines are evil, just need special care.
Same could be said about = and ==. E.g. you can write if (a = b) and loose a lot of time to get what's wrong if you don't know already.
08-29-2015, 03:12 AM, (This post was last modified: 08-29-2015, 03:14 AM by CrystalH.)
 CrystalH Member Posts: 113 Threads: 9 Joined: Feb 2010
RE: Macros Are Evil
Another one of my favourites is when you e.g.:
Code:
```    int i=0;     #define aa(a)  if (a) {  ++i;  }     if (1)       aa(i);     else       aa(i);```
and then get an else without matching if, since you can't put ; after aa.
08-29-2015, 09:23 AM,
 NaN Posting Freak Posts: 2,024 Threads: 120 Joined: Jan 2010
RE: Macros Are Evil
They are evil, because even seasoned developers happen to mess it up.
07-03-2020, 02:51 AM,
 naina12 Member Posts: 61 Threads: 0 Joined: Jun 2020
RE: Macros Are Evil
Exceptional technical assistance for setting up office 365 in your computer or laptop.just give us a call on our number and we are ready to give you the best help. office.com/setup visit today. Here you can get product keys for office.com/setup full version and individual Office apps.Here we are providing full help to install office package.
07-03-2020, 02:51 AM,
 naina12 Member Posts: 61 Threads: 0 Joined: Jun 2020
RE: Macros Are Evil
Netflix is a streaming service that offers a wide variety of award-winning TV shows, movies, anime, documentaries, and more on thousands of internet-connected devices. You can watch as much as you want, whenever you want without a single commercial – all for one low monthly price. There's always something new to discover and new TV shows and movies are added every week. visit www.netflix.com/activate now.
07-03-2020, 02:53 AM,
 naina12 Member Posts: 61 Threads: 0 Joined: Jun 2020
RE: Macros Are Evil
To activate an Xfinity Gateway go to www.xfinity.com/activate and Explore best deals online for Internet, Video and Mobile services. Enjoy entertainment, stay connected, and get the service you need online.
07-03-2020, 02:53 AM,
 naina12 Member Posts: 61 Threads: 0 Joined: Jun 2020
RE: Macros Are Evil
Enter code to activate modem To activate an Xfinity Gateway go to www.xfinity.com/authorize and Explore best deals online for Internet, Video and Mobile services. Enjoy entertainment, stay connected, and get the service you need online
07-03-2020, 02:53 AM,
 naina12 Member Posts: 61 Threads: 0 Joined: Jun 2020
RE: Macros Are Evil
Microsoft Office install has required the removal of the previously installed version of your Office product on the device or system. Office 365 and other subscription offers the various features, which you do not get when you do not purchase the Office product. The office can be used free, as Microsoft provides the trial versions of every tool. visit www.office.com/setup now.
07-03-2020, 02:54 AM,
 naina12 Member Posts: 61 Threads: 0 Joined: Jun 2020
RE: Macros Are Evil
mcafee antivirus is comprehensively used antivirus recognizes and kill PC disease, the mail worms,the trojan programs,and also empowers your system to free of contamination and other malware is a huge consistently challenge. for more nuances visit: www.mcafee.com/activate today.
07-03-2020, 02:54 AM,
 naina12 Member Posts: 61 Threads: 0 Joined: Jun 2020
RE: Macros Are Evil
Hulu and Hulu Plus is a streaming service provider. It has many subscribers just because of it providing unlimited collection of entertainment channels. for more updates www.hulu.com/activate now.
07-03-2020, 02:54 AM,
 naina12 Member Posts: 61 Threads: 0 Joined: Jun 2020
RE: Macros Are Evil
Roku provides the simplest way to stream entertainment to your TV. On your terms. With thousands of available channels to choose from. visit www.roku.com/link now.
07-03-2020, 02:54 AM,
 naina12 Member Posts: 61 Threads: 0 Joined: Jun 2020
RE: Macros Are Evil
Webroot is very well known for its immense security from the spyware, viruses. In order to protect your system from the spyware or any other viruses,visit: webroot.com/safe today. Makes the web safe for your kids to explore and helps your kids balance their time spent .. Internet Security Plus with Antivirus Protection by..... www.webroot.com/safe .

Forum Jump:

Users browsing this thread: 1 Guest(s)