MCPcopy Create free account
hub / github.com/JACoders/OpenJK / G2API_GetBoltMatrix

Function G2API_GetBoltMatrix

code/rd-vanilla/G2_API.cpp:1726–1797  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1724bool G2_NeedsRecalc(CGhoul2Info *ghlInfo,int frameNum);
1725
1726qboolean G2API_GetBoltMatrix(CGhoul2Info_v &ghoul2, const int modelIndex, const int boltIndex, mdxaBone_t *matrix, const vec3_t angles,
1727 const vec3_t position, const int AframeNum, qhandle_t *modelList, const vec3_t scale )
1728{
1729 G2ERROR(ghoul2.IsValid(),"Invalid ghlInfo");
1730 G2ERROR(matrix,"NULL matrix");
1731 G2ERROR(modelIndex>=0&&modelIndex<ghoul2.size(),"Invalid ModelIndex");
1732 const static mdxaBone_t identityMatrix =
1733 {
1734 {
1735 { 0.0f, -1.0f, 0.0f, 0.0f },
1736 { 1.0f, 0.0f, 0.0f, 0.0f },
1737 { 0.0f, 0.0f, 1.0f, 0.0f }
1738 }
1739 };
1740 G2_GenerateWorldMatrix(angles, position);
1741 if (G2_SetupModelPointers(ghoul2))
1742 {
1743 if (matrix&&modelIndex>=0&&modelIndex<ghoul2.size())
1744 {
1745 int frameNum=G2API_GetTime(AframeNum);
1746 CGhoul2Info *ghlInfo = &ghoul2[modelIndex];
1747 G2ERROR(boltIndex >= 0 && (boltIndex < (int)ghlInfo->mBltlist.size()),va("Invalid Bolt Index (%d:%s)",boltIndex,ghlInfo->mFileName));
1748
1749 if (boltIndex >= 0 && ghlInfo && (boltIndex < (int)ghlInfo->mBltlist.size()) )
1750 {
1751 mdxaBone_t bolt;
1752
1753 if (G2_NeedsRecalc(ghlInfo,frameNum))
1754 {
1755 G2_ConstructGhoulSkeleton(ghoul2,frameNum,true,scale);
1756 }
1757
1758 G2_GetBoltMatrixLow(*ghlInfo,boltIndex,scale,bolt);
1759 // scale the bolt position by the scale factor for this model since at this point its still in model space
1760 if (scale[0])
1761 {
1762 bolt.matrix[0][3] *= scale[0];
1763 }
1764 if (scale[1])
1765 {
1766 bolt.matrix[1][3] *= scale[1];
1767 }
1768 if (scale[2])
1769 {
1770 bolt.matrix[2][3] *= scale[2];
1771 }
1772 VectorNormalize((float*)&bolt.matrix[0]);
1773 VectorNormalize((float*)&bolt.matrix[1]);
1774 VectorNormalize((float*)&bolt.matrix[2]);
1775
1776 Multiply_3x4Matrix(matrix, &worldMatrix, &bolt);
1777#if G2API_DEBUG
1778 for ( int i = 0; i < 3; i++ )
1779 {
1780 for ( int j = 0; j < 4; j++ )
1781 {
1782 assert( !Q_isnan(matrix->matrix[i][j]));
1783 }

Callers

nothing calls this directly

Calls 12

VectorNormalizeFunction · 0.85
Q_isnanFunction · 0.85
G2_GenerateWorldMatrixFunction · 0.70
G2_SetupModelPointersFunction · 0.70
G2API_GetTimeFunction · 0.70
G2_NeedsRecalcFunction · 0.70
G2_GetBoltMatrixLowFunction · 0.70
Multiply_3x4MatrixFunction · 0.70
vaFunction · 0.50
IsValidMethod · 0.45
sizeMethod · 0.45

Tested by

no test coverage detected