World of Might and Magic  0.2.0
Open reimplementation of Might and Magic 6 7 8 game engine
Структура BspRenderer

#include <Indoor.h>

+ Граф связей класса BspRenderer:

Открытые члены

 BspRenderer ()
 
void AddFaceToRenderList_d3d (unsigned int node_id, unsigned int uFaceID)
 
void MakeVisibleSectorList ()
 

Открытые атрибуты

unsigned int num_faces
 
BspFace faces [1000]
 
unsigned int num_nodes
 
BspRenderer_stru0 nodes [150]
 
unsigned int uNumVisibleNotEmptySectors
 
uint16_t pVisibleSectorIDs_toDrawDecorsActorsEtcFrom [6]
 

Подробное описание

См. определение в файле Indoor.h строка 800

Конструктор(ы)

◆ BspRenderer()

BspRenderer::BspRenderer ( )
inline

См. определение в файле Indoor.h строка 802

802  {
803  num_faces = 0;
804  num_nodes = 0;
806  }

Перекрестные ссылки num_faces, num_nodes и uNumVisibleNotEmptySectors.

Методы

◆ AddFaceToRenderList_d3d()

void BspRenderer::AddFaceToRenderList_d3d ( unsigned int  node_id,
unsigned int  uFaceID 
)

См. определение в файле Indoor.cpp строка 584

