View Issue Details

IDProjectCategoryView StatusLast Update
0002582FSSCPmodelspublic2012-01-29 08:58
ReporterVA Assigned ToGoober5000  
PrioritynormalSeverityminorReproducibilityalways
Status resolvedResolutionfixed 
Product Version3.6.14 RC3 
Target Version3.6.14 
Summary0002582: No way to specify initial state for docking animations
DescriptionOk so if you have a ship with a docking/docked animation, and it begins the mission or arrives already docked, there's no code to set the ships animated submodels in the appropriate 'I AM DOCKED' kind of initial positions.

For example: if you have a freighter with an opening and closing cargo docking clamp, and it arrives already docked to a cargo crate, currently the clamp will be in the fully open position.
Additional InformationFrom my amateur investigations into how the system works, I think that you'd do this upon ship creation: basically check if each dock is occupied by something, and if so run the docking AND docked animations for the associated dock number as an initial animation. (Which would involve first fixing initial animation type)

Currently, when a ship is created one of the last things to be called is: model_anim_set_initial_states(shipp);
(line 8677 of ship.cpp)
This function looks for tabled animations of type 'initial' on each subsystem, and sets them straight to their end point. There's a special case for turrets which works (line 722 of modelanim.cpp -> "if (psub->type == SUBSYSTEM_TURRET) {"), but the one for general subsystems does not.

To get an initial dock animation state, I'd do something like: loop through all the docks the ship has checking if they are occupied, and for each one that is, set any 'docking' and 'docked' animations to their end positions, just as is supposed to happen with 'initial' types. (BTW the animation sub type for docked and docking animations should match the dockpoint index - ie. dock 2's animations would be the 'docking' and 'docked' ones in the table listed as +sub_type: 2)

Anyway, that's all I've got, but who knows - might be vaguely useful to someone who actually has a clue what they're doing! :D (Or at the very least, it shouldn't be a hindrance. :p )

Oh and I can provide test data for this stuff if need be. Just ask. :)
TagsNo tags attached.

Activities

VA

2012-01-23 13:54

reporter   ~0013125

Some further investigating and testing has revealed that the problem with initial animations appears to be something like they get interpreted correctly but never actually applied to the submodels UNTIL another animation of that submodel is triggered.

In a test, a submodel had both an initial type and another type (docked or docking). On mission load, the submodels was NOT in the specified initial position, however as soon as the other animation was triggered (ie, it started docking or actually docked), the submodel snapped to its specified initial position, and THEN proceeded to perform the triggered action.

Still investigating. :)

VA

2012-01-23 15:11

reporter   ~0013126

Hey I fixed it! :O :D

Uploading the patch with the relevant changes, but I was pretty much correct (shock horror!) - all it took was to actually copy the animation system's current_ang data to the angs in submodel_info_1 right after they had been calculated.

I've also had a look at the initial docking stuff, but it's all way over my head - I can't even begin to work out how to access the docking info from modelanim.cpp :\

VA

2012-01-23 16:05

reporter  

InitialTypeFix.patch (1,369 bytes)   
Index: modelanim.cpp
===================================================================
--- modelanim.cpp	(revision 8340)
+++ modelanim.cpp	(working copy)

@@ -723,11 +726,33 @@
 				pss->submodel_info_1.angs.h = psub->triggers[i].angle.xyz.y;
 				pss->submodel_info_2.angs.p = psub->triggers[i].angle.xyz.x;
 			} else {
-				if (psub->triggers[i].type == TRIGGER_TYPE_INITIAL)
+				if (psub->triggers[i].type == TRIGGER_TYPE_INITIAL) {
 					pss->trigger.set_to_end(&psub->triggers[i]);
+
+					//And now actually APPLY the initial angle data to the subobjects themselves!
+					pss->submodel_info_1.angs.p = pss->trigger.current_ang.xyz.x;
+					pss->submodel_info_1.angs.h = pss->trigger.current_ang.xyz.y;
+					pss->submodel_info_1.angs.b = pss->trigger.current_ang.xyz.z;
+
+					if (pss->submodel_info_1.angs.p > PI2)
+						pss->submodel_info_1.angs.p -= PI2;
+					else if (pss->submodel_info_1.angs.p < 0.0f)
+						pss->submodel_info_1.angs.p += PI2;
+
+					if (pss->submodel_info_1.angs.h > PI2)
+						pss->submodel_info_1.angs.h -= PI2;
+					else if (pss->submodel_info_1.angs.h < 0.0f)
+						pss->submodel_info_1.angs.h += PI2;
+
+					if (pss->submodel_info_1.angs.b > PI2)
+						pss->submodel_info_1.angs.b -= PI2;
+					else if (pss->submodel_info_1.angs.b < 0.0f)
+						pss->submodel_info_1.angs.b += PI2;
 			}
+
 		}
 	}
