Commit 63501dd2 authored by Martin Turski's avatar Martin Turski

- added math that will be required for world sectoring computations and frustum checking

- made all IMG archives mount to the same device path prefix
parent d5910ef8
Pipeline #38 skipped
......@@ -16,6 +16,7 @@
#include <Console.CommandHelpers.h>
#include <Streaming.tests.h>
#include <WorldMath.h>
namespace krt
{
......@@ -48,6 +49,7 @@ int Main::Run(const ProgramArguments& arguments)
console::ExecuteBuffer();
// ))))))))))))))
math::Tests();
streaming::FaultTest1();
streaming::Test3();
......
Please put important external dependencies here. We do not want to pollute the commit log
so you should fetch them yourself.
'librw' from https://github.com/aap/librw
'librwgta' from https://github.com/aap/librwgta
\ No newline at end of file
......@@ -34,7 +34,7 @@ public:
void LoadIDEFile( std::string relPath );
void LoadIPLFile( std::string relPath );
vfs::DevicePtr FindDevice( std::string path, std::string& devPathOut );
std::string GetDevicePathPrefix( void ) { return "gta3:/"; }
private:
std::string gameDir;
......@@ -43,15 +43,6 @@ private:
TextureManager texManager;
ModelManager modelManager;
// Need to keep track because there is no generic vfs access system.
struct registered_device
{
std::string pathPrefix;
vfs::DevicePtr mountedDevice;
};
std::vector <registered_device> mountedDevices;
};
extern Game *theGame;
......
#pragma once
// Important math about camera frustum and world sectoring.
namespace krt
{
namespace math
{
struct Sphere
{
rw::V3d point;
float radius;
inline bool intersectLine( const rw::V3d& pos, const rw::V3d& dir, double& first, double& second ) const;
};
// Don't mind the German names. :)
struct Quader
{
inline Quader(
rw::V3d brl, rw::V3d brr, rw::V3d bfl, rw::V3d bfr,
rw::V3d trl, rw::V3d trr, rw::V3d tfl, rw::V3d tfr
);
inline bool isPointInside( const rw::V3d& point ) const;
inline bool intersectWith( const Quader& right ) const;
inline bool intersectWith( const Sphere& right ) const;
// Please do not write into those fields directly!
const rw::V3d brl, brr, bfl, bfr; // bottom plane.
const rw::V3d trl, trr, tfl, tfr; // top plane.
};
// A function to test our math.
// Should succeed, eh.
void Tests( void );
}
};
\ No newline at end of file
......@@ -59,7 +59,7 @@ Game::Game( void ) : streaming( GAME_NUM_STREAMING_CHANNELS ), texManager( strea
this->RunCommandFile( "DATA\\GTA.DAT" );
// Do a test that loads all game models.
modelManager.LoadAllModels();
//modelManager.LoadAllModels();
}
Game::~Game( void )
......@@ -141,19 +141,11 @@ void Game::LoadIMG( std::string relPath )
vfs::DevicePtr myDevPtr( imgDevice );
std::string pathPrefix = ( containerName + ":/" );
// Temporary for now.
std::string pathPrefix = this->GetDevicePathPrefix();
vfs::Mount( myDevPtr, pathPrefix );
// Register our mounted container.
{
registered_device info;
info.pathPrefix = pathPrefix;
info.mountedDevice = myDevPtr;
this->mountedDevices.push_back( info );
}
// We now have to parse the contents of the IMG archive. :)
{
vfs::FindData findData;
......@@ -462,32 +454,4 @@ void Game::RunCommandFile( std::string relPath )
localConsole.ExecuteBuffer();
}
vfs::DevicePtr Game::FindDevice( std::string genPath, std::string& devPathOut )
{
// Search the mounted devices for one that contains our requested item.
for ( const registered_device& curDev : this->mountedDevices )
{
vfs::DevicePtr device = curDev.mountedDevice;
// Construct a device path.
std::string devPath = ( curDev.pathPrefix + genPath );
uint64_t bulkOffset;
// We do a test. The first device to open our request wins :)
vfs::Device::THandle tryOpenHandle = device->OpenBulk( devPath, &bulkOffset );
if ( tryOpenHandle != vfs::Device::InvalidHandle )
{
// OK you won. Lets return you.
device->CloseBulk( tryOpenHandle );
devPathOut = devPath;
return vfs::DevicePtr( device );
}
}
return nullptr;
}
};
\ No newline at end of file
......@@ -55,11 +55,11 @@ void ModelManager::RegisterResource(
}
// Get the device this model is bound to.
vfs::DevicePtr resDevice;
std::string devPath;
{
resDevice = theGame->FindDevice( relFilePath, devPath );
}
std::string pathPrefix = theGame->GetDevicePathPrefix();
std::string devPath = ( pathPrefix + relFilePath );
vfs::DevicePtr resDevice = vfs::GetDevice( devPath );
if ( resDevice == nullptr )
{
......
This diff is collapsed.
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment