Bug in ShapeBase
by William Todd Scott · in Torque Game Engine · 01/12/2006 (4:47 pm) · 5 replies
Hi All,
I believe there is a small bug in the ShapeBase class.
Specifically, the functions registerLights(), getRenderImageTransform(), and getImageTransform() all use the mountPoint data member in ShapeBaseImageData. However, in ShapeBaseImageData::preLoad() the mountPoint data member is never initialized with the node ID named "mountPoint" as it shold be. Therefore, the mountPoint data member is always 0.
The fix is to change the following in ShapeBaseImageData::preLoad() from:
to
That will fix the problem. However, I also suggest that you remove mountPoint from the initPersistFields() call in ShapeBaseImageData because it should not be set via script. I also suggest that we change the variable name to mountNode so that it acts and is named the same as ejectNode, muzzleNode, and retractNode.
If you believe this is in error, please let me know!
edit: And mountPoint should be changed from a U32 to an S32.
Thanks
Todd
I believe there is a small bug in the ShapeBase class.
Specifically, the functions registerLights(), getRenderImageTransform(), and getImageTransform() all use the mountPoint data member in ShapeBaseImageData. However, in ShapeBaseImageData::preLoad() the mountPoint data member is never initialized with the node ID named "mountPoint" as it shold be. Therefore, the mountPoint data member is always 0.
The fix is to change the following in ShapeBaseImageData::preLoad() from:
// Resolve nodes & build mount transform
ejectNode = shape->findNode("ejectPoint");
muzzleNode = shape->findNode("muzzlePoint");
retractNode = shape->findNode("retractionPoint");
mountTransform = mountOffset;
[b]S32 node[/b] = shape->findNode("mountPoint");
if ([b]node[/b] != -1) {
MatrixF total(1);
do {
MatrixF nmat;
QuatF q;
TSTransform::setMatrix(shape->defaultRotations[[b]node[/b]].getQuatF(&q),shape->defaultTranslations[[b]node[/b]],&nmat);
total.mul(nmat);
[b]node[/b] = shape->nodes[[b]node[/b]].parentIndex;
}
while([b]node[/b] != -1);to
// Resolve nodes & build mount transform
ejectNode = shape->findNode("ejectPoint");
muzzleNode = shape->findNode("muzzlePoint");
retractNode = shape->findNode("retractionPoint");
mountTransform = mountOffset;
[b]mountPoint[/b] = shape->findNode("mountPoint");
if ([b]mountPoint[/b] != -1) {
MatrixF total(1);
do {
MatrixF nmat;
QuatF q;
TSTransform::setMatrix(shape->defaultRotations[[b]mountPoint[/b]].getQuatF(&q),shape->defaultTranslations[[b]mountPoint[/b]],&nmat);
total.mul(nmat);
[b]mountPoint[/b] = shape->nodes[[b]mountPoint[/b]].parentIndex;
}
while([b]mountPoint[/b] != -1);That will fix the problem. However, I also suggest that you remove mountPoint from the initPersistFields() call in ShapeBaseImageData because it should not be set via script. I also suggest that we change the variable name to mountNode so that it acts and is named the same as ejectNode, muzzleNode, and retractNode.
If you believe this is in error, please let me know!
edit: And mountPoint should be changed from a U32 to an S32.
Thanks
Todd
#2
I'll look into it.
Are you using this turret resource:
http://www.garagegames.com/index.php?sec=mg&mod=resource&page=view&qid=4116
Todd
01/12/2006 (6:46 pm)
Ok, Thanks,I'll look into it.
Are you using this turret resource:
http://www.garagegames.com/index.php?sec=mg&mod=resource&page=view&qid=4116
Todd
#3
www.garagegames.com/index.php?sec=mg&mod=resource&page=view&qid=5345
with some additional modifications to allow mouse control of the turret.
It's now 3am.. and I'm off to bed.. enough for one night I think.
01/12/2006 (6:55 pm)
I'm using the 1.2 versionwww.garagegames.com/index.php?sec=mg&mod=resource&page=view&qid=5345
with some additional modifications to allow mouse control of the turret.
It's now 3am.. and I'm off to bed.. enough for one night I think.
#4
I believe that I am in error.
The mountPoint variable does NOT correspond to the "mountPoint" node that is supposed to be named on the weapon dts. That threw me.
The mountPoint variable is the node on the player that we are mounting to and the "mountPoint" node that is looked for in preLoad is the node on the weapon.
So, my suggested change SHOULD NOT be implemented.
Jason, thank you for checking this our for me!!!!
01/12/2006 (7:55 pm)
Ok,I believe that I am in error.
The mountPoint variable does NOT correspond to the "mountPoint" node that is supposed to be named on the weapon dts. That threw me.
The mountPoint variable is the node on the player that we are mounting to and the "mountPoint" node that is looked for in preLoad is the node on the weapon.
So, my suggested change SHOULD NOT be implemented.
Jason, thank you for checking this our for me!!!!
#5
I believe that I am in error.
The mountPoint variable does NOT correspond to the "mountPoint" node that is supposed to be named on the weapon dts. That threw me.
The mountPoint variable is the node on the player that we are mounting to and the "mountPoint" node that is looked for in preLoad is the node on the weapon.
So, my suggested change SHOULD NOT be implemented.
Jason, thank you for checking this our for me!!!!
01/12/2006 (9:45 pm)
Ok,I believe that I am in error.
The mountPoint variable does NOT correspond to the "mountPoint" node that is supposed to be named on the weapon dts. That threw me.
The mountPoint variable is the node on the player that we are mounting to and the "mountPoint" node that is looked for in preLoad is the node on the weapon.
So, my suggested change SHOULD NOT be implemented.
Jason, thank you for checking this our for me!!!!
Torque Owner Jason Farmer
It looks like the weapon becomes mounted on the wrong node. I undid the change and my turrets work fine again.
and at half past two in the morning, it's too late for meto try to figure out why.
:-)