Additional work on CMapWorld rendering

This commit is contained in:
Jack Andersen 2017-04-22 11:46:18 -10:00
parent 337ffd1c16
commit d54bb3746c
19 changed files with 391 additions and 105 deletions

View File

@ -99,6 +99,15 @@ static const char* RetroMapVisModes[] =
"NEVER" "NEVER"
}; };
static const char* RetroMapObjVisModes[] =
{
"ALWAYS",
"MAPSTATIONORVISIT",
"VISIT",
"NEVER",
"MAPSTATIONORVISIT2"
};
template <typename PAKRouter> template <typename PAKRouter>
bool ReadMAPAToBlender(hecl::BlenderConnection& conn, bool ReadMAPAToBlender(hecl::BlenderConnection& conn,
const MAPA& mapa, const MAPA& mapa,
@ -118,13 +127,18 @@ bool ReadMAPAToBlender(hecl::BlenderConnection& conn,
"from mathutils import Matrix\n" "from mathutils import Matrix\n"
"\n" "\n"
"bpy.types.Object.retro_mappable_type = bpy.props.IntProperty(name='Retro: MAPA object type', default=-1)\n" "bpy.types.Object.retro_mappable_type = bpy.props.IntProperty(name='Retro: MAPA object type', default=-1)\n"
"bpy.types.Object.retro_mappable_unk = bpy.props.IntProperty(name='Retro: MAPA object unk')\n"
"bpy.types.Object.retro_mappable_sclyid = bpy.props.StringProperty(name='Retro: MAPA object SCLY ID')\n" "bpy.types.Object.retro_mappable_sclyid = bpy.props.StringProperty(name='Retro: MAPA object SCLY ID')\n"
"bpy.types.Scene.retro_map_vis_mode = bpy.props.EnumProperty(items=[('ALWAYS', 'Always', 'Always Visible', 0)," "bpy.types.Scene.retro_map_vis_mode = bpy.props.EnumProperty(items=[('ALWAYS', 'Always', 'Always Visible', 0),"
"('MAPSTATIONORVISIT', 'Map Station or Visit', 'Visible after Map Station or Visit', 1)," "('MAPSTATIONORVISIT', 'Map Station or Visit', 'Visible after Map Station or Visit', 1),"
"('VISIT', 'Visit', 'Visible after Visit', 2)," "('VISIT', 'Visit', 'Visible after Visit', 2),"
"('NEVER', 'Never', 'Never Visible', 3)]," "('NEVER', 'Never', 'Never Visible', 3)],"
"name='Retro: Map Visibility Mode')\n" "name='Retro: Map Visibility Mode')\n"
"bpy.types.Object.retro_mapobj_vis_mode = bpy.props.EnumProperty(items=[('ALWAYS', 'Always', 'Always Visible', 0),"
"('MAPSTATIONORVISIT', 'Map Station or Visit', 'Visible after Map Station or Visit', 1),"
"('VISIT', 'Visit', 'Visible after Door Visit', 2),"
"('NEVER', 'Never', 'Never Visible', 3),"
"('MAPSTATIONORVISIT2', 'Map Station or Visit 2', 'Visible after Map Station or Visit', 4)],"
"name='Retro: Map Object Visibility Mode')\n"
"\n" "\n"
"for ar in bpy.context.screen.areas:\n" "for ar in bpy.context.screen.areas:\n"
" for sp in ar.spaces:\n" " for sp in ar.spaces:\n"
@ -170,7 +184,7 @@ bool ReadMAPAToBlender(hecl::BlenderConnection& conn,
os.format("obj = bpy.data.objects.new('MAPOBJ_%02d', None)\n" os.format("obj = bpy.data.objects.new('MAPOBJ_%02d', None)\n"
"bpy.context.scene.objects.link(obj)\n" "bpy.context.scene.objects.link(obj)\n"
"obj.retro_mappable_type = %d\n" "obj.retro_mappable_type = %d\n"
"obj.retro_mappable_unk = %d\n" "obj.retro_mapobj_vis_mode = '%s'\n"
"obj.retro_mappable_sclyid = '0x%08X'\n" "obj.retro_mappable_sclyid = '0x%08X'\n"
"mtx = Matrix(((%f,%f,%f,%f),(%f,%f,%f,%f),(%f,%f,%f,%f),(0.0,0.0,0.0,1.0)))\n" "mtx = Matrix(((%f,%f,%f,%f),(%f,%f,%f,%f),(%f,%f,%f,%f),(0.0,0.0,0.0,1.0)))\n"
"mtxd = mtx.decompose()\n" "mtxd = mtx.decompose()\n"
@ -178,7 +192,7 @@ bool ReadMAPAToBlender(hecl::BlenderConnection& conn,
"obj.location = mtxd[0]\n" "obj.location = mtxd[0]\n"
"obj.rotation_quaternion = mtxd[1]\n" "obj.rotation_quaternion = mtxd[1]\n"
"obj.scale = mtxd[2]\n", "obj.scale = mtxd[2]\n",
moIdx, moMP12->type, moMP12->unknown1, moMP12->sclyId, moIdx, moMP12->type, RetroMapObjVisModes[moMP12->visMode], moMP12->sclyId,
moMP12->transformMtx[0].vec[0], moMP12->transformMtx[0].vec[1], moMP12->transformMtx[0].vec[2], moMP12->transformMtx[0].vec[3], moMP12->transformMtx[0].vec[0], moMP12->transformMtx[0].vec[1], moMP12->transformMtx[0].vec[2], moMP12->transformMtx[0].vec[3],
moMP12->transformMtx[1].vec[0], moMP12->transformMtx[1].vec[1], moMP12->transformMtx[1].vec[2], moMP12->transformMtx[1].vec[3], moMP12->transformMtx[1].vec[0], moMP12->transformMtx[1].vec[1], moMP12->transformMtx[1].vec[2], moMP12->transformMtx[1].vec[3],
moMP12->transformMtx[2].vec[0], moMP12->transformMtx[2].vec[1], moMP12->transformMtx[2].vec[2], moMP12->transformMtx[2].vec[3]); moMP12->transformMtx[2].vec[0], moMP12->transformMtx[2].vec[1], moMP12->transformMtx[2].vec[2], moMP12->transformMtx[2].vec[3]);
@ -191,7 +205,7 @@ bool ReadMAPAToBlender(hecl::BlenderConnection& conn,
os.format("obj = bpy.data.objects.new('MAPOBJ_%02d', None)\n" os.format("obj = bpy.data.objects.new('MAPOBJ_%02d', None)\n"
"bpy.context.scene.objects.link(obj)\n" "bpy.context.scene.objects.link(obj)\n"
"obj.retro_mappable_type = %d\n" "obj.retro_mappable_type = %d\n"
"obj.retro_mappable_unk = %d\n" "obj.retro_mapobj_vis_mode = '%s'\n"
"obj.retro_mappable_sclyid = '0x%08X'\n" "obj.retro_mappable_sclyid = '0x%08X'\n"
"mtx = Matrix(((%f,%f,%f,%f),(%f,%f,%f,%f),(%f,%f,%f,%f),(0.0,0.0,0.0,1.0)))\n" "mtx = Matrix(((%f,%f,%f,%f),(%f,%f,%f,%f),(%f,%f,%f,%f),(0.0,0.0,0.0,1.0)))\n"
"mtxd = mtx.decompose()\n" "mtxd = mtx.decompose()\n"
@ -199,7 +213,7 @@ bool ReadMAPAToBlender(hecl::BlenderConnection& conn,
"obj.location = mtxd[0]\n" "obj.location = mtxd[0]\n"
"obj.rotation_quaternion = mtxd[1]\n" "obj.rotation_quaternion = mtxd[1]\n"
"obj.scale = mtxd[2]\n", "obj.scale = mtxd[2]\n",
moIdx, moMP3->type, moMP3->unknown1, moMP3->sclyId, moIdx, moMP3->type, RetroMapObjVisModes[moMP3->visMode], moMP3->sclyId,
moMP3->transformMtx[0].vec[0], moMP3->transformMtx[0].vec[1], moMP3->transformMtx[0].vec[2], moMP3->transformMtx[0].vec[3], moMP3->transformMtx[0].vec[0], moMP3->transformMtx[0].vec[1], moMP3->transformMtx[0].vec[2], moMP3->transformMtx[0].vec[3],
moMP3->transformMtx[1].vec[0], moMP3->transformMtx[1].vec[1], moMP3->transformMtx[1].vec[2], moMP3->transformMtx[1].vec[3], moMP3->transformMtx[1].vec[0], moMP3->transformMtx[1].vec[1], moMP3->transformMtx[1].vec[2], moMP3->transformMtx[1].vec[3],
moMP3->transformMtx[2].vec[0], moMP3->transformMtx[2].vec[1], moMP3->transformMtx[2].vec[2], moMP3->transformMtx[2].vec[3]); moMP3->transformMtx[2].vec[0], moMP3->transformMtx[2].vec[1], moMP3->transformMtx[2].vec[2], moMP3->transformMtx[2].vec[3]);
@ -391,7 +405,7 @@ bool Cook(const hecl::BlenderConnection::DataStream::MapArea& mapaIn, const hecl
typename MAPAType::MappableObject& mobj = typename MAPAType::MappableObject& mobj =
static_cast<typename MAPAType::MappableObject&>(*mapa.mappableObjects.back()); static_cast<typename MAPAType::MappableObject&>(*mapa.mappableObjects.back());
mobj.type = MAPA::IMappableObject::Type(poi.type); mobj.type = MAPA::IMappableObject::Type(poi.type);
mobj.unknown1 = poi.unk; mobj.visMode = poi.visMode;
mobj.sclyId = poi.objid; mobj.sclyId = poi.objid;
mobj.transformMtx[0] = poi.xf.val[0]; mobj.transformMtx[0] = poi.xf.val[0];
mobj.transformMtx[1] = poi.xf.val[1]; mobj.transformMtx[1] = poi.xf.val[1];

View File

@ -120,7 +120,7 @@ struct MAPA : BigDNA
{ {
DECL_DNA DECL_DNA
Value<Type> type; Value<Type> type;
Value<atUint32> unknown1; Value<atUint32> visMode;
Value<atUint32> sclyId; Value<atUint32> sclyId;
Value<atInt32> seek1 = -1; Value<atInt32> seek1 = -1;
Value<atVec4f> transformMtx[3]; Value<atVec4f> transformMtx[3];
@ -132,7 +132,7 @@ struct MAPA : BigDNA
{ {
DECL_DNA DECL_DNA
Value<Type> type; Value<Type> type;
Value<atUint32> unknown1; Value<atUint32> visMode;
Value<atUint32> sclyId; Value<atUint32> sclyId;
Buffer<DNA_COUNT(0x10)> unknownHash; Buffer<DNA_COUNT(0x10)> unknownHash;
Value<atInt32> seek1 = -1; Value<atInt32> seek1 = -1;

View File

@ -18,12 +18,20 @@ struct ITweakAutoMapper : public ITweak
virtual float GetMiniCamDist() const=0; virtual float GetMiniCamDist() const=0;
virtual float GetMiniCamXAngle() const=0; virtual float GetMiniCamXAngle() const=0;
virtual float GetMiniCamAngle() const=0; virtual float GetMiniCamAngle() const=0;
virtual const zeus::CColor& GetSurfaceVisitedColor() const=0;
virtual const zeus::CColor& GetOutlineVisitedColor() const=0;
virtual const zeus::CColor& GetSurfaceUnvisitedColor() const=0;
virtual const zeus::CColor& GetOutlineUnvisitedColor() const=0;
virtual const zeus::CColor& GetSurfaceSelectVisitedColor() const=0;
virtual const zeus::CColor& GetOutlineSelectVisitedColor() const=0;
virtual float GetOpenMapScreenTime() const=0; virtual float GetOpenMapScreenTime() const=0;
virtual float GetCloseMapScreenTime() const=0; virtual float GetCloseMapScreenTime() const=0;
virtual float GetHintPanTime() const=0; virtual float GetHintPanTime() const=0;
virtual float GetCamZoomUnitsPerFrame() const=0; virtual float GetCamZoomUnitsPerFrame() const=0;
virtual float GetCamRotateDegreesPerFrame() const=0; virtual float GetCamRotateDegreesPerFrame() const=0;
virtual float GetBaseMapScreenCameraMoveSpeed() const=0; virtual float GetBaseMapScreenCameraMoveSpeed() const=0;
virtual const zeus::CColor& GetSurfaceSelectUnvisitedColor() const=0;
virtual const zeus::CColor& GetOutlineSelectUnvisitedColor() const=0;
virtual float GetMiniAlphaSurfaceVisited() const=0; virtual float GetMiniAlphaSurfaceVisited() const=0;
virtual float GetAlphaSurfaceVisited() const=0; virtual float GetAlphaSurfaceVisited() const=0;
virtual float GetMiniAlphaOutlineVisited() const=0; virtual float GetMiniAlphaOutlineVisited() const=0;
@ -45,6 +53,7 @@ struct ITweakAutoMapper : public ITweak
virtual float GetCamPanUnitsPerFrame() const=0; virtual float GetCamPanUnitsPerFrame() const=0;
virtual float GetCamVerticalOffset() const=0; virtual float GetCamVerticalOffset() const=0;
virtual const zeus::CColor& GetMiniMapSamusModColor() const=0; virtual const zeus::CColor& GetMiniMapSamusModColor() const=0;
virtual const zeus::CColor& GetAreaFlashPulseColor() const=0;
virtual const zeus::CColor& GetDoorColor(int idx) const=0; virtual const zeus::CColor& GetDoorColor(int idx) const=0;
virtual const zeus::CColor& GetOpenDoorColor() const=0; virtual const zeus::CColor& GetOpenDoorColor() const=0;
}; };

View File

@ -27,12 +27,12 @@ struct CTweakAutoMapper : public ITweakAutoMapper
Value<float> x30_miniCamAngle; Value<float> x30_miniCamAngle;
Value<float> x34_; Value<float> x34_;
DNAColor x38_; DNAColor x38_;
DNAColor x3c_; DNAColor x3c_surfColorVisited;
DNAColor x40_; DNAColor x40_outlineColorVisited;
DNAColor x44_; DNAColor x44_surfColorUnvisited;
DNAColor x48_; DNAColor x48_outlineColorUnvisited;
DNAColor x4c_; DNAColor x4c_surfaceSelectColorVisited;
DNAColor x50_; DNAColor x50_outlineSelectColorVisited;
Value<float> x54_; Value<float> x54_;
Value<float> x58_; Value<float> x58_;
Value<float> x5c_; Value<float> x5c_;
@ -43,8 +43,8 @@ struct CTweakAutoMapper : public ITweakAutoMapper
Value<float> x70_zoomUnitsPerFrame; Value<float> x70_zoomUnitsPerFrame;
Value<float> x74_rotateDegPerFrame; Value<float> x74_rotateDegPerFrame;
Value<float> x78_baseMapScreenCameraMoveSpeed; Value<float> x78_baseMapScreenCameraMoveSpeed;
DNAColor x7c_; DNAColor x7c_surfaceSelectColorUnvisited;
DNAColor x80_; DNAColor x80_outlineSelectColorUnvisited;
Value<float> x84_miniAlphaSurfaceVisited; Value<float> x84_miniAlphaSurfaceVisited;
Value<float> x88_alphaSurfaceVisited; Value<float> x88_alphaSurfaceVisited;
Value<float> x8c_miniAlphaOutlineVisited; Value<float> x8c_miniAlphaOutlineVisited;
@ -72,7 +72,7 @@ struct CTweakAutoMapper : public ITweakAutoMapper
Value<float> xe8_; Value<float> xe8_;
Value<float> xec_camVerticalOffset; Value<float> xec_camVerticalOffset;
DNAColor xf0_miniMapSamusModColor; DNAColor xf0_miniMapSamusModColor;
DNAColor xf4_; DNAColor xf4_areaFlashPulseColor;
DNAColor xf8_; DNAColor xf8_;
DNAColor xfc_; DNAColor xfc_;
Value<atUint32> x100_doorColorCount; Value<atUint32> x100_doorColorCount;
@ -93,12 +93,20 @@ struct CTweakAutoMapper : public ITweakAutoMapper
float GetMiniCamDist() const { return x28_miniCamDist; } float GetMiniCamDist() const { return x28_miniCamDist; }
float GetMiniCamXAngle() const { return x2c_miniCamXAngle; } float GetMiniCamXAngle() const { return x2c_miniCamXAngle; }
float GetMiniCamAngle() const { return x30_miniCamAngle; } float GetMiniCamAngle() const { return x30_miniCamAngle; }
const zeus::CColor& GetSurfaceVisitedColor() const { return x3c_surfColorVisited; }
const zeus::CColor& GetOutlineVisitedColor() const { return x40_outlineColorVisited; }
const zeus::CColor& GetSurfaceUnvisitedColor() const { return x44_surfColorUnvisited; }
const zeus::CColor& GetOutlineUnvisitedColor() const { return x48_outlineColorUnvisited; }
const zeus::CColor& GetSurfaceSelectVisitedColor() const { return x4c_surfaceSelectColorVisited; }
const zeus::CColor& GetOutlineSelectVisitedColor() const { return x50_outlineSelectColorVisited; }
float GetOpenMapScreenTime() const { return x64_openMapScreenTime; } float GetOpenMapScreenTime() const { return x64_openMapScreenTime; }
float GetCloseMapScreenTime() const { return x68_closeMapScreenTime; } float GetCloseMapScreenTime() const { return x68_closeMapScreenTime; }
float GetHintPanTime() const { return x6c_hintPanTime; } float GetHintPanTime() const { return x6c_hintPanTime; }
float GetCamZoomUnitsPerFrame() const { return x70_zoomUnitsPerFrame; } float GetCamZoomUnitsPerFrame() const { return x70_zoomUnitsPerFrame; }
float GetCamRotateDegreesPerFrame() const { return x74_rotateDegPerFrame; } float GetCamRotateDegreesPerFrame() const { return x74_rotateDegPerFrame; }
float GetBaseMapScreenCameraMoveSpeed() const { return x78_baseMapScreenCameraMoveSpeed; } float GetBaseMapScreenCameraMoveSpeed() const { return x78_baseMapScreenCameraMoveSpeed; }
const zeus::CColor& GetSurfaceSelectUnvisitedColor() const { return x7c_surfaceSelectColorUnvisited; }
const zeus::CColor& GetOutlineSelectUnvisitedColor() const { return x80_outlineSelectColorUnvisited; }
float GetMiniAlphaSurfaceVisited() const { return x84_miniAlphaSurfaceVisited; } float GetMiniAlphaSurfaceVisited() const { return x84_miniAlphaSurfaceVisited; }
float GetAlphaSurfaceVisited() const { return x88_alphaSurfaceVisited; } float GetAlphaSurfaceVisited() const { return x88_alphaSurfaceVisited; }
float GetMiniAlphaOutlineVisited() const { return x8c_miniAlphaOutlineVisited; } float GetMiniAlphaOutlineVisited() const { return x8c_miniAlphaOutlineVisited; }
@ -120,6 +128,7 @@ struct CTweakAutoMapper : public ITweakAutoMapper
float GetCamPanUnitsPerFrame() const { return xe0_camPanUnitsPerFrame; } float GetCamPanUnitsPerFrame() const { return xe0_camPanUnitsPerFrame; }
float GetCamVerticalOffset() const { return xec_camVerticalOffset; } float GetCamVerticalOffset() const { return xec_camVerticalOffset; }
const zeus::CColor& GetMiniMapSamusModColor() const { return xf0_miniMapSamusModColor; } const zeus::CColor& GetMiniMapSamusModColor() const { return xf0_miniMapSamusModColor; }
const zeus::CColor& GetAreaFlashPulseColor() const { return xf4_areaFlashPulseColor; }
const zeus::CColor& GetDoorColor(int idx) const { return x104_doorColors[idx]; } const zeus::CColor& GetDoorColor(int idx) const { return x104_doorColors[idx]; }
const zeus::CColor& GetOpenDoorColor() const { return x11c_openDoorColor; } const zeus::CColor& GetOpenDoorColor() const { return x11c_openDoorColor; }
}; };

View File

@ -1182,7 +1182,7 @@ void CAutoMapper::Update(float dt, const CStateManager& mgr)
if (x1bc_state != EAutoMapperState::MiniMap && x1c0_nextState != EAutoMapperState::MiniMap) if (x1bc_state != EAutoMapperState::MiniMap && x1c0_nextState != EAutoMapperState::MiniMap)
{ {
x1d8_flashTimer = std::fmod(x1d8_flashTimer + dt, 0.75f); x1d8_flashTimer = std::fmod(x1d8_flashTimer + dt, 0.75f);
x1dc_flashPulse = x1d8_flashTimer < 0.375f ? x1d8_flashTimer / 0.375f : (0.75f - x1d8_flashTimer) / 0.375f; x1dc_playerFlashPulse = x1d8_flashTimer < 0.375f ? x1d8_flashTimer / 0.375f : (0.75f - x1d8_flashTimer) / 0.375f;
} }
if (!m_frmeInitialized && x28_frmeMapScreen.IsLoaded()) if (!m_frmeInitialized && x28_frmeMapScreen.IsLoaded())
@ -1476,13 +1476,13 @@ void CAutoMapper::Draw(const CStateManager& mgr, const zeus::CTransform& xf, flo
{ {
const CMapWorldInfo& mwInfo = *g_GameState->StateForWorld(x24_world->IGetWorldAssetId()).MapWorldInfo(); const CMapWorldInfo& mwInfo = *g_GameState->StateForWorld(x24_world->IGetWorldAssetId()).MapWorldInfo();
const CMapWorld* mw = x24_world->IGetMapWorld(); const CMapWorld* mw = x24_world->IGetMapWorld();
float flashIntensity = 0.f; float hintFlash = 0.f;
if (x1e0_hintSteps.size() && x1e0_hintSteps.front().x0_type == SAutoMapperHintStep::Type::ShowBeacon) if (x1e0_hintSteps.size() && x1e0_hintSteps.front().x0_type == SAutoMapperHintStep::Type::ShowBeacon)
{ {
if (xa0_curAreaId == mgr.GetNextAreaId() && x24_world == mgr.GetWorld()) if (xa0_curAreaId == mgr.GetNextAreaId() && x24_world == mgr.GetWorld())
{ {
float pulseTime = std::fmod(x1e0_hintSteps.front().x4_float * 8.f, 1.f); float pulseTime = std::fmod(x1e0_hintSteps.front().x4_float * 8.f, 1.f);
flashIntensity = 2.f * (pulseTime < 0.5f ? pulseTime : 1.f - pulseTime); hintFlash = 2.f * (pulseTime < 0.5f ? pulseTime : 1.f - pulseTime);
} }
else else
{ {
@ -1493,7 +1493,7 @@ void CAutoMapper::Draw(const CStateManager& mgr, const zeus::CTransform& xf, flo
if (xa0_curAreaId != loc.xc_areaId) if (xa0_curAreaId != loc.xc_areaId)
continue; continue;
float pulseTime = std::fmod((1.f - std::max(0.f, (x1e0_hintSteps.front().x4_float - 0.5f) / 0.5f)) * 4.f, 1.f); float pulseTime = std::fmod((1.f - std::max(0.f, (x1e0_hintSteps.front().x4_float - 0.5f) / 0.5f)) * 4.f, 1.f);
flashIntensity = 2.f * (pulseTime < 0.5f ? pulseTime : 1.f - pulseTime); hintFlash = 2.f * (pulseTime < 0.5f ? pulseTime : 1.f - pulseTime);
break; break;
} }
} }
@ -1504,7 +1504,7 @@ void CAutoMapper::Draw(const CStateManager& mgr, const zeus::CTransform& xf, flo
xa8_renderStates[0].x3c_alphaSurfaceUnvisited * alphaInterp, xa8_renderStates[0].x3c_alphaSurfaceUnvisited * alphaInterp,
xa8_renderStates[0].x40_alphaOutlineUnvisited * alphaInterp, xa8_renderStates[0].x40_alphaOutlineUnvisited * alphaInterp,
mapAlpha, 2.f, mgr, planeXf * preXf, camXf, *x24_world, mapAlpha, 2.f, mgr, planeXf * preXf, camXf, *x24_world,
mwInfo, x1dc_flashPulse, flashIntensity, objectScale, true); mwInfo, x1dc_playerFlashPulse, hintFlash, objectScale, true);
mw->Draw(parms, xa0_curAreaId, xa0_curAreaId, mw->Draw(parms, xa0_curAreaId, xa0_curAreaId,
xa8_renderStates[0].x2c_drawDepth1, xa8_renderStates[0].x2c_drawDepth1,
xa8_renderStates[0].x30_drawDepth2, true); xa8_renderStates[0].x30_drawDepth2, true);
@ -1561,7 +1561,7 @@ void CAutoMapper::Draw(const CStateManager& mgr, const zeus::CTransform& xf, flo
} }
CMapUniverse::CMapUniverseDrawParms parms(universeInterp, x9c_worldIdx, g_GameState->CurrentWorldAssetId(), CMapUniverse::CMapUniverseDrawParms parms(universeInterp, x9c_worldIdx, g_GameState->CurrentWorldAssetId(),
hexIdx, x1dc_flashPulse, mgr, planeXf, camXf); hexIdx, x1dc_playerFlashPulse, mgr, planeXf, camXf);
x8_mapu->Draw(parms, zeus::CVector3f::skZero, 0.f, 0.f); x8_mapu->Draw(parms, zeus::CVector3f::skZero, 0.f, 0.f);
} }

View File

@ -191,7 +191,7 @@ private:
CSfxHandle x1d0_rotatingSfx; CSfxHandle x1d0_rotatingSfx;
CSfxHandle x1d4_zoomingSfx; CSfxHandle x1d4_zoomingSfx;
float x1d8_flashTimer = 0.f; float x1d8_flashTimer = 0.f;
float x1dc_flashPulse = 0.f; float x1dc_playerFlashPulse = 0.f;
std::list<SAutoMapperHintStep> x1e0_hintSteps; std::list<SAutoMapperHintStep> x1e0_hintSteps;
std::list<SAutoMapperHintLocation> x1f8_hintLocations; std::list<SAutoMapperHintLocation> x1f8_hintLocations;
rstl::reserved_vector<TLockedToken<CTexture>, 9> x210_lstick; rstl::reserved_vector<TLockedToken<CTexture>, 9> x210_lstick;

View File

@ -267,7 +267,11 @@ void CMapArea::CMapAreaSurface::Draw(const zeus::CVector3f* verts, const zeus::C
std::vector<CLineRenderer>& linePrims = const_cast<std::vector<CLineRenderer>&>(m_linePrims); std::vector<CLineRenderer>& linePrims = const_cast<std::vector<CLineRenderer>&>(m_linePrims);
if (linePrims.size() < totalPrims) if (linePrims.size() < totalPrims)
{ {
linePrims.clear();
linePrims.reserve(totalPrims); linePrims.reserve(totalPrims);
const_cast<CMapAreaSurface*>(this)->m_lineToken =
CGraphics::CommitResources([&](boo::IGraphicsDataFactory::Context& ctx)
{
for (u32 j=0 ; j<=draw2 ; ++j) for (u32 j=0 ; j<=draw2 ; ++j)
{ {
r.seek(4, athena::SeekOrigin::Begin); r.seek(4, athena::SeekOrigin::Begin);
@ -276,9 +280,11 @@ void CMapArea::CMapAreaSurface::Draw(const zeus::CVector3f* verts, const zeus::C
u32 count = r.readUint32Big(); u32 count = r.readUint32Big();
r.seek(count); r.seek(count);
r.seekAlign4(); r.seekAlign4();
linePrims.emplace_back(CLineRenderer::EPrimitiveMode::LineStrip, count, nullptr, false); linePrims.emplace_back(ctx, CLineRenderer::EPrimitiveMode::LineStrip, count, nullptr, false);
} }
} }
return true;
});
} }
zeus::CColor color = lineColor; zeus::CColor color = lineColor;

View File

@ -27,6 +27,7 @@ public:
u32 m_primCount; u32 m_primCount;
std::experimental::optional<CMapSurfaceShader> m_surfacePrims; std::experimental::optional<CMapSurfaceShader> m_surfacePrims;
std::vector<CLineRenderer> m_linePrims; std::vector<CLineRenderer> m_linePrims;
boo::GraphicsDataToken m_lineToken;
public: public:
CMapAreaSurface(const void* surfBuf); CMapAreaSurface(const void* surfBuf);
CMapAreaSurface(CMapAreaSurface&&) = default; CMapAreaSurface(CMapAreaSurface&&) = default;

View File

@ -3,6 +3,7 @@
#include "GameGlobalObjects.hpp" #include "GameGlobalObjects.hpp"
#include "CSimplePool.hpp" #include "CSimplePool.hpp"
#include "World/CWorld.hpp" #include "World/CWorld.hpp"
#include "CStateManager.hpp"
namespace urde namespace urde
{ {
@ -215,10 +216,148 @@ bool CMapWorld::IsMapAreaValid(const IWorld& wld, int areaIdx, bool checkLoad) c
return true; return true;
} }
void CMapWorld::DrawAreas(const CMapWorld::CMapWorldDrawParms&, int, void CMapWorld::DrawAreas(const CMapWorld::CMapWorldDrawParms& parms, int selArea,
const std::vector<CMapWorld::CMapAreaBFSInfo>&, bool) const const std::vector<CMapAreaBFSInfo>& bfsInfos, bool inMapScreen) const
{ {
// Alpha blend
// Line width 1
int surfCount = 0;
int objCount = 0;
for (const CMapAreaBFSInfo& bfsInfo : bfsInfos)
{
const CMapArea* mapa = GetMapArea(bfsInfo.GetAreaIndex());
surfCount += mapa->GetNumSurfaces();
objCount += mapa->GetNumMappableObjects();
}
std::vector<CMapObjectSortInfo> sortInfos;
sortInfos.reserve(surfCount + objCount + (parms.GetIsSortDoorSurfaces() ? objCount * 6 : 0));
int playerArea = parms.GetStateManager().GetNextAreaId();
const CMapWorldInfo& mwInfo = parms.GetMapWorldInfo();
for (const CMapAreaBFSInfo& bfsInfo : bfsInfos)
{
int thisArea = bfsInfo.GetAreaIndex();
const CMapArea* mapa = GetMapArea(thisArea);
if (!mapa->GetIsVisibleToAutoMapper(mwInfo.IsWorldVisible(thisArea), mwInfo.IsAreaVisible(thisArea)))
continue;
float surfDepth = bfsInfo.GetSurfaceDrawDepth();
float outlineDepth = bfsInfo.GetOutlineDrawDepth();
if (surfDepth >= 1.f)
surfDepth = 1.f;
else if (surfDepth < 0.f)
surfDepth = 0.f;
else
surfDepth -= std::floor(surfDepth);
if (outlineDepth >= 1.f)
outlineDepth = 1.f;
else if (outlineDepth < 0.f)
outlineDepth = 0.f;
else
outlineDepth -= std::floor(outlineDepth);
float alphaSurf;
float alphaOutline;
const zeus::CColor* surfaceColor;
const zeus::CColor* outlineColor;
const zeus::CColor* surfacePlayerColor;
const zeus::CColor* outlinePlayerColor;
if (mwInfo.IsAreaVisted(thisArea))
{
alphaSurf = parms.GetAlphaSurfaceVisited();
alphaOutline = parms.GetAlphaOutlineVisited();
surfaceColor = &g_tweakAutoMapper->GetSurfaceVisitedColor();
outlineColor = &g_tweakAutoMapper->GetOutlineVisitedColor();
surfacePlayerColor = &g_tweakAutoMapper->GetSurfaceSelectVisitedColor();
outlinePlayerColor = &g_tweakAutoMapper->GetOutlineSelectVisitedColor();
}
else
{
alphaSurf = parms.GetAlphaSurfaceUnvisited();
alphaOutline = parms.GetAlphaOutlineUnvisited();
surfaceColor = &g_tweakAutoMapper->GetSurfaceUnvisitedColor();
outlineColor = &g_tweakAutoMapper->GetOutlineUnvisitedColor();
surfacePlayerColor = &g_tweakAutoMapper->GetSurfaceSelectUnvisitedColor();
outlinePlayerColor = &g_tweakAutoMapper->GetOutlineSelectUnvisitedColor();
}
zeus::CColor hintFlashColor =
zeus::CColor::lerp(zeus::CColor::skClear, zeus::CColor{1.f, 1.f, 1.f, 0.f}, parms.GetHintAreaFlashIntensity());
zeus::CColor finalSurfColor, finalOutlineColor;
if (thisArea == selArea && inMapScreen)
{
finalSurfColor = *surfacePlayerColor + hintFlashColor;
finalOutlineColor = *outlinePlayerColor + hintFlashColor;
}
else
{
finalSurfColor = *surfaceColor;
finalSurfColor.a = surfDepth * alphaSurf;
finalOutlineColor = *outlineColor;
finalOutlineColor.a = outlineDepth * alphaOutline;
}
if ((selArea != playerArea || parms.GetHintAreaFlashIntensity() == 0.f) &&
playerArea == thisArea && this == parms.GetStateManager().GetWorld()->GetMapWorld())
{
float pulse = parms.GetPlayerAreaFlashIntensity();
const zeus::CColor& flashCol = g_tweakAutoMapper->GetAreaFlashPulseColor();
finalSurfColor = zeus::CColor::lerp(finalSurfColor, flashCol, pulse);
finalOutlineColor = zeus::CColor::lerp(finalOutlineColor, flashCol, pulse);
}
zeus::CTransform modelView = parms.GetCameraTransform().inverse() *
mapa->GetAreaPostTransform(parms.GetWorld(), thisArea);
for (int i=0 ; i<mapa->GetNumSurfaces() ; ++i)
{
const CMapArea::CMapAreaSurface& surf = mapa->GetSurface(i);
zeus::CVector3f pos = modelView * surf.GetCenterPosition();
sortInfos.emplace_back(pos.y, thisArea, CMapObjectSortInfo::EObjectCode::Surface, i,
finalSurfColor, finalOutlineColor);
}
int i = 0;
int si = 0;
for (; i<mapa->GetNumMappableObjects() ; ++i, si+=6)
{
const CMappableObject& obj = mapa->GetMappableObject(i);
if (!obj.IsVisibleToAutoMapper(mwInfo.IsWorldVisible(thisArea), mwInfo))
continue;
bool doorType = CMappableObject::IsDoorType(obj.GetType());
if (doorType)
{
if (!mwInfo.IsAreaVisible(thisArea))
continue;
if (parms.GetIsSortDoorSurfaces())
{
for (int s=0 ; s<6 ; ++s)
{
zeus::CVector3f center = obj.BuildSurfaceCenterPoint(s);
zeus::CVector3f pos = modelView * (CMapArea::GetAreaPostTranslate(parms.GetWorld(), thisArea) + center);
sortInfos.emplace_back(pos.y, thisArea, CMapObjectSortInfo::EObjectCode::DoorSurface, si+s,
zeus::CColor{1.f, 0.f, 1.f, 1.f}, zeus::CColor{1.f, 0.f, 1.f, 1.f});
}
continue;
}
}
zeus::CVector3f pos = modelView * (obj.GetTransform().origin + CMapArea::GetAreaPostTranslate(parms.GetWorld(), thisArea));
sortInfos.emplace_back(pos.y, thisArea, doorType ? CMapObjectSortInfo::EObjectCode::Door :
CMapObjectSortInfo::EObjectCode::Object,
i, zeus::CColor{1.f, 0.f, 1.f, 1.f}, zeus::CColor{1.f, 0.f, 1.f, 1.f});
}
}
if (sortInfos.empty())
return;
/* TODO: Finish */
} }
struct Support struct Support

View File

@ -49,10 +49,10 @@ public:
public: public:
enum class EObjectCode enum class EObjectCode
{ {
One = 1 << 16, Object = 1 << 16,
Door = 2 << 16, DoorSurface = 2 << 16,
Three = 3 << 16, Door = 3 << 16,
Four = 4 << 16 Surface = 4 << 16
}; };
CMapObjectSortInfo(float zDist, int areaIdx, EObjectCode type, int idx, CMapObjectSortInfo(float zDist, int areaIdx, EObjectCode type, int idx,
@ -98,8 +98,8 @@ public:
const zeus::CTransform& x20_viewXf; const zeus::CTransform& x20_viewXf;
const IWorld& x24_wld; const IWorld& x24_wld;
const CMapWorldInfo& x28_mwInfo; const CMapWorldInfo& x28_mwInfo;
float x2c_flashPulse; float x2c_playerFlashIntensity;
float x30_flashIntensity; float x30_hintFlashIntensity;
float x34_objectScale; float x34_objectScale;
bool x38_sortDoorSurfs; bool x38_sortDoorSurfs;
public: public:
@ -107,8 +107,8 @@ public:
float alphaSurfUnvisited, float alphaOlUnvisited, float alphaSurfUnvisited, float alphaOlUnvisited,
float alpha, float outlineWidthScale, const CStateManager& mgr, float alpha, float outlineWidthScale, const CStateManager& mgr,
const zeus::CTransform& modelXf, const zeus::CTransform& viewXf, const zeus::CTransform& modelXf, const zeus::CTransform& viewXf,
const IWorld& wld, const CMapWorldInfo& mwInfo, float flashPulse, const IWorld& wld, const CMapWorldInfo& mwInfo, float playerFlash,
float flashIntensity, float objectScale, bool sortDoorSurfs) float hintFlash, float objectScale, bool sortDoorSurfs)
: x0_alphaSurfVisited(alphaSurfVisited), : x0_alphaSurfVisited(alphaSurfVisited),
x4_alphaOlVisited(alphaOlVisited), x4_alphaOlVisited(alphaOlVisited),
x8_alphaSurfUnvisited(alphaSurfUnvisited), x8_alphaSurfUnvisited(alphaSurfUnvisited),
@ -120,16 +120,16 @@ public:
x20_viewXf(viewXf), x20_viewXf(viewXf),
x24_wld(wld), x24_wld(wld),
x28_mwInfo(mwInfo), x28_mwInfo(mwInfo),
x2c_flashPulse(flashPulse), x2c_playerFlashIntensity(playerFlash),
x30_flashIntensity(flashIntensity), x30_hintFlashIntensity(hintFlash),
x34_objectScale(objectScale), x34_objectScale(objectScale),
x38_sortDoorSurfs(sortDoorSurfs) x38_sortDoorSurfs(sortDoorSurfs)
{} {}
const IWorld& GetWorld() const { return x24_wld; } const IWorld& GetWorld() const { return x24_wld; }
float GetOutlineWidthScale() const { return x14_outlineWidthScale; } float GetOutlineWidthScale() const { return x14_outlineWidthScale; }
const zeus::CTransform& GetPlaneProjectionTransform() const { return x1c_modelXf; } const zeus::CTransform& GetPlaneProjectionTransform() const { return x1c_modelXf; }
float GetPlayerAreaFlashIntensity() const { return x30_flashIntensity; } float GetHintAreaFlashIntensity() const { return x30_hintFlashIntensity; }
float GetPlayerAreaFlashPulse() const { return x2c_flashPulse; } float GetPlayerAreaFlashIntensity() const { return x2c_playerFlashIntensity; }
const zeus::CTransform& GetCameraTransform() const { return x20_viewXf; } const zeus::CTransform& GetCameraTransform() const { return x20_viewXf; }
float GetAlphaOutlineUnvisited() const { return xc_alphaOlUnvisited; } float GetAlphaOutlineUnvisited() const { return xc_alphaOlUnvisited; }
float GetAlphaSurfaceUnvisited() const { return x8_alphaSurfUnvisited; } float GetAlphaSurfaceUnvisited() const { return x8_alphaSurfUnvisited; }

View File

@ -23,7 +23,7 @@ CMappableObject::CMappableObject(const void* buf)
{ {
athena::io::MemoryReader r(buf, 64); athena::io::MemoryReader r(buf, 64);
x0_type = EMappableObjectType(r.readUint32Big()); x0_type = EMappableObjectType(r.readUint32Big());
x4_ = r.readUint32Big(); x4_visibilityMode = EVisMode(r.readUint32Big());
x8_objId = r.readUint32Big(); x8_objId = r.readUint32Big();
xc_ = r.readUint32Big(); xc_ = r.readUint32Big();
x10_transform.read34RowMajor(r); x10_transform.read34RowMajor(r);
@ -258,6 +258,26 @@ zeus::CVector3f CMappableObject::BuildSurfaceCenterPoint(int surfIdx) const
return {}; return {};
} }
bool CMappableObject::IsVisibleToAutoMapper(bool worldVis, const CMapWorldInfo& mwInfo) const
{
bool areaVis = mwInfo.IsAreaVisible(x8_objId.AreaNum());
switch (x4_visibilityMode)
{
case EVisMode::Always:
default:
return true;
case EVisMode::MapStationOrVisit:
case EVisMode::MapStationOrVisit2:
return worldVis || areaVis;
case EVisMode::Visit:
if (IsDoorType(x0_type))
return mwInfo.IsDoorVisited(x8_objId);
return areaVis;
case EVisMode::Never:
return false;
}
}
boo::GraphicsDataToken CMappableObject::g_gfxToken = {}; boo::GraphicsDataToken CMappableObject::g_gfxToken = {};
boo::IGraphicsBufferS* CMappableObject::g_doorVbo; boo::IGraphicsBufferS* CMappableObject::g_doorVbo;
boo::IGraphicsBufferS* CMappableObject::g_doorIbo; boo::IGraphicsBufferS* CMappableObject::g_doorIbo;

View File

@ -51,11 +51,20 @@ public:
MissileStation = 37 MissileStation = 37
}; };
enum class EVisMode
{
Always,
MapStationOrVisit,
Visit,
Never,
MapStationOrVisit2
};
private: private:
static const zeus::CVector3f skDoorVerts[8]; static const zeus::CVector3f skDoorVerts[8];
EMappableObjectType x0_type; EMappableObjectType x0_type;
u32 x4_; EVisMode x4_visibilityMode;
TEditorId x8_objId; TEditorId x8_objId;
u32 xc_; u32 xc_;
zeus::CTransform x10_transform; zeus::CTransform x10_transform;
@ -86,7 +95,7 @@ public:
zeus::CVector3f BuildSurfaceCenterPoint(int surfIdx) const; zeus::CVector3f BuildSurfaceCenterPoint(int surfIdx) const;
bool IsDoorConnectedToArea(int idx, const CStateManager&) const; bool IsDoorConnectedToArea(int idx, const CStateManager&) const;
bool IsDoorConnectedToVisitedArea(const CStateManager&) const; bool IsDoorConnectedToVisitedArea(const CStateManager&) const;
bool GetIsVisibleToAutoMapper(bool) const; bool IsVisibleToAutoMapper(bool worldVis, const CMapWorldInfo& mwInfo) const;
bool GetIsSeen() const; bool GetIsSeen() const;
static void ReadAutoMapperTweaks(const ITweakAutoMapper&); static void ReadAutoMapperTweaks(const ITweakAutoMapper&);

View File

@ -4,6 +4,7 @@
#include "CTimeProvider.hpp" #include "CTimeProvider.hpp"
#include "Shaders/CTextSupportShader.hpp" #include "Shaders/CTextSupportShader.hpp"
#include "GuiSys/CGuiSys.hpp" #include "GuiSys/CGuiSys.hpp"
#include "CLineRenderer.hpp"
namespace urde namespace urde
{ {
@ -108,7 +109,7 @@ void CGraphics::EndScene()
/* GXCopyDisp to g_CurrenFrameBuf with clear enabled */ /* GXCopyDisp to g_CurrenFrameBuf with clear enabled */
/* Register next breakpoint with GP FIFO */ /* Register next breakpoint with GP FIFO */
/* Yup, GX had fences long before D3D12 and Vulkan /* Yup, GX effectively had fences long before D3D12 and Vulkan
* (same functionality implemented in boo's execute method) */ * (same functionality implemented in boo's execute method) */
/* This usually comes from VI register during interrupt; /* This usually comes from VI register during interrupt;
@ -120,6 +121,9 @@ void CGraphics::EndScene()
/* Flush text instance buffers just before GPU command list submission */ /* Flush text instance buffers just before GPU command list submission */
CTextSupportShader::UpdateBuffers(); CTextSupportShader::UpdateBuffers();
/* Same with line renderer */
CLineRenderer::UpdateBuffers();
++g_FrameCounter; ++g_FrameCounter;
} }

View File

@ -13,25 +13,14 @@ void CLineRenderer::Initialize()
void CLineRenderer::Shutdown() void CLineRenderer::Shutdown()
{ {
CLineRendererShaders::Shutdown(); CLineRendererShaders::Shutdown();
s_vertPoolTex.doDestroy();
s_vertPoolNoTex.doDestroy();
s_uniformPool.doDestroy();
} }
struct SDrawVertTex hecl::VertexBufferPool<CLineRenderer::SDrawVertTex> CLineRenderer::s_vertPoolTex = {};
{ hecl::VertexBufferPool<CLineRenderer::SDrawVertNoTex> CLineRenderer::s_vertPoolNoTex = {};
zeus::CVector4f pos; hecl::UniformBufferPool<CLineRenderer::SDrawUniform> CLineRenderer::s_uniformPool = {};
zeus::CColor color;
zeus::CVector2f uv;
};
struct SDrawVertNoTex
{
zeus::CVector4f pos;
zeus::CColor color;
};
struct SDrawUniform
{
zeus::CColor moduColor;
};
CLineRenderer::CLineRenderer(boo::IGraphicsDataFactory::Context& ctx, CLineRenderer::CLineRenderer(boo::IGraphicsDataFactory::Context& ctx,
EPrimitiveMode mode, u32 maxVerts, boo::ITexture* texture, bool additive) EPrimitiveMode mode, u32 maxVerts, boo::ITexture* texture, bool additive)
@ -58,10 +47,13 @@ CLineRenderer::CLineRenderer(boo::IGraphicsDataFactory::Context& ctx,
break; break;
} }
m_vertBuf = ctx.newDynamicBuffer(boo::BufferUse::Vertex, if (texture)
texture ? sizeof(SDrawVertTex) : sizeof(SDrawVertNoTex), m_vertBufTex = s_vertPoolTex.allocateBlock(CGraphics::g_BooFactory, maxTriVerts);
maxTriVerts); else
m_uniformBuf = ctx.newDynamicBuffer(boo::BufferUse::Uniform, sizeof(SDrawUniform), 1); m_vertBufNoTex = s_vertPoolNoTex.allocateBlock(CGraphics::g_BooFactory, maxTriVerts);
m_uniformBuf = s_uniformPool.allocateBlock(CGraphics::g_BooFactory);
CLineRendererShaders::BuildShaderDataBinding(ctx, *this, texture, additive); CLineRendererShaders::BuildShaderDataBinding(ctx, *this, texture, additive);
} }
@ -89,19 +81,22 @@ CLineRenderer::CLineRenderer(EPrimitiveMode mode, u32 maxVerts, boo::ITexture* t
break; break;
} }
if (texture)
m_vertBufTex = s_vertPoolTex.allocateBlock(CGraphics::g_BooFactory, maxTriVerts);
else
m_vertBufNoTex = s_vertPoolNoTex.allocateBlock(CGraphics::g_BooFactory, maxTriVerts);
m_uniformBuf = s_uniformPool.allocateBlock(CGraphics::g_BooFactory);
m_gfxToken = CGraphics::CommitResources([&](boo::IGraphicsDataFactory::Context& ctx) -> bool m_gfxToken = CGraphics::CommitResources([&](boo::IGraphicsDataFactory::Context& ctx) -> bool
{ {
m_vertBuf = ctx.newDynamicBuffer(boo::BufferUse::Vertex,
texture ? sizeof(SDrawVertTex) : sizeof(SDrawVertNoTex),
maxTriVerts);
m_uniformBuf = ctx.newDynamicBuffer(boo::BufferUse::Uniform, sizeof(SDrawUniform), 1);
CLineRendererShaders::BuildShaderDataBinding(ctx, *this, texture, additive); CLineRendererShaders::BuildShaderDataBinding(ctx, *this, texture, additive);
return true; return true;
}); });
} }
static rstl::reserved_vector<SDrawVertTex, 256> g_StaticLineVertsTex; rstl::reserved_vector<CLineRenderer::SDrawVertTex, 256> CLineRenderer::g_StaticLineVertsTex = {};
static rstl::reserved_vector<SDrawVertNoTex, 256> g_StaticLineVertsNoTex; rstl::reserved_vector<CLineRenderer::SDrawVertNoTex, 256> CLineRenderer::g_StaticLineVertsNoTex = {};
static zeus::CVector2f IntersectLines(const zeus::CVector2f& pa1, const zeus::CVector2f& pa2, static zeus::CVector2f IntersectLines(const zeus::CVector2f& pa1, const zeus::CVector2f& pa2,
const zeus::CVector2f& pb1, const zeus::CVector2f& pb2) const zeus::CVector2f& pb1, const zeus::CVector2f& pb2)
@ -357,17 +352,16 @@ void CLineRenderer::Render(const zeus::CColor& moduColor)
m_final = true; m_final = true;
} }
SDrawUniform uniformData = {moduColor}; m_uniformBuf.access() = SDrawUniform{moduColor};
m_uniformBuf->load(&uniformData, sizeof(SDrawUniform));
if (m_textured) if (m_textured)
{ {
m_vertBuf->load(g_StaticLineVertsTex.data(), sizeof(SDrawVertTex) * g_StaticLineVertsTex.size()); memmove(m_vertBufTex.access(), g_StaticLineVertsTex.data(), sizeof(SDrawVertTex) * g_StaticLineVertsTex.size());
CGraphics::SetShaderDataBinding(m_shaderBind); CGraphics::SetShaderDataBinding(m_shaderBind);
CGraphics::DrawArray(0, g_StaticLineVertsTex.size()); CGraphics::DrawArray(0, g_StaticLineVertsTex.size());
} }
else else
{ {
m_vertBuf->load(g_StaticLineVertsNoTex.data(), sizeof(SDrawVertNoTex) * g_StaticLineVertsNoTex.size()); memmove(m_vertBufNoTex.access(), g_StaticLineVertsNoTex.data(), sizeof(SDrawVertNoTex) * g_StaticLineVertsNoTex.size());
CGraphics::SetShaderDataBinding(m_shaderBind); CGraphics::SetShaderDataBinding(m_shaderBind);
CGraphics::DrawArray(0, g_StaticLineVertsNoTex.size()); CGraphics::DrawArray(0, g_StaticLineVertsNoTex.size());
} }

