weapon_position_foo still broken in 1.72

For test results, bug reports, announcements of new builds etc.

Moderators: winston, another_commander, Getafix

Post Reply
User avatar
Commander McLane
---- E L I T E ----
---- E L I T E ----
Posts: 9520
Joined: Thu Dec 14, 2006 9:08 am
Location: a Hacker Outpost in a moderately remote area
Contact:

weapon_position_foo still broken in 1.72

Post by Commander McLane »

The weapon_position_foo-keys are still broken in 1.72. And I don't actually recall that somebody was working to fix them.

Bug no 013273 on BerliOs.
another_commander
Quite Grand Sub-Admiral
Quite Grand Sub-Admiral
Posts: 6630
Joined: Wed Feb 28, 2007 7:54 am

Post by another_commander »

We know exactly why this does not work. The problem is that nobody has found the time to sit down and implement a proper fix yet.

But hey, we're halfway through. We'll get it right eventually.
User avatar
Ark
---- E L I T E ----
---- E L I T E ----
Posts: 664
Joined: Sun Dec 09, 2007 8:22 am
Location: Athens Greece

Post by Ark »

another_commander wrote:
We know exactly why this does not work. The problem is that nobody has found the time to sit down and implement a proper fix yet.

But hey, we're halfway through. We'll get it right eventually.
This is common in the world of "Lazy programmers" :D :D :D
bmaxa
Average
Average
Posts: 11
Joined: Thu Nov 06, 2008 2:14 pm
Location: Belgrade, Serbia

Post by bmaxa »

This is easy to fix.
Currently I can't see that weapon offset is used at all ;)

Put simply

position.x += offset.x;
position.y += offset.y;
position.z += offset.z;
// just three lines in front of

orientation = [ship normalOrientation];

Vector v_up = vector_up_from_quaternion(orientation);
Vector v_forward = vector_forward_from_quaternion(orientation);
Vector v_right = vector_right_from_quaternion(orientation);
velocity = vector_multiply_scalar(v_forward, [ship flightSpeed]);

in function initLaserFromShip and laser will fire with x,y,z offset from
original ship position while retaining ship orientation, effectively making
laser offset that can move up-down left-right forward-backward
from ship position.

Greets, Branimir.
another_commander
Quite Grand Sub-Admiral
Quite Grand Sub-Admiral
Posts: 6630
Joined: Wed Feb 28, 2007 7:54 am

Post by another_commander »

bmaxa wrote:
This is easy to fix.
Currently I can't see that weapon offset is used at all ;)
And that's precisely what is wrong. You are correct on this one.
Put simply

position.x += offset.x;
position.y += offset.y;
position.z += offset.z;
// just three lines in front of

orientation = [ship normalOrientation];
<snipped the rest>
Well, you will find that doing that requires to set all offsets in shipdata.plist to 0, if you want the laser to originate from the center front of the ship. I think we should find a somewhat more elegant way to do it, in order to not have to change all the shipdatas of all OXP ships ever released that contain weapons offsets. By just applying your fix, the laser moves indeed, but you will see that laser fire originates well outside the ship. You can check that by switching to external view.

Of course, feel free to bring to the table ideas as they come, you are more than welcome. It's just that this particular fix has been discussed already and I don't really think it represents the best solution.
bmaxa
Average
Average
Posts: 11
Joined: Thu Nov 06, 2008 2:14 pm
Location: Belgrade, Serbia

Post by bmaxa »

Sorry that was quick ,didn;t work as you say as we can;t simply
add to position (also relatively changes laser positon while flying), but this solution seems to work:

Vector vo1 = vector_multiply_scalar(v_forward, offset.z);
Vector vo2 = vector_multiply_scalar(v_right, offset.x);
Vector vo3 = vector_multiply_scalar(v_up, offset.y);
position = vector_add(position,vo1);
position = vector_add(position,vo2);
position = vector_add(position,vo3);
// position = vector_add(position, viewOffset); not needed anymore
rotMatrix = OOMatrixForQuaternionRotation(orientation);

Tested with Imperial Currier and positions seems right (all 4), especially
nose as laser points exactly from there as author typed offsets.
If OXP-s calculate offset from 0,0,0 this should work,
or I am missing something?
Problem will be if all three offsets are 0 by default than we can revert
to offset calculated based on bounding rectangle?

Greets, Branimir.
Post Reply