cleanup: spelling, comments, alignment

fixed pet peeve “frustrum” and other non-functional changes.
This commit is contained in:
2016-01-28 01:35:50 -05:00
parent 05dbc470ad
commit f91fe78af5
9 changed files with 85 additions and 90 deletions

View File

@@ -800,7 +800,7 @@ typedef struct RecastData {
typedef struct GameData { typedef struct GameData {
/* standalone player */ /* standalone player */
struct GameFraming framing; struct GameFraming framing;
short playerflag, xplay, yplay, freqplay; short playerflag, xplay, yplay, freqplay;
short depth, attrib, rt1, rt2; short depth, attrib, rt1, rt2;
@@ -823,7 +823,7 @@ typedef struct GameData {
/* /*
* bit 3: (gameengine): Activity culling is enabled. * bit 3: (gameengine): Activity culling is enabled.
* bit 5: (gameengine) : enable Bullet DBVT tree for view frustrum culling * bit 5: (gameengine) : enable Bullet DBVT tree for view frustum culling
*/ */
int flag; int flag;
short mode, matmode; short mode, matmode;

View File

@@ -86,7 +86,7 @@ typedef struct World {
* bit 2: (reserved) depth of field * bit 2: (reserved) depth of field
* bit 3: (gameengine): Activity culling is enabled. * bit 3: (gameengine): Activity culling is enabled.
* bit 4: ambient occlusion * bit 4: ambient occlusion
* bit 5: (gameengine) : enable Bullet DBVT tree for view frustrum culling * bit 5: (gameengine) : enable Bullet DBVT tree for view frustum culling
*/ */
short mode; // partially moved to scene->gamedata in 2.5 short mode; // partially moved to scene->gamedata in 2.5
short occlusionRes; /* resolution of occlusion Z buffer in pixel */ // XXX moved to scene->gamedata in 2.5 short occlusionRes; /* resolution of occlusion Z buffer in pixel */ // XXX moved to scene->gamedata in 2.5

View File

@@ -320,7 +320,7 @@ void KX_Camera::ExtractFrustumSphere()
if (m_projection_matrix[3][3] == MT_Scalar(0.0f)) if (m_projection_matrix[3][3] == MT_Scalar(0.0f))
{ {
// frustrum projection // frustum projection
// detect which of the corner of the far clipping plane is the farthest to the origin // detect which of the corner of the far clipping plane is the farthest to the origin
MT_Vector4 nfar; // far point in device normalized coordinate MT_Vector4 nfar; // far point in device normalized coordinate
MT_Point3 farpoint; // most extreme far point in camera coordinate MT_Point3 farpoint; // most extreme far point in camera coordinate
@@ -359,7 +359,7 @@ void KX_Camera::ExtractFrustumSphere()
nfar.setValue(-nfar[0], -nfar[1], -1.0f, 1.0f); nfar.setValue(-nfar[0], -nfar[1], -1.0f, 1.0f);
nfar = clip_camcs_matrix*nfar; nfar = clip_camcs_matrix*nfar;
nearpoint.setValue(nfar[0]/nfar[3], nfar[1]/nfar[3], nfar[2]/nfar[3]); nearpoint.setValue(nfar[0]/nfar[3], nfar[1]/nfar[3], nfar[2]/nfar[3]);
// this is a frustrum projection // this is a frustum projection
N = nearpoint.dot(nearpoint); N = nearpoint.dot(nearpoint);
e = farpoint[2]; e = farpoint[2];
s = nearpoint[2]; s = nearpoint[2];

View File

@@ -1450,22 +1450,21 @@ void KX_Dome::CalculateFrustum(KX_Camera *cam)
gluPerspective(90.0f,1.0f,cam->GetCameraNear(),cam->GetCameraFar()); gluPerspective(90.0f,1.0f,cam->GetCameraNear(),cam->GetCameraFar());
#endif #endif
RAS_FrameFrustum m_frustrum; //90 deg. Frustum RAS_FrameFrustum m_frustum; //90 deg. Frustum
m_frustrum.camnear = cam->GetCameraNear(); m_frustum.camnear = cam->GetCameraNear();
m_frustrum.camfar = cam->GetCameraFar(); m_frustum.camfar = cam->GetCameraFar();
// float top = tan(90.0f*MT_PI/360.0f) * m_frustrum.camnear; // float top = tan(90.0f*MT_PI/360.0f) * m_frustum.camnear;
float top = m_frustrum.camnear; // for deg = 90deg, tan = 1 float top = m_frustum.camnear; // for deg = 90deg, tan = 1
m_frustrum.x1 = -top; m_frustum.x1 = -top;
m_frustrum.x2 = top; m_frustum.x2 = top;
m_frustrum.y1 = -top; m_frustum.y1 = -top;
m_frustrum.y2 = top; m_frustum.y2 = top;
m_projmat = m_rasterizer->GetFrustumMatrix( m_projmat = m_rasterizer->GetFrustumMatrix(
m_frustrum.x1, m_frustrum.x2, m_frustrum.y1, m_frustrum.y2, m_frustrum.camnear, m_frustrum.camfar); m_frustum.x1, m_frustum.x2, m_frustum.y1, m_frustum.y2, m_frustum.camnear, m_frustum.camfar);
} }
void KX_Dome::CalculateCameraOrientation() void KX_Dome::CalculateCameraOrientation()

View File

@@ -107,7 +107,7 @@ double KX_KetsjiEngine::m_suspendedtime = 0.0;
double KX_KetsjiEngine::m_suspendeddelta = 0.0; double KX_KetsjiEngine::m_suspendeddelta = 0.0;
double KX_KetsjiEngine::m_average_framerate = 0.0; double KX_KetsjiEngine::m_average_framerate = 0.0;
bool KX_KetsjiEngine::m_restrict_anim_fps = false; bool KX_KetsjiEngine::m_restrict_anim_fps = false;
short KX_KetsjiEngine::m_exitkey = 130; //ESC Key short KX_KetsjiEngine::m_exitkey = 130; // ESC Key
/** /**
@@ -310,7 +310,7 @@ void KX_KetsjiEngine::RenderDome()
KX_SceneList::iterator sceneit; KX_SceneList::iterator sceneit;
KX_Scene* scene = NULL; KX_Scene* scene = NULL;
int n_renders=m_dome->GetNumberRenders();// usually 4 or 6 int n_renders=m_dome->GetNumberRenders(); // usually 4 or 6
for (int i=0;i<n_renders;i++) { for (int i=0;i<n_renders;i++) {
m_canvas->ClearBuffer(RAS_ICanvas::COLOR_BUFFER|RAS_ICanvas::DEPTH_BUFFER); m_canvas->ClearBuffer(RAS_ICanvas::COLOR_BUFFER|RAS_ICanvas::DEPTH_BUFFER);
for (sceneit = m_scenes.begin();sceneit != m_scenes.end(); sceneit++) for (sceneit = m_scenes.begin();sceneit != m_scenes.end(); sceneit++)
@@ -327,7 +327,7 @@ void KX_KetsjiEngine::RenderDome()
if (i == 0) { if (i == 0) {
RenderShadowBuffers(scene); RenderShadowBuffers(scene);
} }
// Avoid drawing the scene with the active camera twice when it's viewport is enabled // Avoid drawing the scene with the active camera twice when its viewport is enabled
if (cam && !cam->GetViewport()) if (cam && !cam->GetViewport())
{ {
if (scene->IsClearingZBuffer()) if (scene->IsClearingZBuffer())
@@ -337,7 +337,7 @@ void KX_KetsjiEngine::RenderDome()
// do the rendering // do the rendering
m_dome->RenderDomeFrame(scene,cam, i); m_dome->RenderDomeFrame(scene,cam, i);
//render all the font objects for this scene // render all the font objects for this scene
scene->RenderFonts(); scene->RenderFonts();
} }
@@ -355,7 +355,7 @@ void KX_KetsjiEngine::RenderDome()
// do the rendering // do the rendering
m_dome->RenderDomeFrame(scene, (*it),i); m_dome->RenderDomeFrame(scene, (*it),i);
//render all the font objects for this scene // render all the font objects for this scene
scene->RenderFonts(); scene->RenderFonts();
} }
@@ -438,7 +438,6 @@ void KX_KetsjiEngine::StartEngine(bool clearIpo)
m_sceneconverter->ResetPhysicsObjectsAnimationIpo(clearIpo); m_sceneconverter->ResetPhysicsObjectsAnimationIpo(clearIpo);
m_sceneconverter->WritePhysicsObjectToAnimationIpo(m_currentFrame); m_sceneconverter->WritePhysicsObjectToAnimationIpo(m_currentFrame);
} }
} }
void KX_KetsjiEngine::ClearFrame() void KX_KetsjiEngine::ClearFrame()
@@ -539,7 +538,7 @@ void KX_KetsjiEngine::EndFrame()
m_average_framerate = 1.0/tottime; m_average_framerate = 1.0/tottime;
// Go to next profiling measurement, time spend after this call is shown in the next frame. // Go to next profiling measurement, time spent after this call is shown in the next frame.
m_logger->NextMeasurement(m_kxsystem->GetTimeInSeconds()); m_logger->NextMeasurement(m_kxsystem->GetTimeInSeconds());
m_logger->StartLog(tc_rasterizer, m_kxsystem->GetTimeInSeconds(), true); m_logger->StartLog(tc_rasterizer, m_kxsystem->GetTimeInSeconds(), true);
@@ -609,7 +608,7 @@ bool KX_KetsjiEngine::NextFrame()
double deltatime = m_clockTime - m_frameTime; double deltatime = m_clockTime - m_frameTime;
if (deltatime<0.0) if (deltatime<0.0)
{ {
// We got here too quickly, which means there is nothing todo, just return and don't render. // We got here too quickly, which means there is nothing to do, just return and don't render.
// Not sure if this is the best fix, but it seems to stop the jumping framerate issue (#33088) // Not sure if this is the best fix, but it seems to stop the jumping framerate issue (#33088)
return false; return false;
} }
@@ -660,13 +659,13 @@ bool KX_KetsjiEngine::NextFrame()
* update. */ * update. */
m_logger->StartLog(tc_logic, m_kxsystem->GetTimeInSeconds(), true); m_logger->StartLog(tc_logic, m_kxsystem->GetTimeInSeconds(), true);
m_sceneconverter->resetNoneDynamicObjectToIpo();//this is for none dynamic objects with ipo m_sceneconverter->resetNoneDynamicObjectToIpo(); // this is for none dynamic objects with ipo
scene->UpdateObjectActivity(); scene->UpdateObjectActivity();
if (!scene->IsSuspended()) if (!scene->IsSuspended())
{ {
// if the scene was suspended recalcutlate the delta tu "curtime" // if the scene was suspended recalculate the delta tu "curtime"
m_suspendedtime = scene->getSuspendedTime(); m_suspendedtime = scene->getSuspendedTime();
if (scene->getSuspendedTime()!=0.0) if (scene->getSuspendedTime()!=0.0)
scene->setSuspendedDelta(scene->getSuspendedDelta()+m_clockTime-scene->getSuspendedTime()); scene->setSuspendedDelta(scene->getSuspendedDelta()+m_clockTime-scene->getSuspendedTime());
@@ -769,7 +768,7 @@ bool KX_KetsjiEngine::NextFrame()
frames--; frames--;
} }
// Start logging time spend outside main loop // Start logging time spent outside main loop
m_logger->StartLog(tc_outside, m_kxsystem->GetTimeInSeconds(), true); m_logger->StartLog(tc_outside, m_kxsystem->GetTimeInSeconds(), true);
return doRender; return doRender;
@@ -838,13 +837,13 @@ void KX_KetsjiEngine::Render()
// pass the scene's worldsettings to the rasterizer // pass the scene's worldsettings to the rasterizer
scene->GetWorldInfo()->UpdateWorldSettings(); scene->GetWorldInfo()->UpdateWorldSettings();
// this is now done incrementatlly in KX_Scene::CalculateVisibleMeshes // this is now done incrementally in KX_Scene::CalculateVisibleMeshes
//scene->UpdateMeshTransformations(); //scene->UpdateMeshTransformations();
// shadow buffers // shadow buffers
RenderShadowBuffers(scene); RenderShadowBuffers(scene);
// Avoid drawing the scene with the active camera twice when it's viewport is enabled // Avoid drawing the scene with the active camera twice when its viewport is enabled
if (cam && !cam->GetViewport()) if (cam && !cam->GetViewport())
{ {
if (scene->IsClearingZBuffer()) if (scene->IsClearingZBuffer())
@@ -898,7 +897,7 @@ void KX_KetsjiEngine::Render()
if (scene->IsClearingZBuffer()) if (scene->IsClearingZBuffer())
m_rasterizer->ClearDepthBuffer(); m_rasterizer->ClearDepthBuffer();
//pass the scene, for picking and raycasting (shadows) // pass the scene, for picking and raycasting (shadows)
m_rasterizer->SetAuxilaryClientInfo(scene); m_rasterizer->SetAuxilaryClientInfo(scene);
// do the rendering // do the rendering
@@ -948,10 +947,10 @@ void KX_KetsjiEngine::SetNameNextGame(const STR_String& nextgame)
int KX_KetsjiEngine::GetExitCode() int KX_KetsjiEngine::GetExitCode()
{ {
// if a gameactuator has set an exitcode or if there are no scenes left // if a game actuator has set an exit code or if there are no scenes left
if (!m_exitcode) if (!m_exitcode)
{ {
if (m_scenes.begin()==m_scenes.end()) if (m_scenes.begin() == m_scenes.end())
m_exitcode = KX_EXIT_REQUEST_NO_SCENES_LEFT; m_exitcode = KX_EXIT_REQUEST_NO_SCENES_LEFT;
} }
@@ -1017,9 +1016,8 @@ void KX_KetsjiEngine::SetCameraOverrideZoom(float camzoom)
void KX_KetsjiEngine::GetSceneViewport(KX_Scene *scene, KX_Camera* cam, RAS_Rect& area, RAS_Rect& viewport) void KX_KetsjiEngine::GetSceneViewport(KX_Scene *scene, KX_Camera* cam, RAS_Rect& area, RAS_Rect& viewport)
{ {
// In this function we make sure the rasterizer settings are upto // In this function we make sure the rasterizer settings are up-to-date.
// date. We compute the viewport so that logic // We compute the viewport so that logic using this information is up-to-date.
// using this information is upto date.
// Note we postpone computation of the projection matrix // Note we postpone computation of the projection matrix
// so that we are using the latest camera position. // so that we are using the latest camera position.
@@ -1171,7 +1169,7 @@ void KX_KetsjiEngine::RenderFrame(KX_Scene* scene, KX_Camera* cam)
if (override_camera && m_overrideCamUseOrtho) { if (override_camera && m_overrideCamUseOrtho) {
m_rasterizer->SetProjectionMatrix(m_overrideCamProjMat); m_rasterizer->SetProjectionMatrix(m_overrideCamProjMat);
if (!cam->hasValidProjectionMatrix()) { if (!cam->hasValidProjectionMatrix()) {
// needed to get frustrum planes for culling // needed to get frustum planes for culling
MT_Matrix4x4 projmat; MT_Matrix4x4 projmat;
projmat.setValue(m_overrideCamProjMat.getPointer()); projmat.setValue(m_overrideCamProjMat.getPointer());
cam->SetProjectionMatrix(projmat); cam->SetProjectionMatrix(projmat);
@@ -1280,7 +1278,7 @@ void KX_KetsjiEngine::RenderFrame(KX_Scene* scene, KX_Camera* cam)
scene->RenderBuckets(camtrans, m_rasterizer); scene->RenderBuckets(camtrans, m_rasterizer);
//render all the font objects for this scene // render all the font objects for this scene
scene->RenderFonts(); scene->RenderFonts();
if (scene->GetPhysicsEnvironment()) if (scene->GetPhysicsEnvironment())
@@ -1335,7 +1333,7 @@ void KX_KetsjiEngine::StopEngine()
} }
// Scene Management is able to switch between scenes // Scene Management is able to switch between scenes
// and have several scene's running in parallel // and have several scenes running in parallel
void KX_KetsjiEngine::AddScene(KX_Scene* scene) void KX_KetsjiEngine::AddScene(KX_Scene* scene)
{ {
m_scenes.push_back(scene); m_scenes.push_back(scene);
@@ -1351,7 +1349,7 @@ void KX_KetsjiEngine::PostProcessScene(KX_Scene* scene)
SG_SetActiveStage(SG_STAGE_SCENE); SG_SetActiveStage(SG_STAGE_SCENE);
// if there is no activecamera, or the camera is being // if there is no activecamera, or the camera is being
// overridden we need to construct a temporarily camera // overridden we need to construct a temporary camera
if (!scene->GetActiveCamera() || override_camera) if (!scene->GetActiveCamera() || override_camera)
{ {
KX_Camera* activecam = NULL; KX_Camera* activecam = NULL;
@@ -1368,7 +1366,7 @@ void KX_KetsjiEngine::PostProcessScene(KX_Scene* scene)
activecam = new KX_Camera(scene,KX_Scene::m_callbacks,camdata); activecam = new KX_Camera(scene,KX_Scene::m_callbacks,camdata);
activecam->SetName("__default__cam__"); activecam->SetName("__default__cam__");
// set transformation // set transformation
if (override_camera) { if (override_camera) {
const MT_CmMatrix4x4& cammatdata = m_overrideCamViewMat; const MT_CmMatrix4x4& cammatdata = m_overrideCamViewMat;
MT_Transform trans = MT_Transform(cammatdata.getPointer()); MT_Transform trans = MT_Transform(cammatdata.getPointer());
@@ -1388,7 +1386,7 @@ void KX_KetsjiEngine::PostProcessScene(KX_Scene* scene)
scene->SetActiveCamera(activecam); scene->SetActiveCamera(activecam);
scene->GetObjectList()->Add(activecam->AddRef()); scene->GetObjectList()->Add(activecam->AddRef());
scene->GetRootParentList()->Add(activecam->AddRef()); scene->GetRootParentList()->Add(activecam->AddRef());
//done with activecam // done with activecam
activecam->Release(); activecam->Release();
} }
@@ -1482,7 +1480,7 @@ void KX_KetsjiEngine::RenderDebugProperties()
// Add the ymargin for titles below the other section of debug info // Add the ymargin for titles below the other section of debug info
ycoord += title_y_top_margin; ycoord += title_y_top_margin;
/* Property display*/ /* Property display */
if (m_show_debug_properties) { if (m_show_debug_properties) {
/* Title for debugging("Debug properties") */ /* Title for debugging("Debug properties") */
@@ -1712,7 +1710,7 @@ void KX_KetsjiEngine::AddScheduledScenes()
bool KX_KetsjiEngine::ReplaceScene(const STR_String& oldscene,const STR_String& newscene) bool KX_KetsjiEngine::ReplaceScene(const STR_String& oldscene,const STR_String& newscene)
{ {
// Don't allow replacement if the new scene doesn't exists. // Don't allow replacement if the new scene doesn't exist.
// Allows smarter game design (used to have no check here). // Allows smarter game design (used to have no check here).
// Note that it creates a small backward compatbility issue // Note that it creates a small backward compatbility issue
// for a game that did a replace followed by a lib load with the // for a game that did a replace followed by a lib load with the
@@ -1799,7 +1797,7 @@ void KX_KetsjiEngine::SetAnimRecordMode(bool animation_record, int startFrame)
m_animation_record = animation_record; m_animation_record = animation_record;
if (animation_record) if (animation_record)
{ {
//when recording physics keyframes, run at a variable (capped) frame rate (fixed time == full speed) // when recording physics keyframes, run at a variable (capped) frame rate (fixed time == full speed)
m_bFixedTime = false; m_bFixedTime = false;
} }
m_currentFrame = startFrame; m_currentFrame = startFrame;
@@ -2043,12 +2041,12 @@ void KX_KetsjiEngine::Resize()
{ {
KX_SceneList::iterator sceneit; KX_SceneList::iterator sceneit;
/* extended mode needs to recalculate camera frustrums when */ /* extended mode needs to recalculate camera frusta when */
KX_Scene* firstscene = *m_scenes.begin(); KX_Scene* firstscene = *m_scenes.begin();
const RAS_FrameSettings &framesettings = firstscene->GetFramingType(); const RAS_FrameSettings &framesettings = firstscene->GetFramingType();
if (framesettings.FrameType() == RAS_FrameSettings::e_frame_extend) { if (framesettings.FrameType() == RAS_FrameSettings::e_frame_extend) {
for (sceneit = m_scenes.begin();sceneit != m_scenes.end(); sceneit++) { for (sceneit = m_scenes.begin(); sceneit != m_scenes.end(); sceneit++) {
KX_Camera* cam = ((KX_Scene *)*sceneit)->GetActiveCamera(); KX_Camera* cam = ((KX_Scene *)*sceneit)->GetActiveCamera();
cam->InvalidateProjectionMatrix(); cam->InvalidateProjectionMatrix();
} }

View File

@@ -125,7 +125,7 @@ void RAS_BucketManager::OrderBuckets(const MT_Transform& cameratrans, BucketList
{ {
RAS_MaterialBucket* bucket = *bit; RAS_MaterialBucket* bucket = *bit;
RAS_MeshSlot* ms; RAS_MeshSlot* ms;
// remove the mesh slot form the list, it culls them automatically for next frame // remove the mesh slot from the list, it culls them automatically for next frame
while ((ms = bucket->GetNextActiveMeshSlot())) { while ((ms = bucket->GetNextActiveMeshSlot())) {
slots[i++].set(ms, bucket, pnorm); slots[i++].set(ms, bucket, pnorm);
} }
@@ -157,7 +157,7 @@ void RAS_BucketManager::RenderAlphaBuckets(const MT_Transform& cameratrans, RAS_
sit->m_bucket->RenderMeshSlot(cameratrans, rasty, *(sit->m_ms)); sit->m_bucket->RenderMeshSlot(cameratrans, rasty, *(sit->m_ms));
// make this mesh slot culled automatically for next frame // make this mesh slot culled automatically for next frame
// it will be culled out by frustrum culling // it will be culled out by frustum culling
sit->m_ms->SetCulled(true); sit->m_ms->SetCulled(true);
} }
@@ -174,14 +174,14 @@ void RAS_BucketManager::RenderSolidBuckets(const MT_Transform& cameratrans, RAS_
#if 1 #if 1
RAS_MaterialBucket* bucket = *bit; RAS_MaterialBucket* bucket = *bit;
RAS_MeshSlot* ms; RAS_MeshSlot* ms;
// remove the mesh slot form the list, it culls them automatically for next frame // remove the mesh slot from the list, it culls them automatically for next frame
while ((ms = bucket->GetNextActiveMeshSlot())) { while ((ms = bucket->GetNextActiveMeshSlot())) {
rasty->SetClientObject(ms->m_clientObj); rasty->SetClientObject(ms->m_clientObj);
while (bucket->ActivateMaterial(cameratrans, rasty)) while (bucket->ActivateMaterial(cameratrans, rasty))
bucket->RenderMeshSlot(cameratrans, rasty, *ms); bucket->RenderMeshSlot(cameratrans, rasty, *ms);
// make this mesh slot culled automatically for next frame // make this mesh slot culled automatically for next frame
// it will be culled out by frustrum culling // it will be culled out by frustum culling
ms->SetCulled(true); ms->SetCulled(true);
} }
#else #else
@@ -196,7 +196,7 @@ void RAS_BucketManager::RenderSolidBuckets(const MT_Transform& cameratrans, RAS_
(*bit)->RenderMeshSlot(cameratrans, rasty, *mit); (*bit)->RenderMeshSlot(cameratrans, rasty, *mit);
// make this mesh slot culled automatically for next frame // make this mesh slot culled automatically for next frame
// it will be culled out by frustrum culling // it will be culled out by frustum culling
mit->SetCulled(true); mit->SetCulled(true);
} }
#endif #endif
@@ -367,7 +367,7 @@ void RAS_BucketManager::RemoveMaterial(RAS_IPolyMaterial * mat)
void RAS_BucketManager::MergeBucketManager(RAS_BucketManager *other, SCA_IScene *scene) void RAS_BucketManager::MergeBucketManager(RAS_BucketManager *other, SCA_IScene *scene)
{ {
/* concatinate lists */ /* concatenate lists */
// printf("BEFORE %d %d\n", GetSolidBuckets().size(), GetAlphaBuckets().size()); // printf("BEFORE %d %d\n", GetSolidBuckets().size(), GetAlphaBuckets().size());
GetSolidBuckets().insert( GetSolidBuckets().end(), other->GetSolidBuckets().begin(), other->GetSolidBuckets().end() ); GetSolidBuckets().insert( GetSolidBuckets().end(), other->GetSolidBuckets().begin(), other->GetSolidBuckets().end() );

View File

@@ -73,7 +73,7 @@ public :
}; };
/** /**
* Contructor * Constructor
*/ */
RAS_FrameSettings( RAS_FrameSettings(
@@ -221,7 +221,7 @@ public :
/** /**
* compute a frustrum given a valid viewport, * compute a frustum given a valid viewport,
* RAS_FrameSettings, canvas description * RAS_FrameSettings, canvas description
* and camera description * and camera description
*/ */

View File

@@ -244,7 +244,6 @@ bool RAS_OpenGLRasterizer::SetMaterial(const RAS_IPolyMaterial& mat)
void RAS_OpenGLRasterizer::Exit() void RAS_OpenGLRasterizer::Exit()
{ {
m_storage->Exit(); m_storage->Exit();
glEnable(GL_CULL_FACE); glEnable(GL_CULL_FACE);
@@ -363,7 +362,7 @@ void RAS_OpenGLRasterizer::FlushDebugShapes(SCA_IScene *scene)
if (light) glDisable(GL_LIGHTING); if (light) glDisable(GL_LIGHTING);
if (tex) glDisable(GL_TEXTURE_2D); if (tex) glDisable(GL_TEXTURE_2D);
//draw lines // draw lines
glBegin(GL_LINES); glBegin(GL_LINES);
for (unsigned int i = 0; i < debugShapes.size(); i++) { for (unsigned int i = 0; i < debugShapes.size(); i++) {
if (debugShapes[i].m_type != OglDebugShape::LINE) if (debugShapes[i].m_type != OglDebugShape::LINE)
@@ -376,7 +375,7 @@ void RAS_OpenGLRasterizer::FlushDebugShapes(SCA_IScene *scene)
} }
glEnd(); glEnd();
//draw circles // draw circles
for (unsigned int i = 0; i < debugShapes.size(); i++) { for (unsigned int i = 0; i < debugShapes.size(); i++) {
if (debugShapes[i].m_type != OglDebugShape::CIRCLE) if (debugShapes[i].m_type != OglDebugShape::CIRCLE)
continue; continue;
@@ -785,7 +784,7 @@ static DMDrawOption CheckTexDM(MTexPoly *mtexpoly, const bool has_mcol, int matn
void RAS_OpenGLRasterizer::DrawDerivedMesh(class RAS_MeshSlot &ms) void RAS_OpenGLRasterizer::DrawDerivedMesh(class RAS_MeshSlot &ms)
{ {
// mesh data is in derived mesh, // mesh data is in derived mesh
current_bucket = ms.m_bucket; current_bucket = ms.m_bucket;
current_polymat = current_bucket->GetPolyMaterial(); current_polymat = current_bucket->GetPolyMaterial();
current_ms = &ms; current_ms = &ms;
@@ -837,10 +836,9 @@ void RAS_OpenGLRasterizer::SetProjectionMatrix(const MT_Matrix4x4 & mat)
float matrix[16]; float matrix[16];
/* Get into argument. Looks a bit dodgy, but it's ok. */ /* Get into argument. Looks a bit dodgy, but it's ok. */
mat.getValue(matrix); mat.getValue(matrix);
/* Internally, MT_Matrix4x4 uses doubles (MT_Scalar). */
glLoadMatrixf(matrix); glLoadMatrixf(matrix);
m_camortho= (mat[3][3] != 0.0f); m_camortho = (mat[3][3] != 0.0f);
} }
MT_Matrix4x4 RAS_OpenGLRasterizer::GetFrustumMatrix( MT_Matrix4x4 RAS_OpenGLRasterizer::GetFrustumMatrix(
@@ -882,8 +880,8 @@ MT_Matrix4x4 RAS_OpenGLRasterizer::GetFrustumMatrix(
} }
// leave bottom and top untouched // leave bottom and top untouched
if (m_stereomode == RAS_STEREO_3DTVTOPBOTTOM) { if (m_stereomode == RAS_STEREO_3DTVTOPBOTTOM) {
// restore the vertical frustrum because the 3DTV will // restore the vertical frustum because the 3DTV will
// expande the top and bottom part to the full size of the screen // expand the top and bottom part to the full size of the screen
bottom *= 2.0f; bottom *= 2.0f;
top *= 2.0f; top *= 2.0f;
} }
@@ -910,7 +908,7 @@ MT_Matrix4x4 RAS_OpenGLRasterizer::GetOrthoMatrix(
MT_Matrix4x4 result; MT_Matrix4x4 result;
float mat[16]; float mat[16];
// stereo is meaning less for orthographic, disable it // stereo is meaningless for orthographic, disable it
glMatrixMode(GL_PROJECTION); glMatrixMode(GL_PROJECTION);
glLoadIdentity(); glLoadIdentity();
glOrtho(left, right, bottom, top, frustnear, frustfar); glOrtho(left, right, bottom, top, frustnear, frustfar);
@@ -1305,8 +1303,8 @@ bool RAS_OpenGLRasterizer::RayHit(struct KX_ClientObjectInfo *client, KX_RayCast
float maat[16] = {left[0], left[1], left[2], 0, float maat[16] = {left[0], left[1], left[2], 0,
dir[0], dir[1], dir[2], 0, dir[0], dir[1], dir[2], 0,
resultnormal[0], resultnormal[1], resultnormal[2], 0, resultnormal[0], resultnormal[1], resultnormal[2], 0,
0, 0, 0, 1}; 0, 0, 0, 1};
glTranslatef(oglmatrix[12],oglmatrix[13],oglmatrix[14]); glTranslatef(oglmatrix[12],oglmatrix[13],oglmatrix[14]);
//glMultMatrixd(oglmatrix); //glMultMatrixd(oglmatrix);
@@ -1480,7 +1478,7 @@ void RAS_OpenGLRasterizer::RenderBox2D(int xco,
yco = height - yco; yco = height - yco;
int barsize = 50; int barsize = 50;
/* draw in black first*/ /* draw in black first */
glColor3ub(0, 0, 0); glColor3ub(0, 0, 0);
glBegin(GL_QUADS); glBegin(GL_QUADS);
glVertex2f(xco + 1 + 1 + barsize * percentage, yco - 1 + 10); glVertex2f(xco + 1 + 1 + barsize * percentage, yco - 1 + 10);
@@ -1518,9 +1516,9 @@ void RAS_OpenGLRasterizer::RenderText3D(
BLF_enable(fontid, BLF_MATRIX|BLF_ASPECT); BLF_enable(fontid, BLF_MATRIX|BLF_ASPECT);
BLF_matrix(fontid, mat); BLF_matrix(fontid, mat);
/* aspect is the inverse scale that allows you to increase */ /* aspect is the inverse scale that allows you to increase
/* your resolution without sizing the final text size */ * your resolution without sizing the final text size
/* the bigger the size, the smaller the aspect */ * the bigger the size, the smaller the aspect */
BLF_aspect(fontid, aspect, aspect, aspect); BLF_aspect(fontid, aspect, aspect, aspect);
BLF_size(fontid, size, dpi); BLF_size(fontid, size, dpi);
@@ -1553,7 +1551,7 @@ void RAS_OpenGLRasterizer::RenderText2D(
glLoadIdentity(); glLoadIdentity();
if (mode == RAS_TEXT_PADDED) { if (mode == RAS_TEXT_PADDED) {
/* draw in black first*/ /* draw in black first */
glColor3ub(0, 0, 0); glColor3ub(0, 0, 0);
BLF_size(blf_mono_font, 11, 72); BLF_size(blf_mono_font, 11, 72);
BLF_position(blf_mono_font, (float)xco+1, (float)(height-yco-1), 0.0f); BLF_position(blf_mono_font, (float)xco+1, (float)(height-yco-1), 0.0f);
@@ -1592,7 +1590,7 @@ void RAS_OpenGLRasterizer::MotionBlur()
motionblurvalue = GetMotionBlurValue(); motionblurvalue = GetMotionBlurValue();
if (state==1) if (state==1)
{ {
//bugfix:load color buffer into accum buffer for the first time(state=1) // bugfix:load color buffer into accum buffer for the first time(state=1)
glAccum(GL_LOAD, 1.0f); glAccum(GL_LOAD, 1.0f);
SetMotionBlurState(2); SetMotionBlurState(2);
} }

View File

@@ -141,14 +141,14 @@ void ImageRender::calcImage (unsigned int texId, double ts)
void ImageRender::Render() void ImageRender::Render()
{ {
RAS_FrameFrustum frustrum; RAS_FrameFrustum frustum;
if (!m_render) if (!m_render)
return; return;
if (m_mirror) if (m_mirror)
{ {
// mirror mode, compute camera frustrum, position and orientation // mirror mode, compute camera frustum, position and orientation
// convert mirror position and normal in world space // convert mirror position and normal in world space
const MT_Matrix3x3 & mirrorObjWorldOri = m_mirror->GetSGNode()->GetWorldOrientation(); const MT_Matrix3x3 & mirrorObjWorldOri = m_mirror->GetSGNode()->GetWorldOrientation();
const MT_Point3 & mirrorObjWorldPos = m_mirror->GetSGNode()->GetWorldPosition(); const MT_Point3 & mirrorObjWorldPos = m_mirror->GetSGNode()->GetWorldPosition();
@@ -177,7 +177,7 @@ void ImageRender::Render()
mirrorWorldX[2], mirrorWorldY[2], mirrorWorldZ[2]); mirrorWorldX[2], mirrorWorldY[2], mirrorWorldZ[2]);
m_camera->GetSGNode()->SetLocalOrientation(cameraWorldOri); m_camera->GetSGNode()->SetLocalOrientation(cameraWorldOri);
m_camera->GetSGNode()->UpdateWorldData(0.0); m_camera->GetSGNode()->UpdateWorldData(0.0);
// compute camera frustrum: // compute camera frustum:
// get position of mirror relative to camera: offset = mirrorPos-cameraPos // get position of mirror relative to camera: offset = mirrorPos-cameraPos
MT_Vector3 mirrorOffset = mirrorWorldPos - cameraWorldPos; MT_Vector3 mirrorOffset = mirrorWorldPos - cameraWorldPos;
// convert to camera orientation // convert to camera orientation
@@ -203,12 +203,12 @@ void ImageRender::Render()
// bottom = offsety-height // bottom = offsety-height
// near = -offsetz // near = -offsetz
// far = near+100 // far = near+100
frustrum.x1 = mirrorOffset[0]-width; frustum.x1 = mirrorOffset[0]-width;
frustrum.x2 = mirrorOffset[0]+width; frustum.x2 = mirrorOffset[0]+width;
frustrum.y1 = mirrorOffset[1]-height; frustum.y1 = mirrorOffset[1]-height;
frustrum.y2 = mirrorOffset[1]+height; frustum.y2 = mirrorOffset[1]+height;
frustrum.camnear = -mirrorOffset[2]; frustum.camnear = -mirrorOffset[2];
frustrum.camfar = -mirrorOffset[2]+m_clip; frustum.camfar = -mirrorOffset[2]+m_clip;
} }
// Store settings to be restored later // Store settings to be restored later
const RAS_IRasterizer::StereoMode stereomode = m_rasterizer->GetStereoMode(); const RAS_IRasterizer::StereoMode stereomode = m_rasterizer->GetStereoMode();
@@ -226,10 +226,10 @@ void ImageRender::Render()
m_rasterizer->SetStereoMode(RAS_IRasterizer::RAS_STEREO_NOSTEREO); m_rasterizer->SetStereoMode(RAS_IRasterizer::RAS_STEREO_NOSTEREO);
if (m_mirror) if (m_mirror)
{ {
// frustrum was computed above // frustum was computed above
// get frustrum matrix and set projection matrix // get frustum matrix and set projection matrix
MT_Matrix4x4 projmat = m_rasterizer->GetFrustumMatrix( MT_Matrix4x4 projmat = m_rasterizer->GetFrustumMatrix(
frustrum.x1, frustrum.x2, frustrum.y1, frustrum.y2, frustrum.camnear, frustrum.camfar); frustum.x1, frustum.x2, frustum.y1, frustum.y2, frustum.camnear, frustum.camfar);
m_camera->SetProjectionMatrix(projmat); m_camera->SetProjectionMatrix(projmat);
} }
@@ -264,11 +264,11 @@ void ImageRender::Render()
m_camera->GetSensorFit(), m_camera->GetSensorFit(),
shift_x, shift_x,
shift_y, shift_y,
frustrum frustum
); );
projmat = m_rasterizer->GetOrthoMatrix( projmat = m_rasterizer->GetOrthoMatrix(
frustrum.x1, frustrum.x2, frustrum.y1, frustrum.y2, frustrum.camnear, frustrum.camfar); frustum.x1, frustum.x2, frustum.y1, frustum.y2, frustum.camnear, frustum.camfar);
} }
else { else {
RAS_FramingManager::ComputeDefaultFrustum( RAS_FramingManager::ComputeDefaultFrustum(
@@ -281,10 +281,10 @@ void ImageRender::Render()
shift_x, shift_x,
shift_y, shift_y,
aspect_ratio, aspect_ratio,
frustrum); frustum);
projmat = m_rasterizer->GetFrustumMatrix( projmat = m_rasterizer->GetFrustumMatrix(
frustrum.x1, frustrum.x2, frustrum.y1, frustrum.y2, frustrum.camnear, frustrum.camfar); frustum.x1, frustum.x2, frustum.y1, frustum.y2, frustum.camnear, frustum.camfar);
} }
m_camera->SetProjectionMatrix(projmat); m_camera->SetProjectionMatrix(projmat);
} }
@@ -548,7 +548,7 @@ static int ImageMirror_init(PyObject *pySelf, PyObject *args, PyObject *kwds)
exp.report(); exp.report();
return -1; return -1;
} }
// initialization succeded // initialization succeeded
return 0; return 0;
} }
@@ -607,7 +607,7 @@ ImageRender::ImageRender (KX_Scene *scene, KX_GameObject *observer, KX_GameObjec
m_clip(100.f) m_clip(100.f)
{ {
// this constructor is used for automatic planar mirror // this constructor is used for automatic planar mirror
// create a camera, take all data by default, in any case we will recompute the frustrum on each frame // create a camera, take all data by default, in any case we will recompute the frustum on each frame
RAS_CameraData camdata; RAS_CameraData camdata;
vector<RAS_TexVert*> mirrorVerts; vector<RAS_TexVert*> mirrorVerts;
vector<RAS_TexVert*>::iterator it; vector<RAS_TexVert*>::iterator it;
@@ -641,7 +641,7 @@ ImageRender::ImageRender (KX_Scene *scene, KX_GameObject *observer, KX_GameObjec
RAS_TexVert *v1, *v2, *v3, *v4; RAS_TexVert *v1, *v2, *v3, *v4;
float normal[3]; float normal[3];
float area; float area;
// this polygon is part of the mirror, // this polygon is part of the mirror
v1 = polygon->GetVertex(0); v1 = polygon->GetVertex(0);
v2 = polygon->GetVertex(1); v2 = polygon->GetVertex(1);
v3 = polygon->GetVertex(2); v3 = polygon->GetVertex(2);