Friday, November 22, 2019

Powerman 5000 once said, "When Worlds Collide" (The end of my collision detection research)

For the past few weeks, I've been researching a lot of information on collision detection and subjects related. It's been an extreme struggle to really hone in on the most used functions a collision detection library should have, which ones are going to get the most use from the Gateware users, and what's within the scope of this project lifetime. Collision detection is a huge subject in itself and ultimately I had to really get a lot of feedback from our LSA and poll both Full Sail students and instructors. In addition to that, I then had to use that information and propose an interface I think is user-friendly and follow coding standards and architecture.

Time quickly when by until I had to finalize my thoughts and research into something I was confident with to provide an adequate collision detection library interface. I have 13 shapes and 11 functions to make some huge number of combinations which can be seen below. Most of these functions are overloaded and only account for the float type implementation (there is a double type implementation) which comes out to a huge amount of writing the complete proposed interface. I would be crazy to meticulously write each function line by line, but, as a programmer, I'm lazy and opted to generalize as much as possible to make a function to generate the interface. All that was left was to change specific pieces here and there while checking for mistakes.



Wednesday, November 20, 2019

This new architecture has me both scared and excited

As part of the porting team my job is to port Gateware to the new architecture but I also have to document it so future Devs can make sense of it and that's where my fear comes in. I have to make sense of the new architecture and know it from the inside out and even though I am excited for this challenge there is a small part of me that doesn't know if I can do it but I will do my best so we can move Gateware towards the future.

GFile Interface change complete

    Added new functionalities to the GFile interface, now it supports getting folder count and folder names. Unit Test for all functionalities pass on all platforms, Lari gave me the green light to integrate into Alpha branch. I will now resume my research/test in my file concatenation tool.

Monday, November 18, 2019

GAudio and GAudio3D big progress achieved... on Windows

Month:1, Week: 4

Huge progress has been achieved in the last couple of work days. The biggest bottleneck for my progress was resolving memory leaks (and race conditions) in GSound for over two weeks. After the issue was resolved, I managed to fix the memory leaks from GMusic, GAudio3D, GSound3D and GMusic3D in a single day!

3D Audio libraries are derived from the base class, so without working base class no progress could be done on 3D. After the base class got fixed, 3D contained a lot of issues but from my almost 3 weeks of experience of GAudio allowed me to figure out a solution fairly quickly.

The next big challenge comes from implementing the fixes on Linux and Mac as from what I saw these platforms experience similar (if not the same) issues. The problem comes from the usage of Audio libraries which are not cross-platform, so I would need to learn the nuances of those for each platform again. For example, I learned that XAudio2 (Windows) is not thread-safe, so the EndEvent would cause way too many issues as the XAudio threads were not synced to the GAudio thread(s).

I will start by implementing unit tests and possible solutions from Windows to Linux and Mac. This would allow me to see if any improvements were achieved and will try to take a next step after. After the memory leaks from GAudio and GAudio3D on Linux and Mac get resolved, I will start working on extra features of GAudio3D.

Thursday, November 14, 2019

Bad code turns into Warnings, Warnings turn into Errors, Errors turn into Failures.

Week 1 and 2 were essentially for getting used to the code base and getting the other platforms set up and running. Running through the warnings on Windows was just like any other day, with a few weird exceptions. So then we moved to Linux. It wouldn't build for some of us and if it did build, it wouldn't run. So we moved to Mac. After taking some time to understand how this new IDE operators, and how Mac operates, we got to start looking at the warnings and there was very few...that we could fix. We tried fixing some, but when we did, well.. it just caused an error somewhere else. It was like were between a rock and a hard place. It's always frustrating to be in a productive environment and not feel like you are producing. This felt foreboding for what Gateware would be, but after talking to the team and beating our head against walls we started to get more comfortable and understanding of what we had gotten ourselves into. Moving on to our other tasks helped put us back on the positive mindset that we were finally getting work done again, and it felt good.