View File

@ -3,8 +3,11 @@
#include "RetroTypes.hpp" #include "RetroTypes.hpp"
#include "zeus/CVector3f.hpp" #include "zeus/CVector3f.hpp"
#include "zeus/CVector4f.hpp"
#include "zeus/CColor.hpp" #include "zeus/CColor.hpp"
#include "boo/graphicsdev/IGraphicsDataFactory.hpp" #include "boo/graphicsdev/IGraphicsDataFactory.hpp"
#include "hecl/VertexBufferPool.hpp"
#include "hecl/UniformBufferPool.hpp"
namespace urde namespace urde
{ {
@ -19,6 +22,24 @@ public:
LineLoop LineLoop
}; };
struct SDrawVertTex
{
zeus::CVector4f pos;
zeus::CColor color;
zeus::CVector2f uv;
};
struct SDrawVertNoTex
{
zeus::CVector4f pos;
zeus::CColor color;
};
struct SDrawUniform
{
zeus::CColor moduColor;
};
private: private:
EPrimitiveMode m_mode; EPrimitiveMode m_mode;
u32 m_maxVerts; u32 m_maxVerts;
@ -38,10 +59,18 @@ private:
zeus::CColor m_lastColor; zeus::CColor m_lastColor;
float m_lastWidth; float m_lastWidth;
static rstl::reserved_vector<SDrawVertTex, 256> g_StaticLineVertsTex;
static rstl::reserved_vector<SDrawVertNoTex, 256> g_StaticLineVertsNoTex;
static hecl::VertexBufferPool<SDrawVertTex> s_vertPoolTex;
static hecl::VertexBufferPool<SDrawVertNoTex> s_vertPoolNoTex;
static hecl::UniformBufferPool<SDrawUniform> s_uniformPool;
public: public:
boo::GraphicsDataToken m_gfxToken; boo::GraphicsDataToken m_gfxToken;
boo::IGraphicsBufferD* m_vertBuf; hecl::VertexBufferPool<SDrawVertTex>::Token m_vertBufTex;
boo::IGraphicsBufferD* m_uniformBuf; hecl::VertexBufferPool<SDrawVertNoTex>::Token m_vertBufNoTex;
hecl::UniformBufferPool<SDrawUniform>::Token m_uniformBuf;
boo::IShaderDataBinding* m_shaderBind = nullptr; boo::IShaderDataBinding* m_shaderBind = nullptr;
CLineRenderer(boo::IGraphicsDataFactory::Context& ctx, CLineRenderer(boo::IGraphicsDataFactory::Context& ctx,
@ -54,6 +83,13 @@ public:
const zeus::CVector2f& uv=zeus::CVector2f::skZero); const zeus::CVector2f& uv=zeus::CVector2f::skZero);
void Render(const zeus::CColor& moduColor=zeus::CColor::skWhite); void Render(const zeus::CColor& moduColor=zeus::CColor::skWhite);
static void UpdateBuffers()
{
s_vertPoolTex.updateBuffers();
s_vertPoolNoTex.updateBuffers();
s_uniformPool.updateBuffers();
}
static void Initialize(); static void Initialize();
static void Shutdown(); static void Shutdown();
}; };

