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.
This commit is contained in:
Brecht Van Lommel
2008-09-04 20:51:28 +00:00
parent 2167e5c341
commit cb89decfdc
258 changed files with 13813 additions and 5271 deletions

View File

@@ -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)