Commit 00b302fd authored by Martin Turski's avatar Martin Turski

finished frustum math in WorldMath.h and added World rendering test with...

finished frustum math in WorldMath.h and added World rendering test with sector grid in World.cpp (thank you for giving an example rendering code!)
parent 4fbd0559
......@@ -3,21 +3,27 @@
#include "QuadTree.h"
#include "Game.h"
#include "Console.CommandHelpers.h"
namespace krt
{
static ConsoleCommand cmdWorldStreamTest( "wsector_test",
[&]( void )
{
Game *theGame = krt::theGame;
World *theWorld = theGame->GetWorld();
theWorld->PutEntitiesOnGrid();
});
World::World( void )
{
// A world can store a lot of entities.
LIST_CLEAR( this->entityList.root );
QuadTree <3, 6000, int> tree;
tree.root.VisitByPoint( 200, 200,
[]( int& ok )
{
ok = 1337;
});
}
World::~World( void )
......@@ -36,9 +42,232 @@ World::~World( void )
// TODO: add more cool world stuff.
#define DEG2RAD( x ) (x*3.14159265/180)
inline rw::V3d corvec( rw::V3d rwvec )
{
return rw::V3d( rwvec.x, rwvec.z, rwvec.y );
}
inline math::Quader getCameraFrustum( rw::Camera *camera, float fov_angle )
{
// Calculate it ourselves.
float farPlaneDist = camera->farPlane;
float nearPlaneDist = camera->nearPlane;
double fov = DEG2RAD(fov_angle);
double ar = 16.0f / 9.0f;
double Hnear = 2 * tan( fov / 2 ) * nearPlaneDist;
double Wnear = Hnear * ar;
double Hfar = 2 * tan( fov / 2 ) * farPlaneDist;
double Wfar = Hfar * ar;
rw::Matrix cameraWorldMat = *camera->getFrame()->getLTM();
float half_Wnear = (float)( Wnear / 2 );
float half_Hnear = (float)( Hnear / 2 );
float half_Wfar = (float)( Wfar / 2 );
float half_Hfar = (float)( Hfar / 2 );
rw::V3d brl = cameraWorldMat.transPoint( rw::V3d( -half_Wnear, -half_Hnear, nearPlaneDist ) );
rw::V3d brr = cameraWorldMat.transPoint( rw::V3d( half_Wnear, -half_Hnear, nearPlaneDist ) );
rw::V3d trl = cameraWorldMat.transPoint( rw::V3d( -half_Wnear, half_Hnear, nearPlaneDist ) );
rw::V3d trr = cameraWorldMat.transPoint( rw::V3d( half_Wnear, half_Hnear, nearPlaneDist ) );
rw::V3d bfl = cameraWorldMat.transPoint( rw::V3d( -half_Wfar, -half_Hfar, farPlaneDist ) );
rw::V3d bfr = cameraWorldMat.transPoint( rw::V3d( half_Wfar, -half_Hfar, farPlaneDist ) );
rw::V3d tfl = cameraWorldMat.transPoint( rw::V3d( -half_Wfar, half_Hfar, farPlaneDist ) );
rw::V3d tfr = cameraWorldMat.transPoint( rw::V3d( half_Wfar, half_Hfar, farPlaneDist ) );
// Construct a view frustum.
return math::Quader( corvec( brl ), corvec( brr ), corvec( bfl ), corvec( bfr ), corvec( trl ), corvec( trr ), corvec( tfl ), corvec( tfr ) );
}
void World::DepopulateEntities( void )
{
// Remove all entity world links for the entities we know.
LIST_FOREACH_BEGIN( Entity, this->entityList.root, worldNode )
item->RemoveEntityFromWorldSectors();
LIST_FOREACH_END
}
void World::PutEntitiesOnGrid( void )
{
// Try putting all the world entities on the grid.
LIST_FOREACH_BEGIN( Entity, this->entityList.root, worldNode )
this->staticEntityGrid.PutEntity( item );
LIST_FOREACH_END
}
static ConsoleCommand putGridCmd( "pgrid",
[]( void )
{
theGame->GetWorld()->DepopulateEntities();
theGame->GetWorld()->PutEntitiesOnGrid();
printf( "populated static entity grid\n" );
});
#include <windows.h>
#include <d3d9.h>
void World::RenderWorld( void *gfxDevice )
{
// Thank you Bas for figuring out that rendering gunk!
// perform rendering
IDirect3DDevice9* device = reinterpret_cast<IDirect3DDevice9*>(gfxDevice);
device->Clear(0, 0, D3DCLEAR_TARGET | D3DCLEAR_ZBUFFER, D3DCOLOR_ARGB(255, 0, 0x99, 0xff), 1.0f, 0);
device->BeginScene();
device->SetRenderState(D3DRS_CULLMODE, D3DCULL_NONE);
device->SetRenderState(D3DRS_SRCBLEND, D3DBLEND_SRCALPHA);
device->SetRenderState(D3DRS_DESTBLEND, D3DBLEND_INVSRCALPHA);
device->SetRenderState(D3DRS_ALPHABLENDENABLE, 1);
device->SetTextureStageState(0, D3DTSS_ALPHAOP, D3DTOP_MODULATE);
// Create a test frustum and see how it intersects with things.
rw::Camera *testCamera = rw::Camera::create();
assert( testCamera != NULL );
testCamera->farPlane = 600.0f;
testCamera->nearPlane = 1.0f;
//testCamera->projection = rw::Camera::PERSPECTIVE;
float fov_angle = 65.0f;
testCamera->setFOV( fov_angle, 16.0f / 9.0f );
rw::Frame *camFrame = rw::Frame::create();
assert( camFrame != NULL );
rw::Matrix cam_mat;
cam_mat.setIdentity();
cam_mat.pos = rw::V3d( -15, 100, -1890 );
cam_mat.posw = 1;
camFrame->matrix = cam_mat;
camFrame->updateObjects();
testCamera->setFrame( camFrame );
testCamera->updateProjectionMatrix();
{
rw::V3d cameraPosition(500.0f, 50.0f, 100.0f);
rw::V3d objectPosition(0.0f, 0.0f, 100.0f);
rw::Frame* frame = testCamera->getFrame();
if (frame)
{
rw::V3d forward = rw::normalize(rw::sub(objectPosition, cameraPosition));
rw::V3d left = rw::normalize(rw::cross(rw::V3d(0.0f, 0.0f, 1.0f), forward));
rw::V3d up = rw::cross(forward, left);
frame->matrix.right = left;
frame->matrix.up = up;
frame->matrix.at = forward;
frame->matrix.pos = cameraPosition;
frame->updateObjects();
}
}
rw::Matrix viewmat;
rw::Matrix::invert(&viewmat, testCamera->getFrame()->getLTM());
//viewmat.right.x = -viewmat.right.x;
viewmat.rightw = 0.0;
//viewmat.up.x = -viewmat.up.x;
viewmat.upw = 0.0;
//viewmat.at.x = -viewmat.at.x;
viewmat.atw = 0.0;
//viewmat.pos.x = -viewmat.pos.x;
viewmat.posw = 1.0;
device->SetTransform(D3DTS_VIEW, (D3DMATRIX*)&viewmat);
device->SetTransform(D3DTS_PROJECTION, (D3DMATRIX*)testCamera->projMat);
// Get its frustum.
math::Quader frustum = getCameraFrustum( testCamera, fov_angle );
streaming::StreamMan& streaming = theGame->GetStreaming();
// Visit the things that are visible.
this->staticEntityGrid.VisitSectorsByFrustum( frustum,
[&]( StaticEntitySector& sector )
{
// Render all entities on this sector.
for ( Entity *entity : sector.entitiesOnSector )
{
rw::Sphere worldSphere;
bool hasEntityBounds = entity->GetWorldBoundingSphere( worldSphere );
if ( hasEntityBounds )
{
math::Sphere math_sphere;
math_sphere.point = worldSphere.center;
math_sphere.radius = worldSphere.radius;
if ( frustum.intersectWith( math_sphere ) )
{
// Entity is visible.
// Request a model for this entity.
{
ModelManager::ModelResource *entityModel = entity->GetModelInfo();
if ( entityModel )
{
streaming::ident_t streaming_id = entityModel->GetID();
if ( streaming.GetResourceStatus( streaming_id ) != streaming::StreamMan::eResourceStatus::LOADED )
{
streaming.Request( streaming_id );
}
}
}
entity->CreateRWObject();
// If the entity has a valid rw object, we can render it.
if ( rw::Object *rwobj = entity->GetRWObject() )
{
if ( rwobj->type == rw::Atomic::ID )
{
// We only render atomics for now.
rw::Atomic *atomic = (rw::Atomic*)rwobj;
atomic->render();
}
}
}
}
}
});
testCamera->destroy();
testCamera = NULL;
camFrame->destroy();
camFrame = NULL;
device->EndScene();
device->Present(nullptr, nullptr, nullptr, nullptr);
// OK.
}
}
\ No newline at end of file
#include "StdInc.h"
#include "WorldMath.h"
#include <utils/DataSlice.h>
namespace krt
{
namespace math
{
inline float ivec( const rw::V3d v, int idx )
inline float ivec( const rw::V3d& v, int idx )
{
if ( idx == 1 )
{
......@@ -24,21 +26,53 @@ inline float ivec( const rw::V3d v, int idx )
return 0.0f;
}
// SPECIAL PLANE EQUATION SOLUTIONS.
// GTFO IF YOU DONT KNOW WHAT YOU ARE DOING M8.
// Cats meow beautifully into the night
typedef double p_resolve_t;
// Class to represent a polynome of max. first grade.
struct Simple_Polynome
{
p_resolve_t raise;
p_resolve_t const_off;
MATH_INLINE p_resolve_t Calculate( p_resolve_t x ) const
{
return ( raise * x + const_off );
}
MATH_INLINE bool IsConst( void ) const
{
return ( this->raise == 0 );
}
};
enum class ePolynomePlaneDependsType
{
DEPENDS_ON_A,
DEPENDS_ON_B,
DEPENDS_ON_S,
DEPENDS_ON_T
};
enum class ePolynomeCoefficient
{
COEFF_A,
COEFF_B,
COEFF_S,
COEFF_T
};
// Helper math.
MATH_INLINE p_resolve_t block_trans( const rw::V3d& t, const rw::V3d& b, int idxPrim, int idxSec )
{
return ivec( t, idxPrim ) / ivec( b, idxPrim ) - ivec( t, idxPrim ) / ivec( b, idxSec );
return ivec( t, idxPrim ) / ivec( b, idxPrim ) - ivec( t, idxSec ) / ivec( b, idxSec );
}
// The most general solution, kinda. Could also say most complicated.
inline bool plane_solution_fetcht_type_a(
const rw::V3d& u, const rw::V3d& z, const rw::V3d& o,
const rw::V3d& x, const rw::V3d& y, const rw::V3d& p,
p_resolve_t b, p_resolve_t& result
Simple_Polynome& polyOut, ePolynomeCoefficient& coeffSrcType, ePolynomeCoefficient& coeffDependsType
)
{
// Check this shit beforehand.
......@@ -54,10 +88,9 @@ inline bool plane_solution_fetcht_type_a(
if ( mod_point_yx12_yx32_diff != 0 && mod_point_ux12 != 0 && mod_point_ux32 != 0 )
{
p_resolve_t t =
polyOut.raise = ( block_trans( z, x, 1, 2 ) / mod_point_ux12 - block_trans( z, x, 3, 2 ) / mod_point_ux32 ) / mod_point_yx12_yx32_diff;
polyOut.const_off =
(
b * ( block_trans( z, x, 1, 2 ) / mod_point_ux12 - block_trans( z, x, 3, 2 ) / mod_point_ux32 )
+
(
( block_trans( o, x, 1, 2 ) - block_trans( p, x, 1, 2 ) ) / mod_point_ux12
-
......@@ -66,7 +99,9 @@ inline bool plane_solution_fetcht_type_a(
)
/ mod_point_yx12_yx32_diff;
result = t;
coeffSrcType = ePolynomeCoefficient::COEFF_T;
coeffDependsType = ePolynomeCoefficient::COEFF_B;
return true;
}
......@@ -78,10 +113,9 @@ inline bool plane_solution_fetcht_type_a(
if ( mod_point_yx12_yx13_diff != 0 && mod_point_ux12 != 0 && mod_point_ux13 != 0 )
{
p_resolve_t t =
polyOut.raise = ( block_trans( z, x, 1, 2 ) / mod_point_ux12 - block_trans( z, x, 1, 3 ) / mod_point_ux13 ) / mod_point_yx12_yx13_diff;
polyOut.const_off =
(
b * ( block_trans( z, x, 1, 2 ) / mod_point_ux12 - block_trans( z, x, 1, 3 ) / mod_point_ux13 )
+
(
( block_trans( o, x, 1, 2 ) - block_trans( p, x, 1, 2 ) ) / mod_point_ux12
-
......@@ -90,7 +124,9 @@ inline bool plane_solution_fetcht_type_a(
)
/ mod_point_yx12_yx13_diff;
result = t;
coeffSrcType = ePolynomeCoefficient::COEFF_T;
coeffDependsType = ePolynomeCoefficient::COEFF_B;
return true;
}
......@@ -98,10 +134,9 @@ inline bool plane_solution_fetcht_type_a(
if ( mod_point_yx32_yx13_diff != 0 && mod_point_ux32 != 0 && mod_point_ux13 != 0 )
{
p_resolve_t t =
polyOut.raise = ( block_trans( z, x, 3, 2 ) / mod_point_ux32 - block_trans( z, x, 1, 3 ) / mod_point_ux13 ) / mod_point_yx32_yx13_diff;
polyOut.const_off =
(
b * ( block_trans( z, x, 3, 2 ) / mod_point_ux32 - block_trans( z, x, 1, 3 ) / mod_point_ux13 )
+
(
( block_trans( o, x, 3, 2 ) - block_trans( p, x, 3, 2 ) ) / mod_point_ux32
-
......@@ -110,7 +145,9 @@ inline bool plane_solution_fetcht_type_a(
)
/ mod_point_yx32_yx13_diff;
result = t;
coeffSrcType = ePolynomeCoefficient::COEFF_T;
coeffDependsType = ePolynomeCoefficient::COEFF_B;
return true;
}
......@@ -123,7 +160,7 @@ inline bool plane_solution_fetcht_type_a(
inline bool plane_solution_fetcht_type_b(
const rw::V3d& u, const rw::V3d& z, const rw::V3d& o,
const rw::V3d& x, const rw::V3d& y, const rw::V3d& p,
p_resolve_t b, p_resolve_t& result,
Simple_Polynome& polyOut, ePolynomeCoefficient& coeffSrcType, ePolynomeCoefficient& coeffDependsType,
int datIndex
)
{
......@@ -139,7 +176,7 @@ inline bool plane_solution_fetcht_type_b(
if ( ivec( x, prim_divide ) != 0 && ivec( x, sec_divide ) != 0 )
{
if ( ivec( u, datIndex != 0 ) )
if ( ivec( u, datIndex ) != 0 )
{
// We got a solution, probably.
p_resolve_t mod_point_ux = block_trans( u, x, prim_divide, sec_divide );
......@@ -151,10 +188,9 @@ inline bool plane_solution_fetcht_type_b(
if ( major_divisor != 0 )
{
// Alright, we should have a solution here.
p_resolve_t t =
polyOut.raise = ( ivec( z, datIndex ) / ivec( u, datIndex ) - block_trans( z, x, prim_divide, sec_divide ) ) / major_divisor;
polyOut.const_off =
(
b * ( ivec( z, datIndex ) / ivec( u, datIndex ) - block_trans( z, x, prim_divide, sec_divide ) )
+
(
( ivec( o, datIndex ) - ivec( p, datIndex ) ) / ivec( u, datIndex )
-
......@@ -168,7 +204,9 @@ inline bool plane_solution_fetcht_type_b(
)
) / major_divisor;
result = t;
coeffSrcType = ePolynomeCoefficient::COEFF_T;
coeffDependsType = ePolynomeCoefficient::COEFF_B;
return true;
}
}
......@@ -202,10 +240,9 @@ inline bool plane_solution_fetcht_type_b(
if ( major_divisor != 0 )
{
// We got a winner!
p_resolve_t t =
polyOut.raise = ( ivec( z, datIndex ) / ivec( u, datIndex ) - block_trans( z, x, prim_divide, sec_divide ) / modulator ) / major_divisor;
polyOut.const_off =
(
b * ( ivec( z, datIndex ) / ivec( u, datIndex ) - block_trans( z, x, prim_divide, sec_divide ) / modulator )
+
(
( ivec( o, datIndex ) - ivec( p, datIndex ) ) / ivec( u, datIndex )
-
......@@ -217,7 +254,9 @@ inline bool plane_solution_fetcht_type_b(
) / modulator
) / major_divisor;
result = t;
coeffSrcType = ePolynomeCoefficient::COEFF_T;
coeffDependsType = ePolynomeCoefficient::COEFF_B;
return true;
}
}
......@@ -234,10 +273,9 @@ inline bool plane_solution_fetcht_type_b(
if ( divisor != 0 )
{
// Easy fish.
p_resolve_t t =
polyOut.raise = block_trans( z, x, prim_divide, sec_divide ) / divisor;
polyOut.const_off =
(
b * block_trans( z, x, prim_divide, sec_divide )
+
(
( ivec( o, prim_divide ) - ivec( p, prim_divide ) ) / ivec( x, prim_divide )
-
......@@ -245,7 +283,9 @@ inline bool plane_solution_fetcht_type_b(
)
) / divisor;
result = t;
coeffSrcType = ePolynomeCoefficient::COEFF_T;
coeffDependsType = ePolynomeCoefficient::COEFF_B;
return true;
}
}
......@@ -254,13 +294,73 @@ inline bool plane_solution_fetcht_type_b(
// And even more...
if ( ivec( y, datIndex ) != 0 )
if ( ivec( u, datIndex ) == 0 )
{
// Pretty cool little solution right here.
p_resolve_t t = ( b * ivec( z, datIndex ) + ivec( o, datIndex ) - ivec( p, datIndex ) ) / ivec( y, datIndex );
if ( ivec( y, datIndex ) != 0 )
{
// Pretty cool little solution right here.
polyOut.raise = ivec( z, datIndex ) / ivec( y, datIndex );
polyOut.const_off = ( ivec( o, datIndex ) - ivec( p, datIndex ) ) / ivec( y, datIndex );
result = t;
return true;
coeffSrcType = ePolynomeCoefficient::COEFF_T;
coeffDependsType = ePolynomeCoefficient::COEFF_B;
return true;
}
else
{
if ( ivec( z, datIndex ) != 0 ) // Otherwise 2D plane equation stuff. Maybe in the future.
{
rw::V3d op_diff = rw::sub( o, p );
// b is a constant.
p_resolve_t b = ( -ivec( op_diff, datIndex ) / ivec( z, datIndex ) );
if ( ivec( x, prim_divide ) == 0 )
{
if ( ivec( y, prim_divide ) != 0 ) // otherwise the other plane makes no sense.
{
polyOut.raise = ivec( u, prim_divide ) / ivec( y, prim_divide );
polyOut.const_off = ( b * ivec( z, prim_divide ) + ivec( op_diff, prim_divide ) ) / ivec( y, prim_divide );
coeffSrcType = ePolynomeCoefficient::COEFF_T;
coeffDependsType = ePolynomeCoefficient::COEFF_A;
return true;
}
}
else if ( ivec( x, sec_divide ) == 0 )
{
if ( ivec( y, sec_divide ) != 0 ) // otherwise the other plane makes no sense.
{
polyOut.raise = ivec( u, sec_divide ) / ivec( y, sec_divide );
polyOut.const_off = ( b * ivec( z, sec_divide ) + ivec( op_diff, sec_divide ) ) / ivec( y, sec_divide );
coeffSrcType = ePolynomeCoefficient::COEFF_T;
coeffDependsType = ePolynomeCoefficient::COEFF_A;
return true;
}
}
else
{
// Special solution.
p_resolve_t divisor = block_trans( y, x, prim_divide, sec_divide );
if ( divisor != 0 )
{
// We can get a special kind of equation for t.
polyOut.raise = block_trans( u, x, prim_divide, sec_divide ) / divisor;
polyOut.const_off = ( b * block_trans( z, x, prim_divide, sec_divide ) + block_trans( op_diff, x, prim_divide, sec_divide ) ) / divisor;
coeffSrcType = ePolynomeCoefficient::COEFF_T;
coeffDependsType = ePolynomeCoefficient::COEFF_A;
return true;
}
}
}
}
}
// No result.
......@@ -271,153 +371,1047 @@ inline bool plane_solution_fetcht_type_b(
inline bool plane_solution_fetcht_type_c(
const rw::V3d& u, const rw::V3d& z, const rw::V3d& o,
const rw::V3d& x, const rw::V3d& y, const rw::V3d& p,
p_resolve_t b, p_resolve_t& result,
Simple_Polynome& polyOut, ePolynomeCoefficient& coeffSrcType, ePolynomeCoefficient& coeffDependsType,
int prim_idx, int sec_idx
)
{
assert( ivec( x, prim_idx == 0 ) && ivec( x, sec_idx ) == 0 );
assert( ivec( x, prim_idx ) == 0 && ivec( x, sec_idx ) == 0 );
// It ain't that hard even, meow.
p_resolve_t divisor = block_trans( y, u, prim_idx, sec_idx );
if ( divisor )
if ( ivec( u, prim_idx ) != 0 && ivec( u, sec_idx ) != 0 )
{
p_resolve_t t =
(
b * block_trans( z, u, prim_idx, sec_idx )
+
// It ain't that hard even, meow.
p_resolve_t divisor = block_trans( y, u, prim_idx, sec_idx );
if ( divisor )
{
polyOut.raise = block_trans( z, u, prim_idx, sec_idx ) / divisor;
polyOut.const_off =
(
( ivec( o, prim_idx ) - ivec( p, prim_idx ) ) / ivec( u, prim_idx )
-
( ivec( o, sec_idx ) - ivec( p, sec_idx ) ) / ivec( u, sec_idx )
)
) / divisor;
(
( ivec( o, prim_idx ) - ivec( p, prim_idx ) ) / ivec( u, prim_idx )
-
( ivec( o, sec_idx ) - ivec( p, sec_idx ) ) / ivec( u, sec_idx )
)
) / divisor;
coeffSrcType = ePolynomeCoefficient::COEFF_T;
coeffDependsType = ePolynomeCoefficient::COEFF_B;
return true;
}
}
return false;
}
// As well as for the other polynome calculator, we can have corner case polynomes here.
MATH_INLINE bool plane_solution_fetcht_type_d(
const rw::V3d& u, const rw::V3d& z, const rw::V3d& o,
const rw::V3d& x, const rw::V3d& y, const rw::V3d& p,
Simple_Polynome& polyOut, ePolynomeCoefficient& coeffSrcType, ePolynomeCoefficient& coeffDependsType,
int datIndex
)
{
int prim_divide = ( ( datIndex == 1 ) ? 2 : 1 );
int sec_divide = ( ( datIndex == 3 ) ? 2 : 3 );
if ( ivec( y, datIndex ) != 0 && ivec( x, datIndex ) == 0 && ivec( y, prim_divide ) == 0 && ivec( y, sec_divide ) == 0 &&
ivec( z, datIndex ) == 0 )
{
// Special cute corner case solution, meow.
polyOut.raise = ivec( u, datIndex ) / ivec( y, datIndex );
polyOut.const_off = ( ivec( o, datIndex ) - ivec( p, datIndex ) ) / ivec( y, datIndex );
coeffSrcType = ePolynomeCoefficient::COEFF_T;
coeffDependsType = ePolynomeCoefficient::COEFF_A;
result = t;
return true;
}
return false;
}
bool Plane::intersectWith( const Plane& right ) const
// Ever heard of polynomes? They are pretty cool.
// This function is used to get the polynome to calculate t depending on b in a 3D plane equation.
MATH_INLINE bool plane_solution_fetcht_find_polynome(
const rw::V3d& u, const rw::V3d& z, const rw::V3d& o,
const rw::V3d& x, const rw::V3d& y, const rw::V3d& p,
Simple_Polynome& coeff_resolve, ePolynomeCoefficient& coeffSrcType, ePolynomeCoefficient& coeffDependType
)
{
// Try some shitty math.
// I hope I got all cases of plane-plane intersection figured out.
// Specialized math.
if ( ivec( x, 1 ) != 0 && ivec( x, 2 ) != 0 && ivec( x, 3 ) != 0 )
{
if ( plane_solution_fetcht_type_a( u, z, o, x, y, p, coeff_resolve, coeffSrcType, coeffDependType ) )
return true;
}
// Legend: x is vector a of this, s is scalar
// y is vector b of this, t is scalar
// u is vector a of right, a is scalar
// z is vector b of right, b is scalar
// p is position of this
// o is position of right
// Always search further if no solution has been found yet.
rw::V3d x = this->a;
rw::V3d y = this->b;
rw::V3d u = right.a;
rw::V3d z = right.b;
rw::V3d p = this->pos;
rw::V3d o = right.pos;
if ( ivec( x, 1 ) == 0 )
{
if ( plane_solution_fetcht_type_b( u, z, o, x, y, p, coeff_resolve, coeffSrcType, coeffDependType, 1 ) )
return true;
bool hasIntersection = false;
// TODO: check special solution.
}
if ( ivec( x, 2 ) == 0 )
{
if ( plane_solution_fetcht_type_b( u, z, o, x, y, p, coeff_resolve, coeffSrcType, coeffDependType, 2 ) )
return true;
// Check all possible cases.
// We first do get the value of t depending on b.
// Then we resolve s depending on t, resolve a depending on b.
p_resolve_t t0, t1;
bool hasSolution = false; // true if we found a solution for t based on b.
// TODO: check special solution.
}
if ( ivec( x, 3 ) == 0 )
{
if ( plane_solution_fetcht_type_b( u, z, o, x, y, p, coeff_resolve, coeffSrcType, coeffDependType, 3 ) )
return true;
// TODO: check special solution.
}
// Now check for solutions if two coordinates are zero.
if ( ivec( x, 1 ) == 0 && ivec( x, 2 ) == 0 )
{
if ( plane_solution_fetcht_type_c( u, z, o, x, y, p, coeff_resolve, coeffSrcType, coeffDependType, 1, 2 ) )
return true;
}
else if ( ivec( x, 2 ) == 0 && ivec( x, 3 ) == 0 )