Integrating recast - rename a source file?
by Daniel Buckmaster · in Torque 3D Professional · 06/14/2013 (10:45 pm) · 22 replies
I'm finally getting around to improving the recast resource, and I've come across an old friend of a problem. Both Torque and Recast define files called DebugDraw.(h|cpp) and this results in conflicts when compiling. For Walkabout, I simply renamed Recast's set of files to duDebugDraw.* and washed my hands of the problem. Of course, this makes updating the Recast code a pain, and nips in the bud any possible integration of the code as a submodule or any other convenient mechanism like that.
Question: should I rename Torque's debug drawer files?
What do people find more palatable? What's standard software practise if this happens? Is there a way around the issue altogether?
EDIT: Also, on a related note: if the Committee wants libraries like Recast to be integrates as folders in the libs/ directory rather than by just pasting all its source code in source/ then we'll need some documentation on how the heck we're supposed to work the project generator :P.
Question: should I rename Torque's debug drawer files?
What do people find more palatable? What's standard software practise if this happens? Is there a way around the issue altogether?
EDIT: Also, on a related note: if the Committee wants libraries like Recast to be integrates as folders in the libs/ directory rather than by just pasting all its source code in source/ then we'll need some documentation on how the heck we're supposed to work the project generator :P.
About the author
Studying mechatronic engineering and computer science at the University of Sydney. Game development is probably my most time-consuming hobby!
#2
06/15/2013 (11:56 am)
I think the file should be renamed and leave torque DebugDraw as it. Unless someone would want to take the time out to do a clean merge of both codes.
#3
Kory: the problem is, every time we update the Recast library we'd need to rename the Recast files again. Not the end of the world, but it makes it more of a pain to, for example, manage the library as a git submodule or svn external, which would allow us to automatically fetch recent versions etc. Not that recast is updated super-often...
06/15/2013 (3:24 pm)
Ahsan: how did you get code from lib/ to be included in the engine? I wanted to basically paste the code there and then use the project generator modules to include the directories, but couldn't get it working.Kory: the problem is, every time we update the Recast library we'd need to rename the Recast files again. Not the end of the world, but it makes it more of a pain to, for example, manage the library as a git submodule or svn external, which would allow us to automatically fetch recent versions etc. Not that recast is updated super-often...
#4
my mistake.
i actually have renamed "recastnavigationDebugUtilsIncludeDebugDraw.h"
to "navDebugDraw.h"
+this have to be done:
"recastnavigationDebugUtilsSourceRecastDebugDraw.cpp"
#include "DebugDraw.h"-->#include "navDebugDraw.h"
"recastnavigationDebugUtilsSourceDetourDebugDraw.cpp"
#include "DebugDraw.h"-->#include "navDebugDraw.h"
"how did you get code from lib/ to be included in the engine? "
for enginesource
06/15/2013 (4:16 pm)
hmm,my mistake.
i actually have renamed "recastnavigationDebugUtilsIncludeDebugDraw.h"
to "navDebugDraw.h"
+this have to be done:
"recastnavigationDebugUtilsSourceRecastDebugDraw.cpp"
#include "DebugDraw.h"-->#include "navDebugDraw.h"
"recastnavigationDebugUtilsSourceDetourDebugDraw.cpp"
#include "DebugDraw.h"-->#include "navDebugDraw.h"
"how did you get code from lib/ to be included in the engine? "
//if u want to keep recast files into engine/lib/ folder then active below
addLibIncludePath( 'recastnavigation/recast/Include' );
addLibIncludePath( 'recastnavigation/DetourTileCache/Include' );
addLibIncludePath( 'recastnavigation/DetourCrowd/Include' );
addLibIncludePath( 'recastnavigation/Detour/Include' );
addLibIncludePath( 'recastnavigation/DebugUtils/Include' );
addLibSrcDir( 'recastnavigation/recast/Source' );
addLibSrcDir( 'recastnavigation/DetourTileCache/Source' );
addLibSrcDir( 'recastnavigation/DetourCrowd/Source' );
addLibSrcDir( 'recastnavigation/Detour/Source' );
addLibSrcDir( 'recastnavigation/DebugUtils/Source' );for enginesource
addIncludePath(getAppEngineSrcDir() ."nav");
addEngineSrcDir("nav");
addIncludePath(getAppEngineSrcDir() ."nav/recastnavigation/recast/Include");
addEngineSrcDir("nav/recastnavigation/recast/Source");
addIncludePath(getAppEngineSrcDir() ."nav/recastnavigation/DetourTileCache/Include");
addEngineSrcDir("nav/recastnavigation/DetourTileCache/Source");
addIncludePath(getAppEngineSrcDir() ."nav/recastnavigation/DetourCrowd/Include");
addEngineSrcDir("nav/recastnavigation/DetourCrowd/Source");
addIncludePath(getAppEngineSrcDir() ."nav/recastnavigation/Detour/Include");
addEngineSrcDir("nav/recastnavigation/Detour/Source");
addIncludePath(getAppEngineSrcDir() ."nav/recastnavigation/DebugUtils/Include");
addEngineSrcDir("nav/recastnavigation/DebugUtils/Source");
#5
06/15/2013 (7:54 pm)
TBH, I really don't know how to approach this problem. My ideas would include trying to combine the two, only to realize that you'd need to reference these changes each time. This is an interesting problem. If recast is going to become a main portion of this engine from now on, then you might want to get the steering committee to discuss changing the existing debugDraw name to allow for recast to use it. Otherwise I'd just keep doing what you're doing for it now.
#6
Also, if that made no sense it's because I'm a little into my cups. My God, I've never used the Backspace key so often!
Edit: Also, I believe that Jessica Alba has the perfect body, and Nicole Kidman has the perfect face. Mmmm.... Nicole Alba.
Edit #2: @Robert - I think Recast/Detour should be added to the trunk, but I'd prefer to keep Walkabout as a paid/supported addon which is tailored to T3D. Just my 2 cents.
06/16/2013 (2:07 am)
Actually, Walkabout notwithstanding, I'd suggest that we need a proper T3D (MIT) nomenclature and protocol. Too many adjustments are being made in bubbles by well-meaning 3rd party providers. I find it extremely difficult to follow code comments as everyone has their preferred methods of doing things. This makes implementation of different resources which change source files within a given project very difficult and time consuming. I think that we really need to work out our (the community) protocols before we can settle on methods of delivery. I haven't even touched Walkabout since I integrated it, as I need it to work with both the 3DAAK and UAISK, yet all three kits have different changes to aiPlayer, and they all refer to different directories (Empty Template vs Full template, as well as overwriting lines within the cpp and header files in weird, inconsistent places. Very hard to use WinMerge in these situations. Also, if that made no sense it's because I'm a little into my cups. My God, I've never used the Backspace key so often!
Edit: Also, I believe that Jessica Alba has the perfect body, and Nicole Kidman has the perfect face. Mmmm.... Nicole Alba.
Edit #2: @Robert - I think Recast/Detour should be added to the trunk, but I'd prefer to keep Walkabout as a paid/supported addon which is tailored to T3D. Just my 2 cents.
#7
Ahsan: yeah, I thought I'd have to use those directives but unless you're doing it in a module .conf file instead of just the .inc file, it pulls the files into the standard solution and has name conflicts.
Robert: I figured on pull-requesting a leveled-up version of the recast resource so navmeshy goodness becomes stock (well, if you include the module that is), so we'll need some sort of decent solution.
Dan: standards would be great. I have a feeling that the new modular template system will solve most issues like this - script-side you can simply include the module that defines features for your custom add-on.
Code-side will be a bit more difficult. You can't really define class methods and so on outside the class definition. Maybe we just need better education about using merging tools and stuff :P. Or for more pack vendors to put their heads together and provide integrated versions of their code.
06/16/2013 (4:36 am)
Lol Dan.Ahsan: yeah, I thought I'd have to use those directives but unless you're doing it in a module .conf file instead of just the .inc file, it pulls the files into the standard solution and has name conflicts.
Robert: I figured on pull-requesting a leveled-up version of the recast resource so navmeshy goodness becomes stock (well, if you include the module that is), so we'll need some sort of decent solution.
Dan: standards would be great. I have a feeling that the new modular template system will solve most issues like this - script-side you can simply include the module that defines features for your custom add-on.
Code-side will be a bit more difficult. You can't really define class methods and so on outside the class definition. Maybe we just need better education about using merging tools and stuff :P. Or for more pack vendors to put their heads together and provide integrated versions of their code.
#8
u can use same code on both.
"it pulls the files into the standard solution and has name conflicts."
i tried another solution.i did a search for all files that have included DebugDraw.(h|cpp).then i tried to hard coded them to point to
"gfx\sim\DebugDraw.h"
and
"gfx\sim\DebugDraw.cpp"
that should have solved the problem.but it failed to work out
for some unknown reason !!!!!!!!!!
do u have any idea why that does not work?
06/16/2013 (7:45 am)
" instead of just the .inc file"u can use same code on both.
"it pulls the files into the standard solution and has name conflicts."
i tried another solution.i did a search for all files that have included DebugDraw.(h|cpp).then i tried to hard coded them to point to
"gfx\sim\DebugDraw.h"
and
"gfx\sim\DebugDraw.cpp"
that should have solved the problem.but it failed to work out
for some unknown reason !!!!!!!!!!
do u have any idea why that does not work?
#9
If you look in:
T3D\My Projects\%yourproject%\buildFilesLinkVc2k8.Release.Win32\%yourproject DLL
You'll see a bunch of .obj the compiler spits out. Note it doesn't respect directory structures. Hence name conflict problems.
Wanna say perhaps poking at:
https://github.com/GarageGames/Torque3D/tree/master/Tools/projectGenerator/libs
would be illuminating?
06/16/2013 (11:04 am)
"do u have any idea why that does not work?"If you look in:
T3D\My Projects\%yourproject%\buildFilesLinkVc2k8.Release.Win32\%yourproject DLL
You'll see a bunch of .obj the compiler spits out. Note it doesn't respect directory structures. Hence name conflict problems.
Wanna say perhaps poking at:
https://github.com/GarageGames/Torque3D/tree/master/Tools/projectGenerator/libs
would be illuminating?
#10
06/16/2013 (8:33 pm)
Azaezel: I tried writing a librecast.conf, and it created a librecast.vsproj, but I have no idea what's supposed to happen from there. The build failed with "error MSB3107: The specified project reference metadata is missing or has an invalid value". Beyond me to figure out, and Google doesn't seem to know anything about it either.
#11
For recast as lib:
Create new file: Tools/projectGenerator/libs/libRecast.conf
Create new file: Tools/projectGenerator/modules/navigation.inc
Tools/projectGenerator/classes/Torque3D.php
If you want, i can upload to GitHub your resource with all changes.
Thx for all your code contributions :D
06/17/2013 (12:14 pm)
About name conflit, rename T3D debugDraw to tDebugDraw. Git can handle rename of files.For recast as lib:
Create new file: Tools/projectGenerator/libs/libRecast.conf
<?php
beginLibConfig( 'libRecast', '{F2C0209B-1B90-4F73-816A-A0920FF8B107}' );
// Source
addSrcDir( Generator::getLibSrcDir() . 'recast', true );
// Additional includes
addLibIncludePath( 'recast' );
endLibConfig();
?>Create new file: Tools/projectGenerator/modules/navigation.inc
<?php
beginModule( 'navigation' );
addProjectDefine( "TORQUE_NAVIGATION" );
addSrcDir(getEngineSrcDir() . 'T3D/nav/', true);
includeLib( 'libRecast' );
if (inProjectConfig())
{
addProjectDependency( 'libRecast' );
addSolutionProjectRef( 'libRecast' );
}
endModule();
?>Modify Tools/projectGenerator/libs/Torque3D.conf andTools/projectGenerator/classes/Torque3D.php
// Modules
includeModule( 'Torque3D' );
includeModule( 'core' );
includeModule( 'dsound' );
includeModule( 'fmod');
includeModule( 'T3D' );
includeModule( 'advancedLighting' );
includeModule( 'basicLighting' );
includeModule( 'collada' );
includeModule( 'navigation' ); //add this lineIf you want, i can upload to GitHub your resource with all changes.
Thx for all your code contributions :D
#12
allowed values.
code/
bool NavMesh::setProtectedDetailSampleDist(void *obj, const char *index, const char *data)
{
F32 dist = dAtof(data);
if(dist == 0.0f || dist >= 0.9f)
{
Con::errorf("NavMesh::detailSampleDist must be 0 or greater than 0.9!");
return true;
}
return false;
}
/code
06/17/2013 (3:36 pm)
Might want to look at navMesh.cpp while you are delving into recast again. According to header, Zed (0) or greater than 0.9f are theallowed values.
code/
bool NavMesh::setProtectedDetailSampleDist(void *obj, const char *index, const char *data)
{
F32 dist = dAtof(data);
if(dist == 0.0f || dist >= 0.9f)
{
Con::errorf("NavMesh::detailSampleDist must be 0 or greater than 0.9!");
return true;
}
return false;
}
/code
#13
Ron
06/17/2013 (8:14 pm)
My personal recommendation (obviously NOT associated with the MIT crew at this point).... Leave the T3D naming conventions as they are. It's best to think of all our work as 'add ons' even if they get added to the core engine. Just my 2 cents.Ron
#14
Dale: thanks for that catch. It's an easy fix: the errorf should be after the if statement, not inside it.
Ron: definitely, I want to see this as a completely optional addon, which is why I want to go the full-on module and library route. It's nonsensical to me that there's no way for VS to accommodate two similarly-named source files... seems like a common use case.
EDIT: this answer seems to suggest we may be able to solve the file naming issue, but I haven't been able to get it to work.
06/17/2013 (8:33 pm)
Luis: I still can't get it working at all. If you could upload an example to GitHub that would be fantastic. I've tried a lot of combinations but VS is still complaining about undefined external symbols.Dale: thanks for that catch. It's an easy fix: the errorf should be after the if statement, not inside it.
Ron: definitely, I want to see this as a completely optional addon, which is why I want to go the full-on module and library route. It's nonsensical to me that there's no way for VS to accommodate two similarly-named source files... seems like a common use case.
EDIT: this answer seems to suggest we may be able to solve the file naming issue, but I haven't been able to get it to work.
#15
Include changes to templates.
For activate, add to buildFiles/config/project.conf
Tested with VS2012 using VS2010 solution
06/18/2013 (5:52 am)
Recast Resource on GitHubInclude changes to templates.
For activate, add to buildFiles/config/project.conf
<?php
$TORQUE_HIFI_NET = false;
$TORQUE_EXTENDED_MOVE = false;
// Configure Torque 3D
Torque3D::beginConfig( "win32", "testNavigation" );
includeModule( 'navigation' ); //add this
Torque3D::endConfig();
?>Tested with VS2012 using VS2010 solution
#16
06/19/2013 (10:06 am)
If you link to Recast as a static library instead of putting the code directly into T3D, this will not happen AFAIK.
#17
06/19/2013 (3:27 pm)
Would that require an additional .lib alongside the executable? I kind of don't want to do than, even if I did figure out how to build one.
#18
06/19/2013 (3:41 pm)
Check my repo. I compile recast/detour as static lib. This avoid filename conflict.
#19
06/19/2013 (5:41 pm)
Thanks Luis - I haven't checked your code yet, I'll get around to that soon. Maybe I can just pull from your repo and perform the modifications to the Torque-side source there :P.
Ahsan Muzaheed
Default Studio Name
i also had the same problem.
What i did is changing 3/4 header file's Location indication.
no need to change Torque's debug drawer files.
+i have moved folders of recasetNavigation(http://code.google.com/p/recastnavigation/source/browse/trunk) to lib folder,so that anyone can update the library easily.
it just take some type to figure it out.i do not have time to post those changes.but if u want then i can send u my engine source files.