585  {
586  unsigned __int16 pTransitionSector; // ax@11
587  int v9; // edx@15
588  char v29; // al@48
589 
591  // v39 = &pIndoor->pFaces[uFaceID];
592 
593  BLVFace *pFace = &pIndoor->pFaces[uFaceID];
594 
595  if (!pFace->Portal()) {
596  if (num_faces < 1000) {
597  faces[num_faces].uFaceID = uFaceID;
598  faces[num_faces++].uNodeID = node_id;
599  }
600  return;
601  }
602 
603  // portals are invisible faces marking the transition between sectors
604 
605  if (nodes[node_id].uFaceID == uFaceID) return;
606  if (!node_id &&
608  pFace->pBounding.x1 -
609  16 && // we are probably standing at the portal plane
610  pIndoorCameraD3D->vPartyPos.x <= pFace->pBounding.x2 + 16 &&
611  pIndoorCameraD3D->vPartyPos.y >= pFace->pBounding.y1 - 16 &&
612  pIndoorCameraD3D->vPartyPos.y <= pFace->pBounding.y2 + 16 &&
613  pIndoorCameraD3D->vPartyPos.z >= pFace->pBounding.z1 - 16 &&
614  pIndoorCameraD3D->vPartyPos.z <= pFace->pBounding.z2 + 16) {
615  if (abs(pFace->pFacePlane_old.dist +
617  pFace->pFacePlane_old.vNormal.x +
619  pFace->pFacePlane_old.vNormal.y +
621  pFace->pFacePlane_old.vNormal.z) <=
622  589824) { // we sure are standing at the portal plane
623  pTransitionSector = pFace->uSectorID;
624  if (nodes[0].uSectorID == pTransitionSector) // draw back sector
625  pTransitionSector = pFace->uBackSectorID;
626  nodes[num_nodes].uSectorID = pTransitionSector;
627  nodes[num_nodes].uFaceID = uFaceID;
636  return;
637  }
638  }
639 
640  v9 = pFace->pFacePlane_old.vNormal.x *
641  (pIndoor->pVertices[pFace->pVertexIDs[0]].x -
643  pFace->pFacePlane_old.vNormal.y *
644  (pIndoor->pVertices[pFace->pVertexIDs[0]].y -
646  pFace->pFacePlane_old.vNormal.z *
647  (pIndoor->pVertices[pFace->pVertexIDs[0]].z -
649  if (nodes[node_id].uSectorID != pFace->uSectorID) v9 = -v9;
650  if (v9 >= 0) return;
651 
652  // check number of verts of portal is seen by camera
653  int num_vertices = GetPortalScreenCoord(uFaceID);
654  if (num_vertices < 2) return;
655 
656  int face_min_screenspace_x = PortalFace._screen_space_x[0],
657  face_max_screenspace_x = PortalFace._screen_space_x[0];
658  int face_min_screenspace_y = PortalFace._screen_space_y[0],
659  face_max_screenspace_y = PortalFace._screen_space_y[0];
660  for (uint i = 1; i < num_vertices; ++i) {
661  if (face_min_screenspace_x > PortalFace._screen_space_x[i])
662  face_min_screenspace_x = PortalFace._screen_space_x[i];
663  if (face_max_screenspace_x < PortalFace._screen_space_x[i])
664  face_max_screenspace_x = PortalFace._screen_space_x[i];
665 
666  if (face_min_screenspace_y > PortalFace._screen_space_y[i])
667  face_min_screenspace_y = PortalFace._screen_space_y[i];
668  if (face_max_screenspace_y < PortalFace._screen_space_y[i])
669  face_max_screenspace_y = PortalFace._screen_space_y[i];
670  }
671  // _screen_space_x = 719, 568, 493
672  // savegame: qw , 0Bh and 0x1D4h
673  // problem here when standing near/on portal, condition is false because of
674  // face_min_screenspace_x > p->uViewportZ
675  if (face_max_screenspace_x >= nodes[node_id].uViewportX &&
676  face_min_screenspace_x <= nodes[node_id].uViewportZ &&
677  face_max_screenspace_y >= nodes[node_id].uViewportY &&
678  face_min_screenspace_y <= nodes[node_id].uViewportW &&
679  PortalFrustrum(num_vertices, &nodes[num_nodes].PortalScreenData,
680  &nodes[node_id].PortalScreenData, uFaceID)) {
681  // current portal visible through previous
682 
683  pTransitionSector = pFace->uSectorID;
684  if (nodes[node_id].uSectorID == pTransitionSector)
685  pTransitionSector = pFace->uBackSectorID;
686  nodes[num_nodes].uSectorID = pTransitionSector;
687  nodes[num_nodes].uFaceID = uFaceID;
692  v29 = false;
693  if (nodes[node_id].viewing_portal_id == -1) { // for first portal
694  v29 = engine->pStru10Instance->CalcPortalShape(
695  pFace, nodes[num_nodes].std__vector_0007AC,
696  nodes[num_nodes].pPortalBounding);
697  } else { // for next portals
698  static RenderVertexSoft static_subAddFaceToRenderList_d3d_stru_F7AA08[64];
699  static RenderVertexSoft static_subAddFaceToRenderList_d3d_stru_F79E08[64];
700 
701  for (uint k = 0; k < pFace->uNumVertices; ++k) {
702  static_subAddFaceToRenderList_d3d_stru_F7AA08[k].vWorldPosition.x =
703  pIndoor->pVertices[pFace->pVertexIDs[k]].x;
704  static_subAddFaceToRenderList_d3d_stru_F7AA08[k].vWorldPosition.y =
705  pIndoor->pVertices[pFace->pVertexIDs[k]].y;
706  static_subAddFaceToRenderList_d3d_stru_F7AA08[k].vWorldPosition.z =
707  pIndoor->pVertices[pFace->pVertexIDs[k]].z;
708  }
709 
710  unsigned int pNewNumVertices = pFace->uNumVertices;
712  static_subAddFaceToRenderList_d3d_stru_F7AA08, &pNewNumVertices,
713  static_subAddFaceToRenderList_d3d_stru_F79E08,
714  nodes[node_id].std__vector_0007AC, 4, 0, 0);
715 
716  v29 = engine->pStru10Instance->_49C5DA(
717  pFace, static_subAddFaceToRenderList_d3d_stru_F79E08,
718  &pNewNumVertices, nodes[num_nodes].std__vector_0007AC,
719  nodes[num_nodes].pPortalBounding);
720  }
721 
722  if (1) {
723  assert(num_nodes < 150);
724 
725  // add portal sector to drawing list
726 
727  nodes[num_nodes].viewing_portal_id = uFaceID;
729  }
730 
731  if (pIndoorCameraD3D->debug_flags & BLV_RENDER_DRAW_SW_OUTLINES)
733  // pIndoorCameraD3D->DebugDrawPortal(pFace);
734  }
735 }

Перекрестные ссылки stru367::_screen_space_x, stru367::_screen_space_y, AddBspNodeToRenderList(), IndoorCameraD3D::CalcPortalShape(), IndoorCameraD3D::debug_flags, Plane_int_::dist, engine, faces, GetPortalScreenCoord(), BspRenderer_PortalViewportData::GetViewportData(), nodes, num_faces, num_nodes, pBLVRenderParams, BLVFace::pBounding, BLVFace::pFacePlane_old, IndoorLocation::pFaces, pIndoor, pIndoorCameraD3D, BLVFace::Portal(), PortalFace, PortalFrustrum(), BspRenderer_stru0::PortalScreenData, IndoorCameraD3D::PrepareAndDrawDebugOutline(), BLVFace::pVertexIDs, IndoorLocation::pVertices, BLVFace::uBackSectorID, BspRenderer_stru0::uFaceID, BspFace::uFaceID, BspFace::uNodeID, BLVFace::uNumVertices, BLVFace::uSectorID, BspRenderer_stru0::uSectorID, BLVRenderParams::uViewportW, BspRenderer_stru0::uViewportW, BLVRenderParams::uViewportX, BspRenderer_stru0::uViewportX, BLVRenderParams::uViewportY, BspRenderer_stru0::uViewportY, BLVRenderParams::uViewportZ, BspRenderer_stru0::uViewportZ, BspRenderer_stru0::viewing_portal_id, Plane_int_::vNormal, IndoorCameraD3D::vPartyPos, RenderVertexSoft::vWorldPosition, Vec2< T >::x, Vec3_float_::x, BBox_short_::x1, BBox_short_::x2, Vec2< T >::y, Vec3_float_::y, BBox_short_::y1, BBox_short_::y2, Vec3< T >::z, Vec3_float_::z, BBox_short_::z1 и BBox_short_::z2.

Используется в AddBspNodeToRenderList() и sub_4406BC().

+ Граф вызовов:
+ Граф вызова функции:

◆ MakeVisibleSectorList()

void BspRenderer::MakeVisibleSectorList ( )

См. определение в файле Indoor.cpp строка 3692

3692  {
3693  // int v6; // ebx@3
3694 
3696  for (uint i = 0; i < num_nodes; ++i) {
3697  // if (!uNumVisibleNotEmptySectors)
3698  //{
3699  // pVisibleSectorIDs_toDrawDecorsActorsEtcFrom[uNumVisibleNotEmptySectors++]
3700  // = nodes[i].uSectorID; continue;
3701  //}
3702  // v6 = 0;
3703  // while (pVisibleSectorIDs_toDrawDecorsActorsEtcFrom[v6] !=
3704  // nodes[i].uSectorID )
3705  for (uint j = 0; j < uNumVisibleNotEmptySectors; j++) {
3706  // ++v6;
3708  nodes[i].uSectorID)
3709  break;
3710  }
3713  }
3714 }

Перекрестные ссылки nodes, num_nodes, pVisibleSectorIDs_toDrawDecorsActorsEtcFrom, uNumVisibleNotEmptySectors и BspRenderer_stru0::uSectorID.

Используется в PrepareBspRenderList_BLV().

+ Граф вызова функции:

Данные класса

◆ num_faces

unsigned int BspRenderer::num_faces

◆ faces

BspFace BspRenderer::faces[1000]

См. определение в файле Indoor.h строка 814

Используется в AddFaceToRenderList_d3d(), IndoorLocation::ExecDraw(), Vis::PickIndoorFaces_Keyboard() и Vis::PickIndoorFaces_Mouse().

◆ num_nodes

unsigned int BspRenderer::num_nodes

См. определение в файле Indoor.h строка 816

Используется в AddFaceToRenderList_d3d(), BspRenderer(), MakeVisibleSectorList() и PrepareBspRenderList_BLV().

◆ nodes

BspRenderer_stru0 BspRenderer::nodes[150]

См. определение в файле Indoor.h строка 817

Используется в AddBspNodeToRenderList(), AddFaceToRenderList_d3d(), IndoorLocation::ExecDraw(), MakeVisibleSectorList(), PrepareBspRenderList_BLV() и sub_4406BC().

◆ uNumVisibleNotEmptySectors

unsigned int BspRenderer::uNumVisibleNotEmptySectors

См. определение в файле Indoor.h строка 818

Используется в BspRenderer(), MakeVisibleSectorList(), IndoorLocation::PrepareActorRenderList_BLV() и PrepareDrawLists_BLV().

◆ pVisibleSectorIDs_toDrawDecorsActorsEtcFrom

uint16_t BspRenderer::pVisibleSectorIDs_toDrawDecorsActorsEtcFrom[6]

См. определение в файле Indoor.h строка 819

Используется в MakeVisibleSectorList() и PrepareDrawLists_BLV().


Объявления и описания членов структур находятся в файлах:
BspRenderer_stru0::uViewportY
uint16_t uViewportY
Definition: Indoor.h:778
IndoorCameraD3D::CalcPortalShape
bool CalcPortalShape(struct RenderVertexSoft *a1, unsigned int *pOutNumVertices, struct RenderVertexSoft *pVertices, IndoorCameraD3D_Vec4 *a4, signed int uNumVertices, char a6, int _unused)
Definition: IndoorCameraD3D.cpp:697
stru367::_screen_space_y
std::array< int, 60 > _screen_space_y
Definition: stru367.h:14
BLVFace::Portal
bool Portal() const
Definition: Indoor.h:448
BspRenderer::uNumVisibleNotEmptySectors
unsigned int uNumVisibleNotEmptySectors
Definition: Indoor.h:818
BLVFace::uNumVertices
uint8_t uNumVertices
Definition: Indoor.h:488
BLVFace::pFacePlane_old
struct Plane_int_ pFacePlane_old
Definition: Indoor.h:471
Vec2::x
T x
Definition: VectorTypes.h:12
BspRenderer::num_faces
unsigned int num_faces
Definition: Indoor.h:812
BspRenderer_stru0::PortalScreenData
BspRenderer_PortalViewportData PortalScreenData
Definition: Indoor.h:782
BLVFace::pVertexIDs
uint16_t * pVertexIDs
Definition: Indoor.h:476
Vec3_float_::x
float x
Definition: VectorTypes.h:89
pBLVRenderParams
BLVRenderParams * pBLVRenderParams
Definition: Indoor.cpp:50
BBox_short_::x1
int16_t x1
Definition: VectorTypes.h:114
engine
std::shared_ptr< Engine > engine
Definition: Engine.cpp:130
BspRenderer_stru0::uSectorID
uint16_t uSectorID
Definition: Indoor.h:776
BBox_short_::y1
int16_t y1
Definition: VectorTypes.h:116
Vec3_float_::y
float y
Definition: VectorTypes.h:90
Vec3_float_::z
float z
Definition: VectorTypes.h:91
BBox_short_::z2
int16_t z2
Definition: VectorTypes.h:119
pIndoor
IndoorLocation * pIndoor
Definition: Indoor.cpp:49
stru367::_screen_space_x
std::array< int, 60 > _screen_space_x
Definition: stru367.h:15
Plane_int_::vNormal
Vec3_int_ vNormal
Definition: VectorTypes.h:107
BspFace::uNodeID
uint16_t uNodeID
Definition: Indoor.h:794
BLVRenderParams::uViewportZ
unsigned int uViewportZ
Definition: Indoor.h:698
BspRenderer_stru0::uViewportW
uint16_t uViewportW
Definition: Indoor.h:780
IndoorCameraD3D::vPartyPos
Vec3< int > vPartyPos
Definition: IndoorCameraD3D.h:253
AddBspNodeToRenderList
void AddBspNodeToRenderList(unsigned int node_id)
Definition: Indoor.cpp:2970
Vec2::y
T y
Definition: VectorTypes.h:13
BspRenderer_stru0::uFaceID
uint16_t uFaceID
Definition: Indoor.h:783
BLVRenderParams::uViewportW
unsigned int uViewportW
Definition: Indoor.h:699
BspRenderer::nodes
BspRenderer_stru0 nodes[150]
Definition: Indoor.h:817
BspFace::uFaceID
uint16_t uFaceID
Definition: Indoor.h:793
BspRenderer_stru0::uViewportX
uint16_t uViewportX
Definition: Indoor.h:777
BBox_short_::y2
int16_t y2
Definition: VectorTypes.h:117
BLVFace::uSectorID
uint16_t uSectorID
Definition: Indoor.h:484
PortalFrustrum
bool PortalFrustrum(int pNumVertices, BspRenderer_PortalViewportData *far_portal, BspRenderer_PortalViewportData *near_portal, int uFaceID)
Definition: Indoor.cpp:3788
BLVFace
Definition: Indoor.h:424
BspRenderer::faces
BspFace faces[1000]
Definition: Indoor.h:814
BLVRenderParams::uViewportX
unsigned int uViewportX
Definition: Indoor.h:696
BspRenderer::pVisibleSectorIDs_toDrawDecorsActorsEtcFrom
uint16_t pVisibleSectorIDs_toDrawDecorsActorsEtcFrom[6]
Definition: Indoor.h:819
BspRenderer::num_nodes
unsigned int num_nodes
Definition: Indoor.h:816
PortalFace
stru367 PortalFace
Definition: mm7_data.cpp:564
BLVFace::uBackSectorID
int16_t uBackSectorID
Definition: Indoor.h:485
BLVFace::pBounding
struct BBox_short_ pBounding
Definition: Indoor.h:486
Plane_int_::dist
int dist
Definition: VectorTypes.h:108
BspRenderer_PortalViewportData::GetViewportData
void GetViewportData(int16_t x, int y, int16_t z, int w)
Definition: Indoor.cpp:3181
BspRenderer_stru0::viewing_portal_id
unsigned int viewing_portal_id
Definition: Indoor.h:785
uint
unsigned int uint
Definition: MM7.h:4
IndoorCameraD3D::debug_flags
int debug_flags
Definition: IndoorCameraD3D.h:255
RenderVertexSoft::vWorldPosition
Vec3_float_ vWorldPosition
Definition: IRender.h:116
GetPortalScreenCoord
int GetPortalScreenCoord(unsigned int uFaceID)
Definition: Indoor.cpp:4045
IndoorLocation::pVertices
struct Vec3_short_ * pVertices
Definition: Indoor.h:628
IndoorLocation::pFaces
struct BLVFace * pFaces
Definition: Indoor.h:630
BBox_short_::x2
int16_t x2
Definition: VectorTypes.h:115
RenderVertexSoft
Definition: IRender.h:113
BBox_short_::z1
int16_t z1
Definition: VectorTypes.h:118
pIndoorCameraD3D
IndoorCameraD3D * pIndoorCameraD3D
Definition: IndoorCameraD3D.cpp:21
BLVRenderParams::uViewportY
unsigned int uViewportY
Definition: Indoor.h:697
IndoorCameraD3D::PrepareAndDrawDebugOutline
void PrepareAndDrawDebugOutline(struct BLVFace *pFace, unsigned int uDiffuse)
Definition: IndoorCameraD3D.cpp:445
BspRenderer_stru0::uViewportZ
uint16_t uViewportZ
Definition: Indoor.h:779
Vec3::z
T z
Definition: VectorTypes.h:27