Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBrecht Van Lommel <brechtvanlommel@pandora.be>2008-09-05 00:51:28 +0400
committerBrecht Van Lommel <brechtvanlommel@pandora.be>2008-09-05 00:51:28 +0400
commitcb89decfdcf5e6b2f26376d416633f4ccf0c532d (patch)
treea299a5c8729dd0cb4359d57501fd9e6970141e5d /source/gameengine/Ketsji/KX_Light.cpp
parent2167e5c341f656b2f664b1052d181e8aa32fe698 (diff)
Merge of first part of changes from the apricot branch, especially
the features that are needed to run the game. Compile tested with scons, make, but not cmake, that seems to have an issue not related to these changes. The changes include: * GLSL support in the viewport and game engine, enable in the game menu in textured draw mode. * Synced and merged part of the duplicated blender and gameengine/ gameplayer drawing code. * Further refactoring of game engine drawing code, especially mesh storage changed a lot. * Optimizations in game engine armatures to avoid recomputations. * A python function to get the framerate estimate in game. * An option take object color into account in materials. * An option to restrict shadow casters to a lamp's layers. * Increase from 10 to 18 texture slots for materials, lamps, word. An extra texture slot shows up once the last slot is used. * Memory limit for undo, not enabled by default yet because it needs the .B.blend to be changed. * Multiple undo for image painting. * An offset for dupligroups, so not all objects in a group have to be at the origin.
Diffstat (limited to 'source/gameengine/Ketsji/KX_Light.cpp')
-rw-r--r--source/gameengine/Ketsji/KX_Light.cpp57
1 files changed, 33 insertions, 24 deletions
diff --git a/source/gameengine/Ketsji/KX_Light.cpp b/source/gameengine/Ketsji/KX_Light.cpp
index 4e3d6180d22..6cfe5610863 100644
--- a/source/gameengine/Ketsji/KX_Light.cpp
+++ b/source/gameengine/Ketsji/KX_Light.cpp
@@ -42,14 +42,13 @@
#include "KX_PyMath.h"
-#ifdef BLENDER_GLSL
+#include "DNA_object_types.h"
#include "GPU_material.h"
-#endif
KX_LightObject::KX_LightObject(void* sgReplicationInfo,SG_Callbacks callbacks,
class RAS_IRenderTools* rendertools,
const RAS_LightObject& lightobj,
- struct GPULamp *gpulamp,
+ bool glsl,
PyTypeObject* T
)
:
@@ -59,7 +58,8 @@ KX_LightObject::KX_LightObject(void* sgReplicationInfo,SG_Callbacks callbacks,
m_lightobj = lightobj;
m_lightobj.m_worldmatrix = GetOpenGLMatrixPtr();
m_rendertools->AddLight(&m_lightobj);
- m_gpulamp = gpulamp;
+ m_glsl = glsl;
+ m_blenderscene = ((KX_Scene*)sgReplicationInfo)->GetBlenderScene();
};
@@ -73,7 +73,7 @@ CValue* KX_LightObject::GetReplica()
{
KX_LightObject* replica = new KX_LightObject(*this);
-
+
// this will copy properties and so on...
CValue::AddDataToReplica(replica);
@@ -81,13 +81,23 @@ CValue* KX_LightObject::GetReplica()
replica->m_lightobj.m_worldmatrix = replica->GetOpenGLMatrixPtr();
m_rendertools->AddLight(&replica->m_lightobj);
+
return replica;
}
+GPULamp *KX_LightObject::GetGPULamp()
+{
+ if(m_glsl)
+ return GPU_lamp_from_blender(m_blenderscene, GetBlenderObject(), GetBlenderGroupObject());
+ else
+ return false;
+}
+
void KX_LightObject::Update()
{
-#ifdef BLENDER_GLSL
- if(m_gpulamp) {
+ GPULamp *lamp;
+
+ if((lamp = GetGPULamp())) {
float obmat[4][4];
double *dobmat = GetOpenGLMatrixPtr()->getPointer();
@@ -95,38 +105,39 @@ void KX_LightObject::Update()
for(int j=0; j<4; j++, dobmat++)
obmat[i][j] = (float)*dobmat;
- GPU_lamp_update(m_gpulamp, obmat);
+ GPU_lamp_update(lamp, obmat);
}
-#endif
}
bool KX_LightObject::HasShadowBuffer()
{
-#ifdef BLENDER_GLSL
- return (m_gpulamp && GPU_lamp_has_shadow_buffer(m_gpulamp));
-#else
- return false;
-#endif
+ GPULamp *lamp;
+
+ if((lamp = GetGPULamp()))
+ return GPU_lamp_has_shadow_buffer(lamp);
+ else
+ return false;
}
int KX_LightObject::GetShadowLayer()
{
-#ifdef BLENDER_GLSL
- if(m_gpulamp)
- return GPU_lamp_shadow_layer(m_gpulamp);
+ GPULamp *lamp;
+
+ if((lamp = GetGPULamp()))
+ return GPU_lamp_shadow_layer(lamp);
else
-#endif
return 0;
}
void KX_LightObject::BindShadowBuffer(RAS_IRasterizer *ras, KX_Camera *cam, MT_Transform& camtrans)
{
-#ifdef BLENDER_GLSL
+ GPULamp *lamp;
float viewmat[4][4], winmat[4][4];
int winsize;
/* bind framebuffer */
- GPU_lamp_shadow_buffer_bind(m_gpulamp, viewmat, &winsize, winmat);
+ lamp = GetGPULamp();
+ GPU_lamp_shadow_buffer_bind(lamp, viewmat, &winsize, winmat);
/* setup camera transformation */
MT_Matrix4x4 modelviewmat((float*)viewmat);
@@ -146,14 +157,12 @@ void KX_LightObject::BindShadowBuffer(RAS_IRasterizer *ras, KX_Camera *cam, MT_T
ras->SetProjectionMatrix(projectionmat);
ras->SetViewMatrix(modelviewmat, cam->NodeGetWorldPosition(),
cam->GetCameraLocation(), cam->GetCameraOrientation());
-#endif
}
void KX_LightObject::UnbindShadowBuffer(RAS_IRasterizer *ras)
{
-#ifdef BLENDER_GLSL
- GPU_lamp_shadow_buffer_unbind(m_gpulamp);
-#endif
+ GPULamp *lamp = GetGPULamp();
+ GPU_lamp_shadow_buffer_unbind(lamp);
}
PyObject* KX_LightObject::_getattr(const STR_String& attr)