| 1897 | |
| 1898 | |
| 1899 | void G2API_CollisionDetect(CCollisionRecord *collRecMap, CGhoul2Info_v &ghoul2, const vec3_t angles, const vec3_t position, |
| 1900 | int AframeNumber, int entNum, vec3_t rayStart, vec3_t rayEnd, vec3_t scale, CMiniHeap *, |
| 1901 | EG2_Collision eG2TraceType, int useLod, float fRadius) |
| 1902 | { |
| 1903 | G2ERROR(ghoul2.IsValid(),"Invalid ghlInfo"); |
| 1904 | G2ERROR(collRecMap,"NULL Collision Rec"); |
| 1905 | if (G2_SetupModelPointers(ghoul2)&&collRecMap) |
| 1906 | { |
| 1907 | int frameNumber=G2API_GetTime(AframeNumber); |
| 1908 | |
| 1909 | vec3_t transRayStart, transRayEnd; |
| 1910 | |
| 1911 | // make sure we have transformed the whole skeletons for each model |
| 1912 | G2_ConstructGhoulSkeleton(ghoul2, frameNumber,true, scale); |
| 1913 | |
| 1914 | // pre generate the world matrix - used to transform the incoming ray |
| 1915 | G2_GenerateWorldMatrix(angles, position); |
| 1916 | |
| 1917 | ri.GetG2VertSpaceServer()->ResetHeap(); |
| 1918 | |
| 1919 | // now having done that, time to build the model |
| 1920 | #ifdef _G2_GORE |
| 1921 | G2_TransformModel(ghoul2, frameNumber, scale, ri.GetG2VertSpaceServer(), useLod, false); |
| 1922 | #else |
| 1923 | G2_TransformModel(ghoul2, frameNumber, scale,ri.GetG2VertSpaceServer(), useLod); |
| 1924 | #endif |
| 1925 | |
| 1926 | // model is built. Lets check to see if any triangles are actually hit. |
| 1927 | // first up, translate the ray to model space |
| 1928 | TransformAndTranslatePoint(rayStart, transRayStart, &worldMatrixInv); |
| 1929 | TransformAndTranslatePoint(rayEnd, transRayEnd, &worldMatrixInv); |
| 1930 | |
| 1931 | // now walk each model and check the ray against each poly - sigh, this is SO expensive. I wish there was a better way to do this. |
| 1932 | #ifdef _G2_GORE |
| 1933 | G2_TraceModels(ghoul2, transRayStart, transRayEnd, collRecMap, entNum, eG2TraceType, useLod, fRadius,0,0,0,0,0,qfalse); |
| 1934 | #else |
| 1935 | G2_TraceModels(ghoul2, transRayStart, transRayEnd, collRecMap, entNum, eG2TraceType, useLod, fRadius); |
| 1936 | #endif |
| 1937 | |
| 1938 | ri.GetG2VertSpaceServer()->ResetHeap(); |
| 1939 | // now sort the resulting array of collision records so they are distance ordered |
| 1940 | qsort( collRecMap, MAX_G2_COLLISIONS, |
| 1941 | sizeof( CCollisionRecord ), QsortDistance ); |
| 1942 | G2ANIM(ghoul2,"G2API_CollisionDetect"); |
| 1943 | } |
| 1944 | } |
| 1945 | |
| 1946 | qboolean G2API_SetGhoul2ModelFlags(CGhoul2Info *ghlInfo, const int flags) |
| 1947 | { |
nothing calls this directly
no test coverage detected