Tuesday, November 12, 2019

No Such Thing As Too Many Tabs

Going into Gateware I knew it would be a challenge, I signed up for a challenge and I'm loving it. Not only do I get to work in this new environment that is cross platform development on a team but I got the unique privilege to learn about DevOps. Learning GitLab has been something I wanted to do since I heard about it many month ago. I understood it would be hard for me to grasp, (harder even when it's compressed into a FullSail schedule). Just getting started with the process had me fighting my demons of vague/assumptious documentation as well as command prompts. Though I know the battle with these will never be over, I have become more confident in myself in the ability to overcome tasks that I may find daunting at times.

The more I learn about Gateware the more my mind opens up and the more respect I gain for everybody that has contributed to it. DevOps on the other hand is not my realm, but like I said brefore, I do love a challenge. See, for me C++ is a beautiful language. Everything has a purpose that I can grasp or derive some understanding of; even if it's obscure due to unique design styles or limitations. There is almost always a purpose to functional code in C++ and even it is difficult to understand at first, in someway it makes sense because you can always trace it back down to memory and memory is where things make sense to me.

DevOps though, well... not so much. Do I understand why certain things are the way they are? Sure, lets go with that. Is there decent documentation on these technologies? Highly debatable. Does it bring me some weird twisted joy to have 20 something tabs open when trying to figure out why one command doesn't work? Why yes, yes it does.

Some people just "say" they like a challenge but those people haven't had every single command break on them even though it's exactly what the tutorial from the people who made that tech say to do. But. That's development, and if I didn't like it I wouldn't have made it this far with a smile on my face (figuratively speaking of course, something about bad documentation makes a man forget to smile on occasion).

Lastly, I'd like to say that if I don't go home with my brain feeling like it's been run through a Tom & Jerry episode, I get bored. It's fairly understood that when you are having fun that time flies, and I find it hard to believe that I am already in week 3. I'm excited to continue learning how to work in this environment, and I'm excited to defeat my monster that is GitLab CI/CD but most of all I'm excited for the feeling of accomplishing the challenges that are yet to come.

Does Frankensteining Geometry(Convex) Prove Intersection?

Studying math for hours can, most likely, lead to blankly staring into the abyss of notes feeling unsure if you learned anything in the past few hours. Hell, I've just been reading Wikipedia page after Wikipedia page on mathematical topics and decided to title my blog post, "Does Frankenstining Geometry(Convex) Prove Intersection?" Now, I know you just stumbled into a math blog, possibly by mistake, intrigued to see how I manage to relate some grotesque monster with an abnormal brain and Frankenstein's creature. I'm not even sure how I will be able to consistently relate the two nor promise to throughout this, but hopefully, by the end of this post, you will walk away with something more than your brain on fire trapped in a burning windmill. I'll go over how we will "stitch" two simple geometric shapes together and lightly describe the concept of the GJK algorithm which can give you insight on whether an intersection between the two simple geometric shapes we put together exists or not. An added bonus is just a simple glossary of terms you're already probably familiar with along with some images I drew in MS paint. Enjoy.

Can you make a loop? Yes. Can you add or subtract vectors? Yes. Congratulations, you can make your own Frankenstein geometry! It's called the Minkowski Sum and Difference and it's extremely useful to know, especially in collision detection. All that is required is that you have two sets of points representing convex shapes and you add or subtract each point in the first set with each point in the second set. I'm going to show you pseudocode and then list some of the things you may find it useful for.

Pseudocode:

int Minkowski Sum(
// [in]
Point* _a,
const unsigned int& _a_size,
Point* _b,
const unsigned int& _b_size,
// [out]
Point* _out
unsigned int& _out_size)
{
for ( i = 0; i < _a_size; ++i )
{
for ( j = 0; j < _b_size; ++j )
{
// Add _a[i] to _b[j]
}
}

return DoYouEvenCodeBruh ? 13375P34K : ALLYOURBASEAREBELONGTOME; // A fine dilema indeed.
}