View File

@ -1,5 +1,6 @@
#include "CLineRendererShaders.hpp" #include "CLineRendererShaders.hpp"
#include "Graphics/CLineRenderer.hpp" #include "Graphics/CLineRenderer.hpp"
#include "hecl/VertexBufferPool.hpp"
namespace urde namespace urde
{ {
@ -94,33 +95,42 @@ struct OGLLineDataBindingFactory : CLineRendererShaders::IDataBindingFactory
int texCount = 0; int texCount = 0;
boo::ITexture* textures[1]; boo::ITexture* textures[1];
std::pair<boo::IGraphicsBufferD*, hecl::VertexBufferPool<CLineRenderer::SDrawVertTex>::IndexTp> vbufInfo;
std::pair<boo::IGraphicsBufferD*, hecl::UniformBufferPool<CLineRenderer::SDrawUniform>::IndexTp> ubufInfo =
renderer.m_uniformBuf.getBufferInfo();
if (texture) if (texture)
{ {
vbufInfo = renderer.m_vertBufTex.getBufferInfo();
textures[0] = texture; textures[0] = texture;
texCount = 1; texCount = 1;
const boo::VertexElementDescriptor TexFmtTex[] = const boo::VertexElementDescriptor TexFmtTex[] =
{ {
{renderer.m_vertBuf, nullptr, boo::VertexSemantic::Position4}, {vbufInfo.first, nullptr, boo::VertexSemantic::Position4},
{renderer.m_vertBuf, nullptr, boo::VertexSemantic::Color}, {vbufInfo.first, nullptr, boo::VertexSemantic::Color},
{renderer.m_vertBuf, nullptr, boo::VertexSemantic::UV4} {vbufInfo.first, nullptr, boo::VertexSemantic::UV4}
}; };
vtxFmt = ctx.newVertexFormat(3, TexFmtTex); vtxFmt = ctx.newVertexFormat(3, TexFmtTex);
} }
else else
{ {
vbufInfo = renderer.m_vertBufNoTex.getBufferInfo();
const boo::VertexElementDescriptor TexFmtNoTex[] = const boo::VertexElementDescriptor TexFmtNoTex[] =
{ {
{renderer.m_vertBuf, nullptr, boo::VertexSemantic::Position4}, {vbufInfo.first, nullptr, boo::VertexSemantic::Position4},
{renderer.m_vertBuf, nullptr, boo::VertexSemantic::Color} {vbufInfo.first, nullptr, boo::VertexSemantic::Color}
}; };
vtxFmt = ctx.newVertexFormat(2, TexFmtNoTex); vtxFmt = ctx.newVertexFormat(2, TexFmtNoTex);
} }
boo::IGraphicsBuffer* uniforms[] = {renderer.m_uniformBuf}; boo::IGraphicsBuffer* uniforms[] = {ubufInfo.first};
boo::PipelineStage stages[] = {boo::PipelineStage::Vertex};
size_t ubufOffs[] = {ubufInfo.second};
size_t ubufSizes[] = {sizeof(CLineRenderer::SDrawUniform)};
renderer.m_shaderBind = ctx.newShaderDataBinding(pipeline, vtxFmt, renderer.m_vertBuf, renderer.m_shaderBind = ctx.newShaderDataBinding(pipeline, vtxFmt, vbufInfo.first,
nullptr, nullptr, 1, uniforms, nullptr, nullptr, nullptr, 1, uniforms, stages,
texCount, textures, nullptr, nullptr); ubufOffs, ubufSizes, texCount, textures,
nullptr, nullptr, vbufInfo.second);
} }
}; };
@ -158,18 +168,29 @@ struct VulkanLineDataBindingFactory : CLineRendererShaders::IDataBindingFactory
int texCount = 0; int texCount = 0;
boo::ITexture* textures[1]; boo::ITexture* textures[1];
std::pair<boo::IGraphicsBufferD*, hecl::VertexBufferPool<CLineRenderer::SDrawVertTex>::IndexTp> vbufInfo;
std::pair<boo::IGraphicsBufferD*, hecl::UniformBufferPool<CLineRenderer::SDrawUniform>::IndexTp> ubufInfo =
renderer.m_uniformBuf.getBufferInfo();
if (texture) if (texture)
{ {
vbufInfo = renderer.m_vertBufTex.getBufferInfo();
textures[0] = texture; textures[0] = texture;
texCount = 1; texCount = 1;
} }
else
{
vbufInfo = renderer.m_vertBufNoTex.getBufferInfo();
}
boo::IGraphicsBuffer* uniforms[] = {renderer.m_uniformBuf}; boo::IGraphicsBuffer* uniforms[] = {ubufInfo.first};
boo::PipelineStage stages[] = {boo::PipelineStage::Vertex};
size_t ubufOffs[] = {ubufInfo.second};
size_t ubufSizes[] = {sizeof(CLineRenderer::SDrawUniform)};
renderer.m_shaderBind = ctx.newShaderDataBinding(pipeline, nullptr, renderer.m_vertBuf, renderer.m_shaderBind = ctx.newShaderDataBinding(pipeline, nullptr, vbufInfo.first,
nullptr, nullptr, 1, uniforms, nullptr, nullptr, 1, uniforms,
nullptr, texCount, textures, stages, ubufOffs, ubufSizes, texCount, textures,
nullptr, nullptr); nullptr, nullptr, vbufInfo.second);
} }
}; };

