Bug in particle editor (with fix) (actually bug in SimBase)
by J "hplus" W · in Torque Game Engine · 10/08/2006 (11:36 pm) · 4 replies
I don't get it. Why are there no unit tests for this code? It claims to have been around for almost ten years, and thus be "mature".
The built-in particle editor writes out scripts that you can load in as particle data. However, if you do, you actually get a crash, because it turns out that it creates data blocks with "new" rather than "datablock," because, in turn, the serialization support in SimBase is not smart enough to tell the difference.
I'm sorry if I seem ornery, but this is quite frustrating. Each time I try to use something, it turns out to be broken and un-tested. Last week, it was the Linux build; this week, it was object serialization AND cross-platform communication. I'd really like to be able to actually write some content code, rather than debug the core product...
Fix:
By the way: the default key for the particle editor (F9) needs to change, given that the debug render mode uses F9.
The built-in particle editor writes out scripts that you can load in as particle data. However, if you do, you actually get a crash, because it turns out that it creates data blocks with "new" rather than "datablock," because, in turn, the serialization support in SimBase is not smart enough to tell the difference.
I'm sorry if I seem ornery, but this is quite frustrating. Each time I try to use something, it turns out to be broken and un-tested. Last week, it was the Linux build; this week, it was object serialization AND cross-platform communication. I'd really like to be able to actually write some content code, rather than debug the core product...
Fix:
===================================================================
--- console/simBase.cc (revision 648)
+++ console/simBase.cc (working copy)
@@ -446,6 +446,14 @@
mFieldDictionary->writeFields(this, stream, tabStop);
}
+static char const * getNewFunction(SimObject * so)
+{
+ if (dynamic_cast<SimDataBlock *>(so) != NULL) {
+ return "datablock";
+ }
+ return "new";
+}
+
void SimObject::write(Stream &stream, U32 tabStop, U32 flags)
{
// Only output selected objects if they want that.
@@ -454,7 +462,8 @@
writeTabs(stream, tabStop);
char buffer[1024];
- dSprintf(buffer, sizeof(buffer), "new %s(%s) {\r\n", getClassName(), getName() ? getName() : "");
+ dSprintf(buffer, sizeof(buffer), "%s %s(%s) {\r\n", getNewFunction(this),
+ getClassName(), getName() ? getName() : "");
stream.write(dStrlen(buffer), buffer);
writeFields(stream, tabStop + 1);
writeTabs(stream, tabStop);By the way: the default key for the particle editor (F9) needs to change, given that the debug render mode uses F9.
#2
welcome to TGE Jon! feel the pain. (meant to type I feel the pain...but both are fitting.)
It does get easier fairly quickly. In fact since Oct 8th, I'd guess you are feeling that a bit.
I saw you running into audio bugs etc. if you search for threads by me about audio / sound etc, I ran into and debugged a lot of issues when I was first starting and posted the details.
Are you working on an indie game now?
it's good to see you around here.
10/24/2006 (2:59 am)
"I'm sorry if I seem ornery, but this is quite frustrating. Each time I try to use something, it turns out to be broken and un-tested."welcome to TGE Jon! feel the pain. (meant to type I feel the pain...but both are fitting.)
It does get easier fairly quickly. In fact since Oct 8th, I'd guess you are feeling that a bit.
I saw you running into audio bugs etc. if you search for threads by me about audio / sound etc, I ran into and debugged a lot of issues when I was first starting and posted the details.
Are you working on an indie game now?
it's good to see you around here.
#3
I'm just noodling around in Torque in my "copious" spare time. I find it useful to gather impressions from as wide a perspective as possible (a quest for life-long learning and all that). I doubt it'll result in much, but if it does, I'm sure y'all will know about it :-)
10/24/2006 (7:28 pm)
Thanks, Clint.I'm just noodling around in Torque in my "copious" spare time. I find it useful to gather impressions from as wide a perspective as possible (a quest for life-long learning and all that). I doubt it'll result in much, but if it does, I'm sure y'all will know about it :-)
#4
Thanks for posting a fix.
10/25/2006 (2:44 pm)
There was a comment from Ben Garney a year or so ago saying that the particle editor was no longer supported as of version 1.4. I got the impression there was some politics involved.Thanks for posting a fix.
Torque 3D Owner Kevin Rogers
I use F12 for the particle editor myself... works great.