Yes, this pseudocode is not my best work, but now you get the idea of the Minkowski sum implementation. The Minkowski difference is just this implementation, but with subtraction. Reducing the set produced by the function is a whole other topic in itself probably involving a very common computer science problem of efficiently calculating the convex hull. A brief description of the convex hull is found below and I might possibly blog about it some other time.

Here are some interesting things you can do with the Minkowski Sum when used on the following:
Shape + Point = Translated Shape
Shape + 2 Points = Two Translated Copies of the Shape
Circle + Circle = A larger Circle located at the sum of the centers
Shape + (Line or Curve) = Shape-swept Shape
Line + Line parallel to the first Line = Longer Line
Line + Line perpendicular to the first Line = Square

And interestingly for the Minkowski Difference:
Shape + Shape = Larger Shape
If two shapes overlap they will contain the origin.

Notice that the set of points produced by the Minkowski Difference will contain the origin if they intersect. This is extremely useful for checking convex shapes against each other and leads me to the next topic of the GJK algorithm. You see, the Minkowski operations set up the set of points, but we still need to determine if the origin is contained within this convex set. I won't be able to provide pseudocode for this algorithm as I'm still actively researching it, but I'll try to provide a little insight on it from what I currently understand. The GJK algorithm iterates through the set of convex points by checking to see if a triangle(2D) or tetrahedron(3D) can be formed by that set of points around the origin. If so, then you guessed it, there is an intersection. Here's an image I made to illustrate how I think the algorithm works in a 2D case:

(Figure 1) My idea of how GJK works for 2D space given a convex hull through the Minkowski Difference.

Bonus Glossary

(Figure 2) A helpful representation of some of the volumes used in collision detection. I got lazy after drawing the skull.

Point - The main structure of all other geometrical structures is based on in this glossary. For the sake of simplicity, the point will be defined as a vector representing a position in 2D or 3D Euclidean space.

Line - A set of points that can be produced by a function calculating the linear combination between two distinct points: L(t) = ( 1 - t ) PointA + t * PointB where -∞ < t < ∞ a.k.a the parametric line equation. A line divides 2D space into two subspaces.

Line Segment - A subset of points within the parametric line equation in which the parameter t is clamped to 0 ≤ t ≤ 1.

Line Ray - A half-infinite line that can be formed by the equation L(t) = PointA + t( PointB - PointA) where t ≥ 0.

Plane - A flat surface that divides 3D space into two subspaces since it extends in all directions infinitely. It can be represented as three points that are non-collinear, a normal and a point on the plane, or a normal and a distance from the origin.

Polygon - A 2D shape composed of n vertices which are connected through an equal amount of n edges where n is finite. It is a closed figure which means that the last edge connects to the first vertex. Polygons have multiple classifications such as being convex(all angles ≤ 180°) or concave(at least one angle > 180°).

Polyhedron - A 3D shape composed of a finite number of polygonal faces. Each face's edge is shared exactly with one other face. Like polygons, polyhedrons have multiple classifications. A polyhedron considered convex will contain vertices that all lie to one side of a given face for every face the shape has.

Simplex - A shape that is the simplest of its dimension. If any point that defined the shape is removed then its dimensionality will be reduced i.e. removing a point that forms a triangle would cause it to become a line. Examples: Point(0D), Line Segment(1D), Triangle(2D), Tetrahedron(3D), Cell(4D), ..., etc.

Axis-Aligned Bounding Box(AABB) - A rectangle in 2D or cuboid in 3D with all of its face normals permanently parallel with the coordinate axes. Common representations are min and max position, a min position, height, width, and depth, and a center position, height extent, width extent, and depth extent.

Circle - 2D shape composed of a center and radius.

Sphere - Similar to the circle except existing in 3D space. It has a center and radius.

