@@ -2031,6 +2031,33 @@ static void R_SortDrawSurfs()
2031
2031
R_AddDrawViewCmd ( false );
2032
2032
}
2033
2033
2034
+ static void PositionEntityOnTag ( refEntity_t* entity, const refEntity_t* parent, orientation_t * orientation ) {
2035
+ // FIXME: allow origin offsets along tag?
2036
+ VectorCopy ( parent->origin , entity->origin );
2037
+
2038
+ for ( int i = 0 ; i < 3 ; i++ ) {
2039
+ VectorMA ( entity->origin , orientation->origin [i], parent->axis [i], entity->origin );
2040
+ }
2041
+
2042
+ // had to cast away the const to avoid compiler problems...
2043
+ AxisMultiply ( orientation->axis , ( ( refEntity_t* ) parent )->axis , entity->axis );
2044
+ entity->backlerp = parent->backlerp ;
2045
+ }
2046
+
2047
+ static void PositionRotatedEntityOnTag ( refEntity_t* entity, const refEntity_t* parent, orientation_t * orientation ) {
2048
+ // FIXME: allow origin offsets along tag?
2049
+ VectorCopy ( parent->origin , entity->origin );
2050
+
2051
+ for ( int i = 0 ; i < 3 ; i++ ) {
2052
+ VectorMA ( entity->origin , orientation->origin [i], parent->axis [i], entity->origin );
2053
+ }
2054
+
2055
+ // had to cast away the const to avoid compiler problems...
2056
+ axis_t tempAxis;
2057
+ AxisMultiply ( entity->axis , orientation->axis , tempAxis );
2058
+ AxisMultiply ( tempAxis, ( ( refEntity_t* ) parent )->axis , entity->axis );
2059
+ }
2060
+
2034
2061
/*
2035
2062
=============
2036
2063
R_AddEntitySurfaces
@@ -2095,19 +2122,146 @@ void R_AddEntitySurfaces()
2095
2122
}
2096
2123
else
2097
2124
{
2098
- switch ( tr.currentModel ->type )
2099
- {
2125
+ switch ( tr.currentModel ->type ) {
2100
2126
case modtype_t ::MOD_MESH:
2101
2127
R_AddMDVSurfaces ( ent );
2102
2128
break ;
2103
2129
2104
2130
case modtype_t ::MOD_MD5:
2105
- R_AddMD5Surfaces ( ent );
2131
+ /* Log::Warn("%i %s: old: %i-%i %f new: %i-%i %f | %f %f", ent->e.animationHandle,
2132
+ R_GetAnimationByHandle( ent->e.animationHandle )->name, ent->e.startFrame,
2133
+ ent->e.endFrame, ent->e.lerp, ent->e.startFrame2, ent->e.endFrame2, ent->e.lerp2,
2134
+ ent->e.blendLerp, ent->e.scale ); */
2135
+ switch ( ent->e .positionOnTag ) {
2136
+ case EntityTag::ON_TAG:
2137
+ {
2138
+ orientation_t orientation;
2139
+ RE_LerpTagET ( &orientation, &tr.refdef .entities [ent->e .attachmentEntity ].e , ent->e .tag .c_str (), 0 );
2140
+ PositionEntityOnTag ( &ent->e , &tr.refdef .entities [ent->e .attachmentEntity ].e , &orientation );
2141
+ R_RotateEntityForViewParms ( ent, &tr.viewParms , &tr.orientation );
2142
+ break ;
2143
+ }
2144
+
2145
+ case EntityTag::ON_TAG_ROTATED:
2146
+ {
2147
+ orientation_t orientation;
2148
+ RE_LerpTagET ( &orientation, &tr.refdef .entities [ent->e .attachmentEntity ].e , ent->e .tag .c_str (), 0 );
2149
+ PositionRotatedEntityOnTag ( &ent->e , &tr.refdef .entities [ent->e .attachmentEntity ].e , &orientation );
2150
+ R_RotateEntityForViewParms ( ent, &tr.viewParms , &tr.orientation );
2151
+ break ;
2152
+ }
2153
+
2154
+ case EntityTag::NONE:
2155
+ default :
2156
+ break ;
2157
+ }
2158
+
2159
+ if ( ent->e .scale == 0 ) {
2160
+ ent->e .scale = 1 ;
2161
+ }
2162
+ if ( ent->e .animationHandle == 0 ) {
2163
+ ent->e .animationHandle = ent->e .animationHandle2 ;
2164
+ } else if ( ent->e .animationHandle2 == 0 ) {
2165
+ ent->e .animationHandle2 = ent->e .animationHandle ;
2166
+ }
2167
+
2168
+ RE_BuildSkeleton ( &ent->e .skeleton , ent->e .animationHandle , ent->e .startFrame , ent->e .endFrame ,
2169
+ ent->e .lerp , ent->e .clearOrigin );
2170
+ ent->e .skeleton .scale = ent->e .scale ;
2171
+ if ( ent->e .blendLerp > 0.0 ) {
2172
+ refSkeleton_t skel;
2173
+ RE_BuildSkeleton ( &skel, ent->e .animationHandle2 , ent->e .startFrame2 , ent->e .endFrame2 ,
2174
+ ent->e .lerp2 , ent->e .clearOrigin2 );
2175
+ RE_BlendSkeleton ( &ent->e .skeleton , &skel, ent->e .blendLerp );
2176
+ }
2177
+
2178
+ for ( const BoneMod& boneMod : ent->e .boneMods ) {
2179
+ QuatMultiply2 ( ent->e .skeleton .bones [boneMod.index ].t .rot , boneMod.rotation );
2180
+ }
2181
+
2182
+ if ( ent->e .boundsAdd ) {
2183
+ matrix_t mat;
2184
+ vec3_t bounds[2 ];
2185
+
2186
+ MatrixFromAngles ( mat, ent->e .boundsRotation [0 ], ent->e .boundsRotation [1 ], ent->e .boundsRotation [2 ] );
2187
+ MatrixTransformBounds ( mat, ent->e .skeleton .bounds [0 ], ent->e .skeleton .bounds [1 ], bounds[0 ], bounds[1 ] );
2188
+ BoundsAdd ( ent->e .skeleton .bounds [0 ], ent->e .skeleton .bounds [1 ], bounds[0 ], bounds[1 ] );
2189
+ }
2190
+
2191
+ if ( !( ent->e .renderfx & RF_NORENDER ) ) {
2192
+ R_AddMD5Surfaces ( ent );
2193
+ }
2106
2194
break ;
2107
2195
2108
2196
case modtype_t ::MOD_IQM:
2109
- R_AddIQMSurfaces ( ent );
2197
+ {
2198
+ /* Log::Warn("%i %s: old: %i-%i %f new: %i-%i %f | %f %f", ent->e.animationHandle,
2199
+ R_GetAnimationByHandle( ent->e.animationHandle )->name, ent->e.startFrame,
2200
+ ent->e.endFrame, ent->e.lerp, ent->e.startFrame2, ent->e.endFrame2, ent->e.lerp2,
2201
+ ent->e.blendLerp, ent->e.scale ); */
2202
+ switch ( ent->e .positionOnTag ) {
2203
+ case EntityTag::ON_TAG:
2204
+ {
2205
+ orientation_t orientation;
2206
+ RE_LerpTagET ( &orientation, &tr.refdef .entities [ent->e .attachmentEntity ].e , ent->e .tag .c_str (), 0 );
2207
+ PositionEntityOnTag ( &ent->e , &tr.refdef .entities [ent->e .attachmentEntity ].e , &orientation );
2208
+ R_RotateEntityForViewParms ( ent, &tr.viewParms , &tr.orientation );
2209
+ break ;
2210
+ }
2211
+
2212
+ case EntityTag::ON_TAG_ROTATED:
2213
+ {
2214
+ orientation_t orientation;
2215
+ RE_LerpTagET ( &orientation, &tr.refdef .entities [ent->e .attachmentEntity ].e , ent->e .tag .c_str (), 0 );
2216
+ PositionRotatedEntityOnTag ( &ent->e , &tr.refdef .entities [ent->e .attachmentEntity ].e , &orientation );
2217
+ R_RotateEntityForViewParms ( ent, &tr.viewParms , &tr.orientation );
2218
+ break ;
2219
+ }
2220
+
2221
+ case EntityTag::NONE:
2222
+ default :
2223
+ break ;
2224
+ }
2225
+
2226
+ bool transform = true ;
2227
+ if ( ent->e .scale == 0 ) {
2228
+ ent->e .scale = 1 ;
2229
+ }
2230
+ if ( ent->e .animationHandle == 0 ) {
2231
+ ent->e .animationHandle = ent->e .animationHandle2 ;
2232
+ } else if ( ent->e .animationHandle2 == 0 ) {
2233
+ ent->e .animationHandle2 = ent->e .animationHandle ;
2234
+ }
2235
+
2236
+ ent->e .skeleton .scale = ent->e .scale ;
2237
+ RE_BuildSkeleton ( &ent->e .skeleton , ent->e .animationHandle , ent->e .startFrame , ent->e .endFrame ,
2238
+ ent->e .lerp , ent->e .clearOrigin );
2239
+ if ( ent->e .blendLerp > 0.0 ) {
2240
+ refSkeleton_t skel;
2241
+ RE_BuildSkeleton ( &skel, ent->e .animationHandle2 , ent->e .startFrame2 , ent->e .endFrame2 ,
2242
+ ent->e .lerp2 , ent->e .clearOrigin2 );
2243
+ RE_BlendSkeleton ( &ent->e .skeleton , &skel, ent->e .blendLerp );
2244
+ }
2245
+
2246
+ for ( const BoneMod& boneMod : ent->e .boneMods ) {
2247
+ QuatMultiply2 ( ent->e .skeleton .bones [boneMod.index ].t .rot , boneMod.rotation );
2248
+ }
2249
+ R_TransformSkeleton ( &ent->e .skeleton , ent->e .scale );
2250
+
2251
+ if ( ent->e .boundsAdd ) {
2252
+ matrix_t mat;
2253
+ vec3_t bounds[2 ];
2254
+
2255
+ MatrixFromAngles ( mat, ent->e .boundsRotation [0 ], ent->e .boundsRotation [1 ], ent->e .boundsRotation [2 ] );
2256
+ MatrixTransformBounds ( mat, ent->e .skeleton .bounds [0 ], ent->e .skeleton .bounds [1 ], bounds[0 ], bounds[1 ] );
2257
+ BoundsAdd ( ent->e .skeleton .bounds [0 ], ent->e .skeleton .bounds [1 ], bounds[0 ], bounds[1 ] );
2258
+ }
2259
+
2260
+ if ( !( ent->e .renderfx & RF_NORENDER ) ) {
2261
+ R_AddIQMSurfaces ( ent );
2262
+ }
2110
2263
break ;
2264
+ }
2111
2265
2112
2266
case modtype_t ::MOD_BSP:
2113
2267
R_AddBSPModelSurfaces ( ent );
0 commit comments