comparison Render.cpp @ 2182:e1e4a8a20b5f

_46А6АС_GetActorsInViewport
author Ritor1
date Thu, 23 Jan 2014 17:31:12 +0600
parents 147ee4591b76
children 48a28fe1f32f 4842f58715ea
comparison
equal deleted inserted replaced
2181:17b3e40daedc 2182:e1e4a8a20b5f
9135 pPixels = (unsigned __int16 *)malloc(2 * height * width); 9135 pPixels = (unsigned __int16 *)malloc(2 * height * width);
9136 memset(pPixels, 0 , 2 * height * width); 9136 memset(pPixels, 0 , 2 * height * width);
9137 9137
9138 v3 = pPixels; 9138 v3 = pPixels;
9139 9139
9140 BeginSceneD3D(); 9140 BeginSceneD3D();
9141 9141
9142 if (uCurrentlyLoadedLevelType == LEVEL_Indoor) 9142 if (uCurrentlyLoadedLevelType == LEVEL_Indoor)
9143 pIndoor->Draw(); 9143 pIndoor->Draw();
9144 else if (uCurrentlyLoadedLevelType == LEVEL_Outdoor) 9144 else if (uCurrentlyLoadedLevelType == LEVEL_Outdoor)
9145 pOutdoor->Draw(); 9145 pOutdoor->Draw();
9146 9146 DrawBillboards_And_MaybeRenderSpecialEffects_And_EndScene();
9147 DrawBillboards_And_MaybeRenderSpecialEffects_And_EndScene(); 9147 memset(&Dst, 0, 0x7C);
9148 memset(&Dst, 0, 0x7C); 9148 Dst.dwSize = sizeof(Dst);
9149 Dst.dwSize = sizeof(Dst); 9149
9150 9150 if ( LockSurface_DDraw4(pBackBuffer4, &Dst, DDLOCK_WAIT) )
9151 if ( LockSurface_DDraw4(pBackBuffer4, &Dst, DDLOCK_WAIT) ) 9151 {
9152 { 9152 for (uint y = 0; y < height; ++y)
9153 for (uint y = 0; y < height; ++y) 9153 {
9154 { 9154 for (uint x = 0; x < width; ++x)
9155 for (uint x = 0; x < width; ++x) 9155 {
9156 //*v3 = pRenderer->ReadPixel16((int)(x* interval_x + 8.0), (int)(y * interval_y + 8.0));//screen_data[screen_y + (int)(x* interval_x + 8.0)];
9157 if (Dst.ddpfPixelFormat.dwRGBBitCount == 32)
9156 { 9158 {
9157 //*v3 = pRenderer->ReadPixel16((int)(x* interval_x + 8.0), (int)(y * interval_y + 8.0));//screen_data[screen_y + (int)(x* interval_x + 8.0)]; 9159 auto p = (unsigned __int32 *)Dst.lpSurface + (int)(x * interval_x + 8.0) + y/* (int)(y * interval_y + 8.0)*/ * Dst.lPitch;
9158 9160 *v3 = Color16((*p >> 16) & 255, (*p >> 8) & 255, *p & 255);
9159 if (Dst.ddpfPixelFormat.dwRGBBitCount == 32) 9161 }
9162 else if (Dst.ddpfPixelFormat.dwRGBBitCount == 16)
9163 {
9164 auto p = (unsigned __int16 *)Dst.lpSurface + (int)(x * interval_x + 8.0) + y * Dst.lPitch;
9165 *v3 = *p;
9166 }
9167 else __debugbreak();
9168 ++v3;
9169 }
9170 }
9171 ErrD3D(pBackBuffer4->Unlock(0));
9172 }
9173 else
9174 {
9175 __debugbreak(); // unrefactored - black screenshot
9176 v4 = height;
9177 if ( height > 0 )
9178 {
9179 do
9180 {
9181 if ( width > 0 )
9182 {
9183 v5 = width & 1;
9184 v6 = (unsigned int)width / 2;
9185 memset(v3, 0, 4 * ((unsigned int)width / 2));
9186 v7 = &v3[2 * v6];
9187 for ( j = v5; j; --j )
9160 { 9188 {
9161 auto p = (unsigned __int32 *)Dst.lpSurface + (int)(x * interval_x + 8.0) + y/* (int)(y * interval_y + 8.0)*/ * Dst.lPitch; 9189 *v7 = 0;
9162 *v3 = Color16((*p >> 16) & 255, (*p >> 8) & 255, *p & 255); 9190 ++v7;
9163 } 9191 }
9164 else if (Dst.ddpfPixelFormat.dwRGBBitCount == 16) 9192 v3 += width;
9165 {
9166 auto p = (unsigned __int16 *)Dst.lpSurface + (int)(x * interval_x + 8.0) + y * Dst.lPitch;
9167 *v3 = *p;
9168 }
9169 else __debugbreak();
9170 ++v3;
9171 } 9193 }
9172 } 9194 --v4;
9173 ErrD3D(pBackBuffer4->Unlock(0)); 9195 }
9174 } 9196 while ( v4 );
9175 else 9197 }
9176 { 9198 }
9177 __debugbreak(); // unrefactored - black screenshot 9199
9178 v4 = height;
9179 if ( height > 0 )
9180 {
9181 do
9182 {
9183 if ( width > 0 )
9184 {
9185 v5 = width & 1;
9186 v6 = (unsigned int)width >> 1;
9187 memset(v3, 0, 4 * ((unsigned int)width >> 1));
9188 v7 = &v3[2 * v6];
9189 for ( j = v5; j; --j )
9190 {
9191 *v7 = 0;
9192 ++v7;
9193 }
9194 v3 += width;
9195 }
9196 --v4;
9197 }
9198 while ( v4 );
9199 }
9200 }
9201
9202
9203 /*if (!pRenderer->pRenderD3D) 9200 /*if (!pRenderer->pRenderD3D)
9204 { 9201 {
9205 pRenderer->BeginScene(); 9202 pRenderer->BeginScene();
9206 if ( uCurrentlyLoadedLevelType == LEVEL_Indoor ) 9203 if ( uCurrentlyLoadedLevelType == LEVEL_Indoor )
9207 { 9204 {
9271 free(pixels); 9268 free(pixels);
9272 } 9269 }
9273 9270
9274 9271
9275 //----- (0046A7C8) -------------------------------------------------------- 9272 //----- (0046A7C8) --------------------------------------------------------
9276 int Render::_46A6AC_spell_render_d3d(int a1, int a2, int a3) 9273 int Render::_466_GetActorsInViewport(int pDepth)
9277 { 9274 {
9278 unsigned int v3; // eax@2 9275 unsigned int v3; // eax@2 - id
9279 unsigned int v5; // eax@2 9276 unsigned int v5; // eax@2
9280 unsigned int v6; // eax@4 9277 unsigned int v6; // eax@4
9281 int v10; // ecx@11
9282 unsigned int v12; // [sp+10h] [bp-14h]@1 9278 unsigned int v12; // [sp+10h] [bp-14h]@1
9283 int v15; // [sp+1Ch] [bp-8h]@1 9279 int mon_num; // [sp+1Ch] [bp-8h]@1
9284 unsigned int a1a; // [sp+20h] [bp-4h]@1 9280 unsigned int a1a; // [sp+20h] [bp-4h]@1
9285 9281
9286 v15 = 0; 9282 mon_num = 0;
9287 v12 = GetBillboardDrawListSize(); 9283 v12 = GetBillboardDrawListSize();
9288 if ( (signed int)GetBillboardDrawListSize() > 0 ) 9284 if ( (signed int)GetBillboardDrawListSize() > 0 )
9289 { 9285 {
9290 for ( a1a = 0; (signed int)a1a < (signed int)v12; ++a1a ) 9286 for ( a1a = 0; (signed int)a1a < (signed int)v12; ++a1a )
9291 { 9287 {
9292 v3 = GetParentBillboardID(a1a); 9288 v3 = GetParentBillboardID(a1a);
9293 v5 = (unsigned __int16)pBillboardRenderList[v3].object_pid; 9289 v5 = (unsigned __int16)pBillboardRenderList[v3].object_pid;
9294 if ( PID_TYPE(v5) == OBJECT_Actor) 9290 if ( PID_TYPE(v5) == OBJECT_Actor)
9295 { 9291 {
9296 if ( pBillboardRenderList[v3].sZValue <= (unsigned int)(a3 << 16) ) 9292 if ( pBillboardRenderList[v3].sZValue <= (unsigned int)(pDepth << 16) )
9297 { 9293 {
9298 v6 = PID_ID(v5); 9294 v6 = PID_ID(v5);
9299 if ( pActors[v6].uAIState != Dead && pActors[v6].uAIState != Dying && pActors[v6].uAIState != Removed 9295 if ( pActors[v6].uAIState != Dead && pActors[v6].uAIState != Dying && pActors[v6].uAIState != Removed
9300 && pActors[v6].uAIState != Disabled && pActors[v6].uAIState != Summoned ) 9296 && pActors[v6].uAIState != Disabled && pActors[v6].uAIState != Summoned )
9301 { 9297 {
9302 if ( pGame->pVisInstance->DoesRayIntersectBillboard((double)a3, a1a) ) 9298 if ( pGame->pVisInstance->DoesRayIntersectBillboard((double)pDepth, a1a) )
9303 { 9299 {
9304 if ( v15 < a2 - 1 ) 9300 if ( mon_num < 100 )
9305 { 9301 {
9306 __debugbreak();// *(int *)(a1 + 4 * v10) = v6; ? 9302 _50BF30_actors_in_viewport_ids[mon_num] = v6;
9307 v10 = v15++; 9303 mon_num++;
9308 *(int *)(a1 + 4 * v10) = v6;
9309 } 9304 }
9310 } 9305 }
9311 } 9306 }
9312 } 9307 }
9313 } 9308 }
9314 } 9309 }
9315 } 9310 }
9316 return v15; 9311 return mon_num;
9317 } 9312 }
9318 9313
9319 9314
9320 9315
9321 9316