Oriented Bounding Box(OBB) - Similar to the AABB, OBBs are rectangles in 2D or cuboids in 3D with the added data describing its orientation.

Capsule - A sphere-swept line.

Lozenge - A sphere-swept rectangle.

Slab - A slab in a region that extends infinitely and bound by two planes.

Discrete-Orientated Polytope(DOP) - A volume of intersecting extents along with some number of directions. Most volumes, such as AABBs and OBBs, are a specific type of DOP. Their axes do not have to be orthogonal.

Support Map - A function that maps a direction into a supporting point. Simple convex shapes can be mapped using elementary mathematical functions, while, more complex geometry will require numerical methods.

Supporting Plane - A supporting point within a plane that possesses a normal same as the given direction.

Supporting Point a.k.a. Extreme Point - A point furthest along a direction for a given geometry.

Supporting Vertex - A vertex that is a supporting point.

Separating Plane - A plane that has no intersections with two convex sets, each entire convex set is in a separate halfspace.

Separating Axis - A separating plane that has a normal orthogonal to an axis.

Convex Hull - A subset of convex points from a set of points representing convex geometry in its respective dimension i.e. convex polygons in 2D and convex polyhedrons in 3D.

Minkowski Sum and Difference - Operations that are applied to sets of points and return a set of points. The returning set of points can interestingly yield some useful information or shapes depending on which operation is used. The Minkowski sum can translate a shape, copy a shape and translate both the original and copy, create a shape-swept shape, and more. The Minkowski difference will produce a convex shape and if that shape encompasses the origin, then the two original sets of points are intersecting.

Multi-Platform Development is a challenging yet exciting beast.

Multi-Platform Development is a challenging yet exciting beast. During the start of the month I had no idea that multi-platform development would be such a pain. I haven't really coded in the past few weeks but just the process of setting up the Linux virtual machines and Mac laptops for development and that has been quite the struggle. Also going through the old documents and updating them to help the future Gateware devs and setting up the new macs for dev use has been challenging considering I have never touched a mac before in my life. I'm excited to keep learning and to keep expanding my knowledge of these new platforms. That being said I hope I never own a mac for personal use.

GAudio is very fun and... problematic

Month:1, Week: 3

Another week spent debugging and figuring out the reference system of GAudio and potential problems that can occur. The bugs that came out during testing are somewhat inconsistent and XAudio2 threading adds up to the difficulty of the problem.

Some of the flaws I observed in the “original” design with just the call to cleanup in GSound audio end event:
-If the sound was never played the event will never happen
-If decrement of the GSound happens after the sound ended and stopped, the full cleanup will never happen

The solution I ended up implementing fixed the memory leaks, but at the cost of flawed behavior (cuts the sound too early on deletion), so I need to find a middle ground solution that has the correct event system AND doesn't leak memory in some cases.

The problem seems to be pretty tough to fix and a lot of people seem to experience the same problems in the past with XAudio library, but at least I feel fairly confident in understanding GAudio library at this point and hopefully can figure out the proper implementation really soon.

Another week and finally progress

Over the course of the last week, I changed directions in my work. I started still trying to help Alex focus in on his GAudio problems, but once it was established that him and Lari were about as close as they could be I moved on to beginning to do my memory leak work on other systems. On Friday I officially started looking for memory leaks on mac and yesterday I was able to solve one. Unfortunately I'm a dummy and was apparently far behind on git, so maybe the leak didn't really exist, but I'll find out tomorrow.

This week my goal will be to reaffirm that that leak is fixed and there are no more on mac, and then move on to Linux.

The only thing standing in my way right now is that cmake is currently angry at me for my visual studio, and I can't run the project on windows again. Also my own failure to use gitkraken is going to hurt.

File concatenation tool work in progress

