VariablesDB.cpp 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747
  1. #include "..\..\common_h\render.h"
  2. #ifndef COMPILE_PROPS_INCLUDED
  3. #error CompileProps.h must be included
  4. #endif
  5. #if defined (_XBOX) && defined(_PRECOMPILED_COMMAND_BUFFER_BAKER)
  6. #include "VariablesDB.h"
  7. #include "Render.h"
  8. VariablesDB::VariablesDB() : vector4Pool (_FL_), boolPool (_FL_), variables (_FL_), variables_hash (_FL_), texturesAddrPool (_FL_), texture_variables (_FL_)
  9. {
  10. #ifndef STOP_DEBUG
  11. bDebugIsConst = false;
  12. #endif
  13. _mWorldViewProj = NULL;
  14. _mWorld = NULL;
  15. _mView = NULL;
  16. _mProjection = NULL;
  17. _mInverseView = NULL;
  18. _vWorldPos = NULL;
  19. _vCamPosRelativeWorld = NULL;
  20. _vCamDirRelativeWorld = NULL;
  21. _vCamPos = NULL;
  22. _fFogHeightDensity = NULL;
  23. _fFogHeightMin = NULL;
  24. _fFogHeightMax = NULL;
  25. _fFogHeightDistanceInv = NULL;
  26. _fFogDensity = NULL;
  27. _fFogDistanceMin = NULL;
  28. _fFogDistanceMax = NULL;
  29. _fFogDistanceMinSquared = NULL;
  30. _fFogDistanceLen = NULL;
  31. _cFogColor = NULL;
  32. _vAmbientLight = NULL;
  33. _vAmbientLightSpecular = NULL;
  34. _vGlobalLightColorSpecular = NULL;
  35. _vGlobalLightColor = NULL;
  36. _vGlobalLightDirection = NULL;
  37. _vGlobalLightDirectionSpecular = NULL;
  38. _vGlobalLightBackColor = NULL;
  39. }
  40. VariablesDB::~VariablesDB()
  41. {
  42. varPool.Destroy();
  43. }
  44. void VariablesDB::Init ()
  45. {
  46. for (DWORD i = 0; i < variables.Size(); i++)
  47. {
  48. variables[i]->convertOffsetToPointer(&vector4Pool[0], &boolPool[0], &texturesAddrPool[0]);
  49. }
  50. #ifndef STOP_DEBUG
  51. Debug_MakeItConst();
  52. #endif
  53. /*
  54. Ничего особо не дало, т.к. кэш миссы походу в destination
  55. DWORD dwBytesSize = vector4Pool.GetDataSize();
  56. BYTE* dwBytesData = (BYTE*)&vector4Pool[0].x;
  57. XLockL2(XLOCKL2_INDEX_XPS, dwBytesData, dwBytesSize, XLOCKL2_LOCK_SIZE_1_WAY, XLOCKL2_FLAG_SUSPEND_REPLACEMENT);
  58. */
  59. BindStandartVariables();
  60. }
  61. #ifndef STOP_DEBUG
  62. void VariablesDB::DebugAssert(bool bExpr)
  63. {
  64. if (bExpr == false)
  65. {
  66. int a = 0;
  67. }
  68. Assert(bExpr);
  69. }
  70. void VariablesDB::Debug_MakeItConst()
  71. {
  72. bDebugIsConst = true;
  73. }
  74. #endif
  75. IVariable * VariablesDB::getShaderVariable (const char* shaderName, const char * srcFile, long srcLine)
  76. {
  77. #ifndef STOP_DEBUG
  78. DebugAssert(bDebugIsConst == true);
  79. #endif
  80. IVariable* var = NULL;
  81. variables_hash.Find(shaderName, var);
  82. if (var == NULL)
  83. {
  84. api->Trace("Variable '%s' not found", shaderName);
  85. variables_hash.Find(shaderName, var);
  86. return NULL;
  87. }
  88. return var;
  89. }
  90. void VariablesDB::AddVariable (const char * szVariableName, ID3DXEffect* pEffect, D3DXHANDLE paramHandle)
  91. {
  92. #ifndef STOP_DEBUG
  93. DebugAssert(bDebugIsConst == false);
  94. #endif
  95. D3DXPARAMETER_DESC constDesc;
  96. pEffect->GetParameterDesc(paramHandle, &constDesc);
  97. if ((constDesc.Class == D3DXPC_OBJECT && constDesc.Type != D3DXPT_TEXTURE) || constDesc.Class == D3DXPC_STRUCT)
  98. {
  99. /*
  100. OutputDebugString("skip var : ");
  101. OutputDebugString(szVariableName);
  102. OutputDebugString("\n");
  103. */
  104. return;
  105. }
  106. DWORD dwSlotsInPool = 0;
  107. VariableType type = VT_UNKNOWN;
  108. if (constDesc.Class == D3DXPC_OBJECT && constDesc.Type == D3DXPT_TEXTURE && constDesc.Elements == 0)
  109. {
  110. type = VT_TEXTURE;
  111. dwSlotsInPool = 1;
  112. }
  113. if (constDesc.Class == D3DXPC_VECTOR && constDesc.Type == D3DXPT_FLOAT)
  114. {
  115. if (constDesc.Columns == 3)
  116. {
  117. type = VT_VECTOR3;
  118. dwSlotsInPool = 1;
  119. }
  120. if (constDesc.Columns == 4)
  121. {
  122. type = VT_VECTOR4;
  123. dwSlotsInPool = 1;
  124. }
  125. }
  126. if (constDesc.Class == D3DXPC_SCALAR && constDesc.Type == D3DXPT_FLOAT && constDesc.Columns == 1)
  127. {
  128. type = VT_FLOAT;
  129. dwSlotsInPool = 1;
  130. }
  131. if (constDesc.Class == D3DXPC_MATRIX_COLUMNS && constDesc.Type == D3DXPT_FLOAT && constDesc.Columns == 4 && constDesc.Rows == 4)
  132. {
  133. type = VT_MATRIX4x4;
  134. dwSlotsInPool = 4;
  135. }
  136. if (constDesc.Class == D3DXPC_SCALAR && constDesc.Type == D3DXPT_BOOL && constDesc.Columns == 1)
  137. {
  138. type = VT_BOOL;
  139. dwSlotsInPool = 1;
  140. }
  141. DWORD dwElementsCount = constDesc.Elements;
  142. if (dwElementsCount <= 0)
  143. {
  144. dwElementsCount = 1;
  145. }
  146. if (type == VT_BOOL)
  147. {
  148. dwElementsCount = ((dwElementsCount + 31) >> 5);
  149. }
  150. /*
  151. OutputDebugString("var : ");
  152. OutputDebugString(szVariableName);
  153. OutputDebugString("\n");
  154. */
  155. if (type == VT_UNKNOWN)
  156. {
  157. OutputDebugString("-- unknown var !!! ---------------- '");
  158. OutputDebugString(szVariableName);
  159. OutputDebugString("'----------------\n");
  160. DebugBreak();
  161. }
  162. DWORD dwIndexInPool = INVALID_ARRAY_INDEX;
  163. //void * ptrToPool = NULL;
  164. DWORD dwElementsToAdd = dwSlotsInPool * dwElementsCount;
  165. if (type == VT_BOOL)
  166. {
  167. dwIndexInPool = boolPool.Size();
  168. boolPool.AddElements(dwElementsToAdd);
  169. memset (&boolPool[dwIndexInPool], 0, dwElementsToAdd*sizeof(boolVector32));
  170. //ptrToPool = &boolPool[dwIndexInPool];
  171. } else
  172. {
  173. if (type == VT_TEXTURE)
  174. {
  175. dwIndexInPool = texturesAddrPool.Size();
  176. texturesAddrPool.AddElements(dwElementsToAdd);
  177. //ptrToPool = &texturesAddrPool[dwIndexInPool];
  178. } else
  179. {
  180. dwIndexInPool = vector4Pool.Size();
  181. vector4Pool.AddElements(dwElementsToAdd);
  182. //ptrToPool = &vector4Pool[dwIndexInPool];
  183. }
  184. }
  185. Assert(dwIndexInPool != INVALID_ARRAY_INDEX);
  186. IVariable* varHandle = varPool.Allocate();
  187. //Передаем index как указатель пока, потом надо будет сделать fixup всем...
  188. varHandle->Init(type, dwElementsCount, dwSlotsInPool, (void*)dwIndexInPool);
  189. if (type == VT_TEXTURE)
  190. {
  191. texture_variables.Add(varHandle);
  192. }
  193. variables.Add(varHandle);
  194. variables_hash.Add(szVariableName, varHandle);
  195. }
  196. /*
  197. void VariablesDB::SetFloat(void * ptrInPool, float val)
  198. {
  199. ((Vector4*)ptrInPool)->x = val;
  200. }
  201. void VariablesDB::SetBool32(void * ptrInPool, boolVector32 val)
  202. {
  203. *((boolVector32*)ptrInPool) = val;
  204. }
  205. void VariablesDB::SetTexture(void * ptrInPool, IBaseTexture* val)
  206. {
  207. IDirect3DBaseTexture9** texAddres = ((IDirect3DBaseTexture9**)ptrInPool);
  208. IDirect3DBaseTexture9 * pDXTexture = NGRender::pRS->GetDXBaseTexture(val);
  209. *texAddres = pDXTexture;
  210. }
  211. void VariablesDB::SetMatrix(void * ptrInPool, const Matrix& val)
  212. {
  213. Vector4* vecPtr = (Vector4*)ptrInPool;
  214. vecPtr->x = val.m[0][0];
  215. vecPtr->y = val.m[1][0];
  216. vecPtr->z = val.m[2][0];
  217. vecPtr->w = val.m[3][0];
  218. vecPtr++;
  219. vecPtr->x = val.m[0][1];
  220. vecPtr->y = val.m[1][1];
  221. vecPtr->z = val.m[2][1];
  222. vecPtr->w = val.m[3][1];
  223. vecPtr++;
  224. vecPtr->x = val.m[0][2];
  225. vecPtr->y = val.m[1][2];
  226. vecPtr->z = val.m[2][2];
  227. vecPtr->w = val.m[3][2];
  228. vecPtr++;
  229. vecPtr->x = val.m[0][3];
  230. vecPtr->y = val.m[1][3];
  231. vecPtr->z = val.m[2][3];
  232. vecPtr->w = val.m[3][3];
  233. }
  234. void VariablesDB::SetVector(void * ptrInPool, const Vector & val)
  235. {
  236. ((Vector4*)ptrInPool)->v = val;
  237. }
  238. void VariablesDB::SetVector4(void * ptrInPool, const Vector4 & val)
  239. {
  240. *((Vector4*)ptrInPool) = val;
  241. }
  242. void VariablesDB::SetVectorAsVector4(void * ptrInPool, const Vector & val)
  243. {
  244. ((Vector4*)ptrInPool)->v = val;
  245. ((Vector4*)ptrInPool)->w = 1.0f;
  246. }
  247. void VariablesDB::SetVector4Array(void * ptrInPool, const Vector4* val, dword dwCount)
  248. {
  249. XMemCpy(ptrInPool, val, sizeof(Vector4) * dwCount);
  250. }
  251. */
  252. IDirect3DBaseTexture9** VariablesDB::getTextureOutput (const char * szName)
  253. {
  254. #ifndef STOP_DEBUG
  255. DebugAssert(bDebugIsConst == true);
  256. #endif
  257. IVariable* var = NULL;
  258. variables_hash.Find(szName, var);
  259. if (var == NULL)
  260. {
  261. return NULL;
  262. }
  263. IDirect3DBaseTexture9** retVal = (IDirect3DBaseTexture9**)var->getVariableInplacePointer();
  264. return retVal;
  265. }
  266. boolVector32* VariablesDB::getBool32Output (const char * szName)
  267. {
  268. #ifndef STOP_DEBUG
  269. DebugAssert(bDebugIsConst == true);
  270. #endif
  271. IVariable* var = NULL;
  272. variables_hash.Find(szName, var);
  273. if (var == NULL)
  274. {
  275. return NULL;
  276. }
  277. boolVector32* retVal = (boolVector32*)var->getVariableInplacePointer();
  278. return retVal;
  279. }
  280. Vector4* VariablesDB::getVectorOutput (const char * szName)
  281. {
  282. #ifndef STOP_DEBUG
  283. DebugAssert(bDebugIsConst == true);
  284. #endif
  285. IVariable* var = NULL;
  286. variables_hash.Find(szName, var);
  287. if (var == NULL)
  288. {
  289. return NULL;
  290. }
  291. Vector4* retVal = (Vector4*)var->getVariableInplacePointer();
  292. return retVal;
  293. }
  294. void VariablesDB::ResetAllTextureVariables()
  295. {
  296. for (DWORD i = 0; i < texture_variables.Size(); i++)
  297. {
  298. texture_variables[i]->ResetTexture();
  299. }
  300. }
  301. void VariablesDB::ApplyFogVariables (ShaderFogVariables& vars)
  302. {
  303. if (_fFogHeightDensity)
  304. {
  305. _fFogHeightDensity->SetFloat(vars.fHeight_Density);
  306. }
  307. if (_fFogHeightMin)
  308. {
  309. _fFogHeightMin->SetFloat(vars.fHeight_Min);
  310. }
  311. if (_fFogHeightMax)
  312. {
  313. _fFogHeightMax->SetFloat(vars.fHeight_Max);
  314. }
  315. if (_fFogHeightDistanceInv)
  316. {
  317. _fFogHeightDistanceInv->SetFloat(vars.fHeight_DistanceInv);
  318. }
  319. if (_fFogDensity)
  320. {
  321. _fFogDensity->SetFloat(vars.fDistance_Density);
  322. }
  323. if (_fFogDistanceMin)
  324. {
  325. _fFogDistanceMin->SetFloat(vars.fDistance_Min);
  326. }
  327. if (_fFogDistanceMax)
  328. {
  329. _fFogDistanceMax->SetFloat(vars.fDistance_Max);
  330. }
  331. if (_fFogDistanceMinSquared)
  332. {
  333. _fFogDistanceMinSquared->SetFloat(vars.fDistance_MinSquared);
  334. }
  335. if (_fFogDistanceLen)
  336. {
  337. _fFogDistanceLen->SetFloat(vars.fDistance_DistanceInv);
  338. }
  339. if (_cFogColor)
  340. {
  341. _cFogColor->SetVector4(vars.fogColor.v4);
  342. }
  343. }
  344. void VariablesDB::ApplyLightingVariables30 (const ShaderLightingVariables& vars, dword lightCount)
  345. {
  346. boolVector32 lightMask;
  347. if (lightCount == 0)
  348. {
  349. lightMask.value = 0x0;
  350. _bLightEnabled30_count->SetBool32(lightMask);
  351. return;
  352. }
  353. //Надо сформировать масочку, в один dword
  354. Assert(MAX_LIGHTS_IN_30_MODEL <= 32);
  355. lightMask.value = (1 << lightCount)-1;
  356. _bLightEnabled30_count->SetBool32(lightMask);
  357. _fPointLightParams_array->SetVector4Array((const Vector4 *)vars.pointLights.vPointLightsParams, lightCount);
  358. _vPointLightPos30_array->SetVector4Array((const Vector4 *)vars.pointLights.vPointLightPos, lightCount);
  359. _vPointLightColor30_array->SetVector4Array((const Vector4 *)vars.pointLights.vPointLightColor, lightCount);
  360. _vPointLightColorSpecular30_array->SetVector4Array((const Vector4 *)vars.pointLights.vPointLightColorSpecular, lightCount);
  361. }
  362. void VariablesDB::ApplyEnvironmentLightingVariables (const ShaderLightingVariables& vars, Vector4 vCamDirRelativeWorld)
  363. {
  364. if (_vAmbientLight)
  365. {
  366. _vAmbientLight->SetVector4(vars.ambientLight.vAmbientLight.v4);
  367. }
  368. if (_vAmbientLightSpecular)
  369. {
  370. _vAmbientLightSpecular->SetVector4(vars.ambientLight.vAmbientLightSpecular.v4);
  371. }
  372. if (_vGlobalLightDirection)
  373. {
  374. _vGlobalLightDirection->SetVectorAsVector4(vars.dirLight.vGlobalLightDirection);
  375. }
  376. if (_vGlobalLightDirectionSpecular)
  377. {
  378. Vector4 specDir;
  379. if (vars.dirLight.dwAttachSpecDirToCam)
  380. {
  381. specDir.v = Vector (-vCamDirRelativeWorld.x, vCamDirRelativeWorld.y, -vCamDirRelativeWorld.z);
  382. specDir.w = 0.0f;
  383. } else
  384. {
  385. specDir = vars.dirLight.vGlobalLightDirection;
  386. }
  387. _vGlobalLightDirectionSpecular->SetVector4(specDir);
  388. }
  389. if (_vGlobalLightColor)
  390. {
  391. _vGlobalLightColor->SetVector4(vars.dirLight.vGlobalLightColor.v4);
  392. }
  393. if (_vGlobalLightColorSpecular)
  394. {
  395. _vGlobalLightColorSpecular->SetVector4(vars.dirLight.vGlobalLightColorSpecular.v4);
  396. }
  397. if (_vGlobalLightBackColor)
  398. {
  399. _vGlobalLightBackColor->SetVector4(vars.dirLight.vGlobalLightBackColor.v4);
  400. }
  401. }
  402. void VariablesDB::ApplyStandartVariables (ShaderStandartVariables & vars)
  403. {
  404. if (_mWorldViewProj)
  405. {
  406. _mWorldViewProj->SetMatrix(*vars.mWorldViewProj);
  407. }
  408. if (_mWorld)
  409. {
  410. _mWorld->SetMatrix(*vars.mWorld);
  411. }
  412. if (_vWorldPos)
  413. {
  414. _vWorldPos->SetVector(vars.mWorld->pos);
  415. }
  416. if (_mView)
  417. {
  418. _mView->SetMatrix(*vars.mView);
  419. }
  420. if (_mProjection)
  421. {
  422. _mProjection->SetMatrix(*vars.mProjection);
  423. }
  424. if (_mInverseView)
  425. {
  426. _mInverseView->SetMatrix(*vars.mInverseView);
  427. }
  428. if (_vCamPosRelativeWorld)
  429. {
  430. _vCamPosRelativeWorld->SetVector(vars.vCamPosRelativeWorld->v);
  431. }
  432. if (_vCamDirRelativeWorld)
  433. {
  434. _vCamDirRelativeWorld->SetVector(vars.vCamDirRelativeWorld->v);
  435. }
  436. if (_vCamPos)
  437. {
  438. Vector camPos_ObjectSpace;
  439. camPos_ObjectSpace = vars.vCamPosRelativeWorld->v * *vars.mInverseWorld;
  440. _vCamPos->SetVector(camPos_ObjectSpace);
  441. }
  442. }
  443. void VariablesDB::BindStandartVariables ()
  444. {
  445. _mWorldViewProj = getShaderVariable("mWorldViewProj", _FL_);
  446. _mWorld = getShaderVariable("mWorld", _FL_);
  447. _mView = getShaderVariable("mView", _FL_);
  448. _mProjection = getShaderVariable("mProjection", _FL_);
  449. _mInverseView = getShaderVariable("mInverseView", _FL_);
  450. _vWorldPos = getShaderVariable("vWorldPos", _FL_);
  451. _vCamPosRelativeWorld = getShaderVariable("vCamPosRelativeWorld", _FL_);
  452. _vCamDirRelativeWorld = getShaderVariable("vCamDirRelativeWorld", _FL_);
  453. _vCamPos = getShaderVariable("vCamPos", _FL_);
  454. _fFogHeightDensity = getShaderVariable("fFogHeightDensity", _FL_);
  455. _fFogHeightMin = getShaderVariable("fFogHeightMin", _FL_);
  456. _fFogHeightMax = getShaderVariable("fFogHeightMax", _FL_);
  457. _fFogHeightDistanceInv = getShaderVariable("fFogHeightDistanceInv", _FL_);
  458. _fFogDensity = getShaderVariable("fFogDensity", _FL_);
  459. _fFogDistanceMin = getShaderVariable("fFogDistanceMin", _FL_);
  460. _fFogDistanceMax = getShaderVariable("fFogDistanceMax", _FL_);
  461. _fFogDistanceMinSquared = getShaderVariable("fFogDistanceMinSquared", _FL_);
  462. _fFogDistanceLen = getShaderVariable("fFogDistanceLen", _FL_);
  463. _cFogColor = getShaderVariable("cFogColor", _FL_);
  464. _vAmbientLight = getShaderVariable("vAmbientLight", _FL_);
  465. _vAmbientLightSpecular = getShaderVariable("vAmbientLightSpecular", _FL_);
  466. _vGlobalLightColor = getShaderVariable("vGlobalLightColor", _FL_);
  467. _vGlobalLightDirection = getShaderVariable("vGlobalLightDirection", _FL_);
  468. _vGlobalLightDirectionSpecular = getShaderVariable("vGlobalLightDirectionSpec", _FL_);
  469. _vGlobalLightBackColor = getShaderVariable("vGlobalLightBackColor", _FL_);
  470. _vGlobalLightColorSpecular = getShaderVariable("vGlobalLightColorSpecular", _FL_);
  471. _bLightEnabled30_count = getShaderVariable("bLightEnabled30", _FL_);
  472. _fPointLightParams_array = getShaderVariable("fPointLightParams", _FL_);
  473. _vPointLightPos30_array = getShaderVariable("vPointLightPos30", _FL_);
  474. _vPointLightColor30_array = getShaderVariable("vPointLightColor30", _FL_);
  475. _vPointLightColorSpecular30_array = getShaderVariable("vPointLightColorSpecular30", _FL_);
  476. }
  477. //=============================================================================================
  478. //=============================================================================================
  479. //=============================================================================================
  480. //=============================================================================================
  481. //=============================================================================================
  482. /*
  483. VariableHandle::VariableHandle()
  484. {
  485. db = NULL;
  486. type = VT_UNKNOWN;
  487. dwElementsCount = 0;
  488. dwSlotsInPool = 0;
  489. ptrInPool = NULL;
  490. }
  491. VariableHandle::~VariableHandle()
  492. {
  493. }
  494. void VariableHandle::Init (VariablesDB * _db, VariableType _type, DWORD _dwElementsCount, DWORD _dwSlotsInPool, void * _ptrInPool)
  495. {
  496. db = _db;
  497. type = _type;
  498. dwElementsCount = _dwElementsCount;
  499. dwSlotsInPool = _dwSlotsInPool;
  500. ptrInPool = _ptrInPool;
  501. }
  502. void VariableHandle::SetFloat(float val)
  503. {
  504. Assert (type == VT_FLOAT && dwElementsCount == 1);
  505. db->SetFloat(ptrInPool, val);
  506. }
  507. void VariableHandle::SetBool32(boolVector32 val)
  508. {
  509. Assert (type == VT_BOOL && dwElementsCount == 1);
  510. db->SetBool32(ptrInPool, val);
  511. }
  512. void VariableHandle::SetTexture(IBaseTexture* val)
  513. {
  514. Assert (type == VT_TEXTURE && dwElementsCount == 1);
  515. db->SetTexture(ptrInPool, val);
  516. }
  517. void VariableHandle::SetMatrix(const Matrix& val)
  518. {
  519. Assert (type == VT_MATRIX4x4 && dwElementsCount == 1);
  520. db->SetMatrix(ptrInPool, val);
  521. }
  522. void VariableHandle::SetVector(const Vector & val)
  523. {
  524. Assert (type == VT_VECTOR3 && dwElementsCount == 1);
  525. db->SetVector(ptrInPool, val);
  526. }
  527. void VariableHandle::SetVector4(const Vector4 & val)
  528. {
  529. Assert (type == VT_VECTOR4 && dwElementsCount == 1);
  530. db->SetVector4(ptrInPool, val);
  531. }
  532. void VariableHandle::SetVectorAsVector4(const Vector & val)
  533. {
  534. Assert (type == VT_VECTOR4 && dwElementsCount == 1);
  535. db->SetVectorAsVector4(ptrInPool, val);
  536. }
  537. void VariableHandle::SetVector4Array(const Vector4* val, dword dwCount)
  538. {
  539. Assert (type == VT_VECTOR4 && dwElementsCount >= 1);
  540. Assert(dwCount <= dwElementsCount);
  541. db->SetVector4Array(ptrInPool, val, dwCount);
  542. }
  543. void VariableHandle::ResetTexture()
  544. {
  545. }
  546. void * VariableHandle::getVariableInplacePointer ()
  547. {
  548. return ptrInPool;
  549. }
  550. void VariableHandle::convertOffsetToPointer(Vector4 * v4Pool, boolVector32 * bPool, IDirect3DBaseTexture9** tPool)
  551. {
  552. Assert(v4Pool != NULL);
  553. Assert(bPool != NULL);
  554. Assert(tPool != NULL);
  555. DWORD dwOffset = (DWORD)ptrInPool;
  556. if (type == VT_BOOL)
  557. {
  558. ptrInPool = (bPool + dwOffset);
  559. } else
  560. {
  561. if (type == VT_TEXTURE)
  562. {
  563. ptrInPool = (tPool + dwOffset);
  564. } else
  565. {
  566. ptrInPool = (v4Pool + dwOffset);
  567. }
  568. }
  569. Assert(ptrInPool != NULL);
  570. }
  571. */
  572. #endif