View File

@ -94,17 +94,29 @@ struct HLSLLineDataBindingFactory : CLineRendererShaders::IDataBindingFactory
int texCount = 0; int texCount = 0;
boo::ITexture* textures[1]; boo::ITexture* textures[1];
std::pair<boo::IGraphicsBufferD*, hecl::VertexBufferPool<CLineRenderer::SDrawVertTex>::IndexTp> vbufInfo;
std::pair<boo::IGraphicsBufferD*, hecl::UniformBufferPool<CLineRenderer::SDrawUniform>::IndexTp> ubufInfo =
renderer.m_uniformBuf.getBufferInfo();
if (texture) if (texture)
{ {
vbufInfo = renderer.m_vertBufTex.getBufferInfo();
textures[0] = texture; textures[0] = texture;
texCount = 1; texCount = 1;
} }
else
{
vbufInfo = renderer.m_vertBufNoTex.getBufferInfo();
}
boo::IGraphicsBuffer* uniforms[] = {renderer.m_uniformBuf}; boo::IGraphicsBuffer* uniforms[] = {ubufInfo.first};
boo::PipelineStage stages[] = {boo::PipelineStage::Vertex};
size_t ubufOffs[] = {ubufInfo.second};
size_t ubufSizes[] = {sizeof(CLineRenderer::SDrawUniform)};
renderer.m_shaderBind = ctx.newShaderDataBinding(pipeline, nullptr, renderer.m_vertBuf, renderer.m_shaderBind = ctx.newShaderDataBinding(pipeline, nullptr, vbufInfo.first,
nullptr, nullptr, 1, uniforms, nullptr, nullptr, nullptr, 1, uniforms, stages,
texCount, textures, nullptr, nullptr); ubufOffs, ubufSizes, texCount, textures,
nullptr, nullptr, vbufInfo.second);
} }
}; };