I started working on the file concatenation tool and did some research on C++11 libraries that might be useful for me. I used GFile interface that was provided in Gateware and was told that it is safe to use GFile for crossplatform file I/O and std::regex library that is in the C++11 standard library. This week, I'm done with setting up file concatenation tool. The issue that's impeding me right now is I have to copy and paste the hpp file content to that #include, the files are not being copied in correctly, and sometimes when you open up the file it does not open in visual studio but in notepad. There are some characters/brackets missing in the file, and I'm trying to debug the issue and it seems like the data structure that I used to hold the data is copying the data in wrong. This will be looked into more on Wednsday.

Wednesday, November 6, 2019

Joke Title Stand-in

Last week we were introduced to gateware and officially given our assignments on Wednesday. As a generalist engineer, my first assignment was and still is to fix memory leaks in the project. in searching for the cause of these we found that they all originate in the audio classes and I've inadvertently joined Alex in his own quest to fix up the audio system.

This week the assignment is the same and I feel a lot more confident in my ability to at least make progress this time around.

Thanks to Ryan's help we have a general idea of where the leaks are and what's causing them, but it's still important to fix them. Unfortunately the systems that are causing the leaks are something I need to investigate more thoroughly because without understanding how they work I won't be able to fix them.

Current Status

I was able to get started on file concatenation using std::regex library that is avaible on c++ 11. I was able to extract a header file and get all #includes in the file. Working on Linux has been a pain because CodeBlocks does not want to build the project so I cannot check to see if warnings are fixed or not.

Tuesday, November 5, 2019

Gateware's New If, When, & Where Library (Coming Soon)


Welcome to my first write on the FS Gateware blogging journal. My name is Ryan Bickell and I'll be designing and implementing a brand new library for FS Gateware under LSA Lari Norri to provide ease for both gaming and simulation developers as well as other fields reliant on computational geometry. This new library will enable knowing the if, when, and where multiple objects are contacting. The collision detection library will make full use of the current FS Gateware core math library. It will introduce new geometrical representations along with the algorithms needed to operate on them. Further detailed documentation and posts will be provided throughout the completion of this project ensuring goals such as robustness ( both numerically and geometrically ) , optimization, and ease of use.

BVH Gif

Feel free to ask me any questions and thanks for your time.

A new beginning of a Generalist


Month: 1, Week: 2

I joined a Gateware developer team last week on a generalist position. My main task for this month is debugging, fixing and polishing the GAudio libraries. Last several days I was installing Linux VM, getting used to MacBook dev environment and reading through the available Gateware libraries and documentation.

Last Friday I installed NoMachine on the developer MacBooks so we as a team can access those remotely which would save a lot of time in the future deployment and testing. [The small guide on how to use it should be available in the research repo under Tutorials folder]



And now my current task is purely focused on the bugs and memory leaks of GAudio (and GAudio3D which is currently not in use due to some issues on Linux platform). Some members of our team were experiencing issues with Unit Tests not finishing at all which suggests potential race condition in GAudio libraries. 

The list of memory leaks coming from GAudio is pretty impressive…

Adding to the difficulty of the task, there is a second branch (JP_Branch-Audio) that contains a majorly different GAudio and unit tests from the original Alpha GAudio (and both have significant issues). I will continue researching and debugging the libraries (on pair with Anthony who is another generalist working on Gateware) and hopefully will be able to get some significant improvements by the end of this week adding to some minor fixes I was able to make yesterday.

Friday, November 1, 2019

Kai's Introduction

    Hello everyone, I'm on the gateware team for C++ 11 porting. Nice to meet everyone.

Hello

My name is Anthony Balsamo, a generalist engineer currently assigned to getting rid of memory leaks, here's hoping that the month goes smoothly.

Hello, Hello, Hello

My name is Caio and I'm on the porting team. I will also be working on research for gitlab and docker integration. I'm excited to learn how to work in a multi-platform environment along with all the other skills I'll be picking up along the way.

Hello fellow Gateware Developers

My name's Chris Kennedy and I'll be working with Caio and Kai on the porting of Gateware to c++ 11. Ill Also be working on the Documentation.