View Issue Details

IDProjectCategoryView StatusLast Update
0002727FSSCPgraphicspublic2012-12-03 20:17
ReporterFUBAR-BDHR Assigned ToValathil  
PrioritynormalSeverityminorReproducibilityalways
Status resolvedResolutionfixed 
Product Version3.6.15 
Summary0002727: Ship Lab - Debris rendered in wrong location if model has non-zero center of mass
DescriptionFound this in TBP when adding debris to a fighter that had both center of mass and pivot that were not at 0,0,0. While it's common for center of mass to not be 0,0,0 the values are usually very small so this is hard to notice. I did mange to find a good retail model that has the issue though. The good old Colossus.
Steps To ReproduceOpen up ship lab and select the Colossus and hit one of the LODs. When the ship appears rotate it so you are facing a side. Select debris. Watch the debris jump out in front of where the ship was.
TagsNo tags attached.

Activities

Valathil

2012-11-18 20:46

developer  

modelinterp.cpp.patch (1,667 bytes)   
Index: code/model/modelinterp.cpp
===================================================================
--- code/model/modelinterp.cpp	(revision 9354)
+++ code/model/modelinterp.cpp	(working copy)
@@ -3201,7 +3201,27 @@
 
 	//set to true since D3d and OGL need the api matrices set
 	g3_start_instance_matrix(pos, orient, true);
+	bool set_autocen = false;
+	vec3d auto_back = ZERO_VECTOR;
+	if (Interp_flags & MR_AUTOCENTER) {
+		// standard autocenter using data in model
+		if (pm->flags & PM_FLAG_AUTOCEN) {
+			auto_back = pm->autocenter;
+			vm_vec_scale(&auto_back, -1.0f);
+			set_autocen = true;
+		}
+		// fake autocenter if we are a missile and don't already have autocen info
+		else if (Interp_flags & MR_IS_MISSILE) {
+            auto_back.xyz.x = -( (pm->submodel[pm->detail[Interp_detail_level]].max.xyz.x + pm->submodel[pm->detail[Interp_detail_level]].min.xyz.x) / 2.0f );
+            auto_back.xyz.y = -( (pm->submodel[pm->detail[Interp_detail_level]].max.xyz.y + pm->submodel[pm->detail[Interp_detail_level]].min.xyz.y) / 2.0f );
+			auto_back.xyz.z = -( (pm->submodel[pm->detail[Interp_detail_level]].max.xyz.z + pm->submodel[pm->detail[Interp_detail_level]].min.xyz.z) / 2.0f );
+			set_autocen = true;
+		}
 
+		if (set_autocen)
+			g3_start_instance_matrix(&auto_back, NULL, true);
+	}
+
 	if (is_outlines_only_htl) {
 		gr_set_fill_mode( GR_FILL_MODE_WIRE );
 
@@ -3322,7 +3342,8 @@
 	if ( !(Interp_flags & MR_NO_LIGHTING ) )	{
 		light_filter_pop();	
 	}
-
+	if (set_autocen)
+		g3_done_instance(true);
 	g3_done_instance(true);
 
 	// turn off fog after each model renders, RT This fixes HUD being fogged when debris is in target box
modelinterp.cpp.patch (1,667 bytes)   

Valathil

2012-11-18 20:47

developer   ~0014054

Attached patch that fixes; Test for side effects.

The_E

2012-12-03 09:23

administrator   ~0014268

Have been running with this patch for some time, no side effects were noticeable.

Valathil

2012-12-03 16:01

developer   ~0014272

Want one more comment about TBP ships still having this issue. I think it's an asset problem but without specifics i cant investigate.

FUBAR-BDHR

2012-12-03 19:04

developer   ~0014276

Did you get the model/table I linked for you to test?

Valathil

2012-12-03 20:17

developer   ~0014277

Fix for retail committed to Trunk @ 9391

TBP was confirmed asset issue.

Issue History

Date Modified Username Field Change
2012-11-13 18:46 FUBAR-BDHR New Issue
2012-11-18 20:46 Valathil File Added: modelinterp.cpp.patch
2012-11-18 20:47 Valathil Assigned To => Valathil
2012-11-18 20:47 Valathil Status new => assigned
2012-11-18 20:47 Valathil Note Added: 0014054
2012-11-18 20:47 Valathil Status assigned => code review
2012-12-03 09:23 The_E Note Added: 0014268
2012-12-03 16:01 Valathil Note Added: 0014272
2012-12-03 19:04 FUBAR-BDHR Note Added: 0014276
2012-12-03 20:17 Valathil Note Added: 0014277
2012-12-03 20:17 Valathil Status code review => resolved
2012-12-03 20:17 Valathil Resolution open => fixed