Inspired by Philip Gregory's resource: "A resource for musicians" I decided to make a simple tutorial for maintaining the engine code base. The idea behind this is that T3D in particular shares the code base between projects. So if you modify the source code from the engine you affect every project. This may not be what you want. In my case it was not. I found this out the hard way and had to reinstall the T3D source to get the original code.
It is all about structure. The layout of the Torque 3D 1.2 directory is as follows for the relevant source directories:
- Torque 3D -- Engine --- source -- My Projects --- "project name" ---- source
Now the 2 directories we care about are the "source" directories. These contain the engine source (Torque 3D->Engine->source) and the project source (Torque 3D->My Projects->"project name"->source). Knowing the location of these 2 directories is important for what I will cover next. Use this is a reference.
How does this help? Well, Microsoft Visual C++ (2008 for the example) has a great way to take advantage of overriding files from a project. This is a good thing. The way you take advantage of this feature is simple.
Say you have to make a change to a file in the T3D source. Lets say that you need to make a SimObject have a virtual function so you can override it in a later SimObject based class. This will mean that if you make this change it will affect every project that uses this same source code base. Unless, you take advantage of overriding a source file from the project source directory. For this example to make this change we would have to modify the file SimObject.h.
So in MS Visual C++ we would open our project and look in the "Solution Explorer" on the left side. Now there is going to be a DLL project named <project name> DLL. Under this you can drill down to the SimObject.h file like this: Source Files->Engine->console->SimObject.h. Now, right click on the file and select Properties. This will pop up a dialog. Find the option "Exclude From Build". This won't actually affect .h (header files), but it will put a red mark on the file. This is a visual indicator that you intend to override this file and just helps you later when tracking down which source file is overridden somewhere else.
Now we need to find the SimObject.h file in Windows Explorer so we can make a COPY of that file from the Torque 3D->Engine->source location to the Torque 3D->My Projects->"project name"->source location. Do not move the file, COPY the file. The path in Explorer would be Torque 3D->Engine->source->console->SimObject.h. Then it would be copied to the Torque 3D->My Projects->"project name"->source->console directory. Make sure the directory structure under "source" matches the directory structure under "Engine". It would look like this:
- Torque 3D -- Engine --- source ---- console -- My Projects --- "project name" ---- source ----- console
It should now be compiling against the new SimObject.h. To make sure we know about the file in the project we should add it back to the project in the Solution Explorer. To do this go into the project explorer again and right click on the "source" directory and choose Add->Existing Item. This will just add a indicator that this is part of the project for .h files. Now the SimObject.h file is part of the project again. Any changes you make to this copy of the SimObject.h will not affect other projects you create later on unless you decide to merge this file back into the main source directories again.