Look_at reimplementation#530
Conversation
|
If possible, renaming dumb rotations to Intrinsic rotations should be done in a separate PR. Mixing the look_at reimplementation and the renaming makes code review very hard. EDIT: I just realized that in your code Intrinsic and look_at rotations are actually the same thing. With that in mind it makes more sense to combine the changes but I would still prefer to have a separate PR which renames dumb rotations. |
There was a problem hiding this comment.
Clearing the vector here isn't necessary since it will be deallocated anyway when the function finishes.
|
I added some comments but I haven't looked at the vector math yet. I'll do that at home when I can see the whole code in a real editor. |
|
PR #531 created, which is basically just the refactor of dumb_rotation to intrinsic_rotation. Once that PR is approved, I'll rebase this one. |
0382b56 to
77f27a9
Compare
|
PR rebased, and I added a new commit which addressed most of the comments here. I'm reluctant to merge the I still need to fix the angle calculations, but I've heard back from Bobboau and I have another math guy willing to look at it, so the investigation is progressing. |
|
I understand the concerns. Adding |
|
Again, if you're going to do that once, you might as well do it in all twelve functions. That's better suited to another PR. I suppose I could make such a PR. |
|
That's even better! My suggestion was to just validate the instance and model number without changing the function signature but removing the parameter is the better solution. |
|
Yeah, I figured, if you want a PR anyway, might as well use the better solution. The model instance code is fairly well debugged by now, but there is admittedly a possibility that the parameters could be transposed. This mitigates that risk. Looks like there were some problems. I'll fix those. Once that PR is merged, I'll rebase this one again. |
|
I just figured out that the reason I'm having so much trouble with the vector math could be that the test model itself is set up incorrectly. :-/ In addition to preventing my current tests from working, this would have required Bobboau's original code to not only be inscrutable, but also use incorrect calculations. I shall be in contact with a modeler shortly to deliver a test model according to my personal specifications. |
|
I've posted a model request: |
modify function headers as suggested in PR #530
5d1a19e to
ecb9365
Compare
8c1b333 to
91185dc
Compare
ebfb8ff to
1c69bee
Compare
…tion to intrinsic_rotation, with some additional tweaks and stuff
…he intrinsic_rotation PR
…t orientation adjustment!
… look_at_offset in degrees rather than radians
1c69bee to
8a16b80
Compare
|
Closing in favor of #3144. |
NOTE: This isn't quite ready to be merged yet! See comments below.
This PR re-implements the look_at feature, which originally was a brute-force iteration down the submodel hierarchy, just like dumb_rotation. The look_at code now properly uses the
model_instancecode developed by Swifty to integrate into the rest of the collision and rendering code.A look-at rotation is a type of intrinsic_rotation, just like dumb-rotations. The same code handles both; the only difference is whether submodel_rotate or submodel_look_at is called to apply the actual movement.
The previous look_at parsing code has been optimized by performing the name-to-submodel resolution when the model is actually parsed, instead of when the first look-at rotation is called. This avoids the need to store a name in the submodel struct and also avoids cluttering the look_at function.
A few functions -
model_instance_find_obj_dir,find_submodel_instance_point, andfind_submodel_instance_point_orient- have been tweaked to allow them to be called for any model with a model_instance, not just ship models.This PR is essentially bookkeeping, except for the submodel_look_at method. Bobboau's previous code has a few flaws - it doesn't work with the new model_instance code, it only accounts for rotation in one level of the submodel hierarchy, it makes an unnecessary detour out to world coordinates - so it can't be used as-is. Unfortunately, it's also almost entirely inscrutable, with one- or two-letter variables and no comments. :-/ So it was necessary to rewrite the rotation calculation code.
Currently, the rotation code has a few bugs that need to be worked out before committing (assistance with the finer points of vector math is appreciated). The rotation has to work properly for all three axes, and it also has to work for all ranges of angles. Currently, only the X axis can be tested with the Praetor model, and currently the door struts flip 180 degrees in the process of opening.
The praetor test mod has been updated since the dumb-rotation PR. It can be downloaded here:
http://scp.indiegames.us/temp/praetor.zip