RadixEngine
RadixEngine copied to clipboard
Write Tests for core classes
Hi, I'm looking to get involved with some open source code, and this looks like a really cool project. I'm a student at the University of Michigan, halfway through a CS minor. Most of my experience is in C++. I'd like to tackle a simple task as my first pull request, and this one seems as good a place to start as any, but I'm pretty unsure how to begin. Would you recommend that I compile the Radix engine and get familiar with it before I try to contribute to the source code? Or is this task pretty abstracted away from the actual functionality of the engine? Hope to hear from you soon, thanks!
@Carrotstrip Very nice to hear. Welcome. Yeah for this task you'll need to compile the engine and the tests (easy on arch or in docker and in windows probably, too we just don't have a lot of people with know how in windows that can elaborate on how to compile).
If you want to dive into a bigger problem from the start you can have a look at https://github.com/GlPortal/RadixEngine/blob/master/tests/core/math/QuaternionTest.cpp and see why it fails.
If you just want to get your feet wet I suggest writing a test for https://github.com/GlPortal/RadixEngine/blob/master/source/core/math/Math.cpp
Depending on your experience level compiling might be challenging. Stick to COMPILE.md and don't hesitate to ask about anything that might come up.
Update: I saw you in the channel earlier for more than 30 minutes. It usually takes some time for us to react to channel joins and question. Sometimes a whole day.
Thanks! I'll check that stuff out.
So I've managed to get everything compiled (I'm running OS X, by the way) and I guess my next question is... what now? My university curriculum has really only prepared me to deal with files that end in .cpp or .h. Anything else is pretty much foreign territory for me. Looking through the files in RadixEngine, everything seems to be either a makefile or an executable. So I guess I don't really know what exactly the RadixEngine is or how it's meant to be used. Is it a library? An editor? And whatever it is, how do I get to the C++ that's driving it?
This is the folder that contains Radix's source code: https://github.com/GlPortal/RadixEngine/tree/master/source the headers are in https://github.com/GlPortal/RadixEngine/tree/master/include/radix
RadixEngine is a library in glportal https://github.com/GlPortal/glPortal and this cli demo https://github.com/GlPortal/cgame you can see how it is used.
The editor is an extension for blender that you can find in a separate repository https://github.com/GlPortal/map-editor it adds tools to the blender ui and an export function to our XML map format.
The engine provides a renderer, a system manager, config system, sound system, several other systems an ecs, math helper classes, base classes for the game class etc.
Okay, I'll take a look around in there.
I’ve been trying to put together tests for Math.cpp, and I have some questions about that and also more general questions that I’ll try to make about the Radix Engine specifically. I don’t want to flood you with questions that I really should be able to answer myself with a bit of googling, but there are a few broad things that I wouldn’t mind some guidance on. First off, I think my compilation is just a bit wrong. When I use “make” to build the binary, I get a couple dozen errors with the following format:
/Users/Carrotstrip/RadixEngine/external/gwen/include/Gwen/Utility.h:53:37: warning: comparison of constant 65535 with expression of type 'String::value_type' (aka 'char') is always true [-Wtautological-constant-out-of-range-compare] } else if (chr >= 0x0800 && chr <= 0xFFFF) {
All of the errors are like this, just with different hex numbers. All I’ve found googling the error is an instance of it that was caused by somebody chaining comparators (0 < i < 10), so I checked in Utility.h and it doesn’t look like that was ever done. Any idea how I could fix this? Also, is it even something that I need to fix? Regarding Math.cpp, all of my courses at university have used RMEs (Requires/Modifies/Effects clauses) to describe what a function is supposed to do. I realize that this is not a universal standard, but I don’t know how the Radix Engine handles this. I’ve been able to find descriptions for some functions (clamp, sign) but not others (toDirection, toEuler). Also regarding testing, I’ve looked through QuaternionTest.cpp, and I’m unfamiliar with the testing methods you’re using. Could you point me towards somewhere I could pick those up? I’ve been taught to use cassert for testing, but again I realize that a lot of things are not universal. One last thing: I can’t figure how to run the T-rex game. For one thing I’d like to see what the Radix Engine can do, and also I want to play it! I couldn’t find a tutorial on how to get it running (if there is one my bad) and so if you would walk me through how to do so I’d be happy to write it up formally so it could be included in cgame/spec.md. Thanks for all your help, I’m hoping I can get to the point soon where I can make some contributions!
@Carrotstrip You should be able to run GlPortal and cgame by typing make run after you followed the COMPILE.md. Here is some footage of GlPortal https://vimeo.com/163973907
@Carrotstrip This is the testing framework we are using https://github.com/philsquared/Catch
"make run" is telling me that there's no target "run" in the Makefile, and checking over RadixEngine/build/Makefile (the one generated by cmake I think) I see no run target. Am I trying "make run" in the wrong directory, or could this be a problem with the way I compiled? Maybe something wrong with cmake? And thanks, the testing makes much more sense after looking over Catch.
Darn, the issues you're having is with code I wrote, which I know don't work well. The string thing is my quickly thrown together UTF-8 encoder/decoder, and the Quaternion stuff is Quat↔Euler angles conversion functions, and some edge cases still fail (IIRC I still haven't fixed return values for singularities). I'll get back to that some time later.
@Carrotstrip RadixEngine (simply a library) itself does not have a make run target. You need client code (a game) like https://github.com/GlPortal/glPortal (it has a COMPILE.md with instructions).
@Carrotstrip Saw you join on IRC earlier. One minute is too fast for us to reply or say hi though.
Hi, sorry it's been a while! I got pretty busy, but I've had this project in the back of my head and now that I've got quite a bit more free time I've been able to get cranking on it again, and I've got another question; once I've finished writing the test for Math.cpp, how can I work it into the test suite that is run by "make test"? I'm a bit turned around with all of these makefiles, and not familiar with cmake. I couldn't find any documentation for it in Catch.
You can look at cmake file and add your test https://github.com/GlPortal/RadixEngine/blob/master/tests/CMakeLists.txt#L18
Thanks SGOrava! So I've got my test running, and I've also been looking at QuaternionTest, and I was wondering if you guys get failure reports when you run those tests, as in Catch reports which line failed in which test. I can't seem to get Catch to do that, and its tutorial claims it's a feature.
@Carrotstrip Remove RadixEngine/CTestCustom.cmake on your checkout and the QuaternionTests will be run. It should tell you which tests fail and why (asserted value vs. true value).
(I was just about to send you this, thanks though, I get the sense that your way is more graceful.) Never mind, figured it out. It was Ctest, not Catch. I was just missing some flags (-R and -VV). So now I'm looking at QuaternionTest to try to figure out why that's failing, and it looks like the Aero functions are the culprits. However, I don't understand what those are trying to do, and the term Aero applied to vectors isn't something I've been able to find online. Here's an example of some test code that's failing:
SECTION("Convert quat to aero north singularity ") { Vector3f init, back; for (int n = 0; n < 50; ++n) { init.x = nppi(gen); init.y = rad(90); init.z = 0; back = quat.fromAero(init).toAero(); std::cout << init.x << ' ' << init.y << ' ' << init.z << " -> " << back.x << ' ' << back.y << ' ' << back.z << std::endl; CHECK(back.fuzzyEqual(init)); }
Is an "aero north singularity" a vector along the y-axis? It seems like that's what back is ending up as in cout, but in that case I don't see why we would expect that to be equal to init, which we give a random x component. Thanks again.
@Carrotstrip @ElementW Should be able to elaborate on it.
@Carrotstrip "aero" is a shorthand I used for "aeronautics" or "aerospace", i.e. angles as expressed for a fixed-wing aircraft, which is a kind of Euler angle system, where it is commonly understood that rotations are applied in the Roll-Pitch-Yaw order (mind you, it's reversed if you do that with matrices), whereas Euler angles has otherwise existing order conventions. In short, the "roll pitch yaw" convention.
However, where Quaternions are a (4-dimensional) rotation system without singularities (set of angle values for which the result is the same), Euler angles have this problem, also known as the gimbal lock.
Even if it's been a while, I never fixed the conversion algorithm to be consistent on singularities and make the test happy.
Thanks @ElementW, I've been reading what seems like every article on gimbal lock and rotational singularities out there, and I haven't come up with a viable solution to the problem as I understand it. I've got some time to spend on fixing this, but not a great grasp of how to fix it, so if you've got any ideas for where to start on this I could run with those a bit. Thanks again.
@Carrotstrip If you are completely stuck on this task then document all the results you got so far in a comment and then find another task to work on. Start with low complexity tasks that you solve in 1 to 2 days and then work your way up to a higher complexity that is realistic for you to solve in about 1 to 2 weeks.