View File

@ -109,17 +109,29 @@ struct MetalLineDataBindingFactory : CLineRendererShaders::IDataBindingFactory
int texCount = 0; int texCount = 0;
boo::ITexture* textures[1]; boo::ITexture* textures[1];
std::pair<boo::IGraphicsBufferD*, hecl::VertexBufferPool<CLineRenderer::SDrawVertTex>::IndexTp> vbufInfo;
std::pair<boo::IGraphicsBufferD*, hecl::UniformBufferPool<CLineRenderer::SDrawUniform>::IndexTp> ubufInfo =
renderer.m_uniformBuf.getBufferInfo();
if (texture) if (texture)
{ {
vbufInfo = renderer.m_vertBufTex.getBufferInfo();
textures[0] = texture; textures[0] = texture;
texCount = 1; texCount = 1;
} }
else
{
vbufInfo = renderer.m_vertBufNoTex.getBufferInfo();
}
boo::IGraphicsBuffer* uniforms[] = {renderer.m_uniformBuf}; boo::IGraphicsBuffer* uniforms[] = {ubufInfo.first};
boo::PipelineStage stages[] = {boo::PipelineStage::Vertex};
size_t ubufOffs[] = {ubufInfo.second};
size_t ubufSizes[] = {sizeof(CLineRenderer::SDrawUniform)};
renderer.m_shaderBind = ctx.newShaderDataBinding(pipeline, nullptr, renderer.m_vertBuf, renderer.m_shaderBind = ctx.newShaderDataBinding(pipeline, nullptr, vbufInfo.first,
nullptr, nullptr, 1, uniforms, nullptr, nullptr, nullptr, 1, uniforms, stages,
texCount, textures, nullptr, nullptr); ubufOffs, ubufSizes, texCount, textures,
nullptr, nullptr, vbufInfo.second);
} }
}; };

2
hecl

@ -1 +1 @@
Subproject commit 2066835a7c597ec5fb022713edbb5a598941dce7 Subproject commit 1327e4b4e8da8275e5a765e9a49802669df36fd8