+	}
 }
 
 /**
InitialTypeFix.patch (1,369 bytes)   

Goober5000

2012-01-26 03:57

administrator   ~0013159

Fix committed to trunk@8373.

Goober5000

2012-01-26 04:02

administrator   ~0013160

Partial fix, that is. Mantis isn't smart enough to recognize the word "partial". :)

I'll need you to do your testing to verify two things:
1) Model submodels begin the mission at their correct initial rotations
2) Model submodels start rotating to their initially docked positions if a ship is initially docked

Note that the submodels won't "snap" to their docked positions for initially docked ships. That will come in the next commit. For this commit, I want to make sure the logic is correct.

Hmm... it would probably also be cool to have a sexp that can activate an arbitrary submodel animation... that would be fun to add. :)

Goober5000

2012-01-26 04:04

administrator   ~0013161

Oh, and you should open a separate ticket for this:

"
One suggestion I have just realised would be a good idea though is for the reverse trigger of docked. Currently 'docked' triggers only once the connection is made, so logically it would make sense to delay the undocking so it occur after the 'docked' animation has been undone, otherwise you could have a problem with animations on things like clamps not fully disengaging before the docker ship starts moving off.

As it is, in the 'case AIS_UNDOCK_1:' section there's already a default 1s delay - could this have the value from the appropriate 'docked' animation's '+time:' field added to it? This way the modder could control exactly when the actual disengagement should occur. For example a really slow moving claw might take 10 seconds to fully open, but only need 5 before it's not going to intersect the dockee ship anymore. The modder could specify a '+time: 6000', which would delay it just enough to look good. :)"

chief1983

2012-01-26 05:27

administrator   ~0013163

Fix committed to fs2_open_3_6_14@8374.

Goober5000

2012-01-29 08:58

administrator   ~0013190

This should now be fixed.

Related Changesets

fs2open: trunk r8373

2012-01-25 22:57

Goober5000


Ported: N/A

Details Diff
partial fix for Mantis 0002582:
--add Vasudan Admiral's fix for setting submodels to their initial positions
--add trigger for moving submodels to their docked positions when an initially-docked ship arrives
Affected Issues
0002582
mod - /trunk/fs2_open/code/model/modelanim.cpp Diff File
mod - /trunk/fs2_open/code/ai/aicode.cpp Diff File

fs2open: fs2_open_3_6_14 r8374

2012-01-26 00:27

chief1983


Ported: N/A

Details Diff
Backport: Trunk 8373; partial fix for Mantis 0002582:
--add Vasudan Admiral's fix for setting submodels to their initial positions
--add trigger for moving submodels to their docked positions when an initially-docked ship arrives
Affected Issues
0002582
mod - /branches/fs2_open_3_6_14/code/model/modelanim.cpp Diff File
mod - /branches/fs2_open_3_6_14/code/ai/aicode.cpp Diff File

fs2open: trunk r8378

2012-01-27 02:42

Goober5000


Ported: N/A

Details Diff
enhancement for bug 2582: trigger animations on BOTH ships undergoing docking Affected Issues
0002582
mod - /trunk/fs2_open/code/model/modelanim.cpp Diff File
mod - /trunk/fs2_open/code/ai/aicode.cpp Diff File

Issue History

Date Modified Username Field Change
2012-01-23 11:48 VA New Issue
2012-01-23 13:54 VA Note Added: 0013125
2012-01-23 15:11 VA Note Added: 0013126
2012-01-23 16:05 VA File Added: InitialTypeFix.patch
2012-01-26 03:52 Goober5000 Assigned To => Goober5000
2012-01-26 03:52 Goober5000 Status new => assigned
2012-01-26 03:57 Goober5000 Changeset attached => fs2open trunk r8373
2012-01-26 03:57 Goober5000 Note Added: 0013159
2012-01-26 03:57 Goober5000 Status assigned => resolved
2012-01-26 03:57 Goober5000 Resolution open => fixed
2012-01-26 04:02 Goober5000 Note Added: 0013160
2012-01-26 04:02 Goober5000 Status resolved => assigned
2012-01-26 04:02 Goober5000 Resolution fixed => open
2012-01-26 04:04 Goober5000 Note Added: 0013161
2012-01-26 05:27 chief1983 Changeset attached => fs2open fs2_open_3_6_14 r8374
2012-01-26 05:27 chief1983 Note Added: 0013163
2012-01-26 05:27 chief1983 Status assigned => resolved
2012-01-26 05:27 chief1983 Resolution open => fixed
2012-01-26 05:27 chief1983 Status resolved => assigned
2012-01-26 05:27 chief1983 Resolution fixed => open
2012-01-26 05:27 chief1983 Target Version => 3.6.14
2012-01-27 22:14 chief1983 Changeset attached => fs2open trunk r8378
2012-01-29 08:58 Goober5000 Note Added: 0013190
2012-01-29 08:58 Goober5000 Status assigned => resolved
2012-01-29 08:58 Goober5000 Resolution open => fixed