Optimizing atof and strtod in MSVC 2008

I recently wrote a text parser for Wavefront OBJ files and once I got it all up and running, I was surprised by the performance. I tend to be somewhat performance conscious when writing code so after realizing I had somehow created the slowest OBJ parser known to man, I was perplexed. It was taking 20 seconds to load the Stanford Bunny (4.83MB as an OBJ file with exported normals).

When parsing a 3d mesh from an OBJ file, it is optimal to collapse equal vertices into an indexed list. This is one of the more complicated steps so my suspicion was that something went wrong there. I was using a hash table to do the comparisons so it should have been fast. I disabled that section of code, and timed the load again. It barely affected the result.

Another common pitfall when parsing files is getting stalls from seeking through the file itself. I had already taken that into consideration and just loaded the whole thing into memory for processing. I was out of ideas and decided to profile the load and see what I had done wrong. I learned that almost all of my time was spent in strlen which was a big red flag considering I never even called strlen during my entire load.

Continue reading...

Loading the Stanford Bunny

I decided to get a little framework set up that would let me play around with some graphics code. As a result, I decided that step one would be to get everyone's favorite test model, the Stanford Bunny, loaded and rendering. I'd never actually used the bunny or any of the other Stanford models before so after a little research into where to access them and what format they were in, I came up with a "pipeline" for loading them into my application. I wouldn't call it a great solution, but it worked pretty well for getting something up and running to play with.

Continue reading...

Constraint Relaxation IK in 2D

titleInverse kinematics (IK) solvers often become mathematically intensive or computationally expensive with long kinematic chains or when functioning in higher dimensions. I am going to cover an approach to solving IK that is easy to understand, handles any number of joints, and is easy to implement in any dimension. We will walk through a two dimensional example and I'll present sample code to perform the algorithm.

Continue reading...

Cyclic Coordinate Descent in 2D

title
When performing inverse kinematics (IK) on a complicated bone chain, it can become too complex for an analytical solution. Cyclic Coordinate Descent (CCD) is an alternative that is both easy to implement and efficient to process. We will discuss the algorithm works at a high level, followed by a two-dimensional example and sample code.

CCD solves the IK problem through optimization. Looping through the joints from end to root, we optimize each joint to get the end effector (tip of the final joint) as close to our target as possible. This loop is then repeated until we find a solution or we reach an iteration limit. You can download the RJ_Demo_IK application and source code to see an interactive implementation.

You might also be interested in the following articles on different IK solvers:

Continue reading...

DISQUS for Joomla

In the process of getting my new Joomla! based website up and running, I wanted to add a comment system [Note: My website no longer has a Joomla! backend]. As usual, every free option available had it's own quirks. Some had visual issues, some didn't support threaded replies, and some had conflicts with other Joomla extensions I was using. I ended up liking the DISQUS comment system for Joomla! v1.1 by JoomlaWorks. It integrates the free comment management system, DISQUS, into a site's articles. While I did have to tweak my site template a bit to prevent its JavaScript generated content from drawing over my footer, it covered the rest of my needs.

After testing out the plugin for a while, I started to notice a large issue. Anytime an article was viewed with a different URL, it ended up using a different comment thread. In Joomla!, articles can be seen under different URLs for a number of reasons including changing search engine friendly (SEF) URL settings, recategorizing an article, changing your menu, or viewing an article split into multiple pages. Dissapointed to find yet another problematic plugin, I decided to find the root of the problem and fix it.

Continue reading...