svn merge https://svn.blender.org/svnroot/bf-blender/trunk/blender -r19820:HEAD

Notes:
* Game and sequencer RNA, and sequencer header are now out of date
  a bit after changes in trunk.
* I didn't know how to port these bugfixes, most likely they are
  not needed anymore.
  * Fix "duplicate strip" always increase the user count for ipo.
  * IPO pinning on sequencer strips was lost during Undo.
This commit is contained in:
Brecht Van Lommel
2009-06-08 20:08:19 +00:00
594 changed files with 28292 additions and 13753 deletions

View File

@@ -31,8 +31,14 @@ SET(INC
../../../../intern/string
../../../../intern/moto/include
../../../../source/gameengine/Rasterizer
../../../../source/gameengine/Ketsji
../../../../source/gameengine/SceneGraph
../../../../extern/glew/include
../../../../source/blender/gpu
../../../../source/blender/makesdna
../../../../source/blender/blenkernel
../../../../source/blender/blenlib
../../../../source/blender/blenloader
)
BLENDERLIB(bf_oglrasterizer "${SRC}" "${INC}")

View File

@@ -42,8 +42,14 @@ CPPFLAGS += -I$(NAN_STRING)/include
CPPFLAGS += -I$(NAN_MOTO)/include
CPPFLAGS += -I../../../kernel/gen_system
CPPFLAGS += -I../../../blender/gpu
CPPFLAGS += -I../../../blender/makesdna
CPPFLAGS += -I../../../blender/blenlib
CPPFLAGS += -I../../../blender/blenkernel
CPPFLAGS += -I../../BlenderRoutines
CPPFLAGS += -I../../Ketsji
CPPFLAGS += -I../../SceneGraph
CPPFLAGS += -I..
CPPFLAGS += -I$(NAN_GUARDEDALLOC)/include
ifeq ($(OS),darwin)
CPPFLAGS += -fpascal-strings

View File

@@ -104,9 +104,11 @@ bool RAS_ListSlot::End()
RAS_ListRasterizer::RAS_ListRasterizer(RAS_ICanvas* canvas, bool useVertexArrays, bool lock)
: RAS_VAOpenGLRasterizer(canvas, lock),
mUseVertexArrays(useVertexArrays)
mUseVertexArrays(useVertexArrays),
mATI(false)
{
// --
if (!strcmp((const char*)glGetString(GL_VENDOR), "ATI Technologies Inc."))
mATI = true;
}
RAS_ListRasterizer::~RAS_ListRasterizer()
@@ -116,13 +118,24 @@ RAS_ListRasterizer::~RAS_ListRasterizer()
void RAS_ListRasterizer::RemoveListSlot(RAS_ListSlot* list)
{
RAS_Lists::iterator it = mLists.begin();
while(it != mLists.end()) {
if (it->second == list) {
mLists.erase(it);
break;
if (list->m_flag & LIST_DERIVEDMESH) {
RAS_DerivedMeshLists::iterator it = mDerivedMeshLists.begin();
while(it != mDerivedMeshLists.end()) {
if (it->second == list) {
mDerivedMeshLists.erase(it);
break;
}
it++;
}
} else {
RAS_ArrayLists::iterator it = mArrayLists.begin();
while(it != mArrayLists.end()) {
if (it->second == list) {
mArrayLists.erase(it);
break;
}
it++;
}
it++;
}
}
@@ -136,12 +149,25 @@ RAS_ListSlot* RAS_ListRasterizer::FindOrAdd(RAS_MeshSlot& ms)
*/
RAS_ListSlot* localSlot = (RAS_ListSlot*)ms.m_DisplayList;
if(!localSlot) {
RAS_Lists::iterator it = mLists.find(ms.m_displayArrays);
if(it == mLists.end()) {
localSlot = new RAS_ListSlot(this);
mLists.insert(std::pair<RAS_DisplayArrayList, RAS_ListSlot*>(ms.m_displayArrays, localSlot));
if (ms.m_pDerivedMesh) {
// that means that we draw based on derived mesh, a display list is possible
// Note that we come here only for static derived mesh
RAS_DerivedMeshLists::iterator it = mDerivedMeshLists.find(ms.m_pDerivedMesh);
if(it == mDerivedMeshLists.end()) {
localSlot = new RAS_ListSlot(this);
localSlot->m_flag |= LIST_DERIVEDMESH;
mDerivedMeshLists.insert(std::pair<DerivedMesh*, RAS_ListSlot*>(ms.m_pDerivedMesh, localSlot));
} else {
localSlot = static_cast<RAS_ListSlot*>(it->second->AddRef());
}
} else {
localSlot = static_cast<RAS_ListSlot*>(it->second->AddRef());
RAS_ArrayLists::iterator it = mArrayLists.find(ms.m_displayArrays);
if(it == mArrayLists.end()) {
localSlot = new RAS_ListSlot(this);
mArrayLists.insert(std::pair<RAS_DisplayArrayList, RAS_ListSlot*>(ms.m_displayArrays, localSlot));
} else {
localSlot = static_cast<RAS_ListSlot*>(it->second->AddRef());
}
}
}
MT_assert(localSlot);
@@ -150,12 +176,12 @@ RAS_ListSlot* RAS_ListRasterizer::FindOrAdd(RAS_MeshSlot& ms)
void RAS_ListRasterizer::ReleaseAlloc()
{
RAS_Lists::iterator it = mLists.begin();
while(it != mLists.end()) {
for(RAS_ArrayLists::iterator it = mArrayLists.begin();it != mArrayLists.end();++it)
delete it->second;
it++;
}
mLists.clear();
mArrayLists.clear();
for (RAS_DerivedMeshLists::iterator it = mDerivedMeshLists.begin();it != mDerivedMeshLists.end();++it)
delete it->second;
mDerivedMeshLists.clear();
}
void RAS_ListRasterizer::IndexPrimitives(RAS_MeshSlot& ms)
@@ -172,8 +198,8 @@ void RAS_ListRasterizer::IndexPrimitives(RAS_MeshSlot& ms)
return;
}
}
if (mUseVertexArrays)
// derived mesh cannot use vertex array
if (mUseVertexArrays && !ms.m_pDerivedMesh)
RAS_VAOpenGLRasterizer::IndexPrimitives(ms);
else
RAS_OpenGLRasterizer::IndexPrimitives(ms);
@@ -204,7 +230,7 @@ void RAS_ListRasterizer::IndexPrimitivesMulti(RAS_MeshSlot& ms)
// workaround: note how we do not use vertex arrays for making display
// lists, since glVertexAttribPointerARB doesn't seem to work correct
// in display lists on ATI? either a bug in the driver or in Blender ..
if (mUseVertexArrays && !localSlot)
if (mUseVertexArrays && !mATI && !ms.m_pDerivedMesh)
RAS_VAOpenGLRasterizer::IndexPrimitivesMulti(ms);
else
RAS_OpenGLRasterizer::IndexPrimitivesMulti(ms);

View File

@@ -9,6 +9,7 @@
class RAS_ListRasterizer;
class RAS_ListSlot : public KX_ListSlot
{
friend class RAS_ListRasterizer;
unsigned int m_list;
unsigned int m_flag;
RAS_ListRasterizer* m_rasty;
@@ -32,15 +33,21 @@ enum RAS_ListSlotFlags {
LIST_NOCREATE =8,
LIST_BEGIN =16,
LIST_END =32,
LIST_REGEN =64
LIST_REGEN =64,
LIST_DERIVEDMESH=128,
};
typedef std::map<RAS_DisplayArrayList, RAS_ListSlot*> RAS_Lists;
struct DerivedMesh;
typedef std::map<RAS_DisplayArrayList, RAS_ListSlot*> RAS_ArrayLists;
typedef std::map<DerivedMesh*, RAS_ListSlot*> RAS_DerivedMeshLists;
class RAS_ListRasterizer : public RAS_VAOpenGLRasterizer
{
bool mUseVertexArrays;
RAS_Lists mLists;
bool mATI;
RAS_ArrayLists mArrayLists;
RAS_DerivedMeshLists mDerivedMeshLists;
RAS_ListSlot* FindOrAdd(class RAS_MeshSlot& ms);
void ReleaseAlloc();

View File

@@ -35,11 +35,20 @@
#include "RAS_Rect.h"
#include "RAS_TexVert.h"
#include "RAS_MeshObject.h"
#include "MT_CmMatrix4x4.h"
#include "RAS_IRenderTools.h" // rendering text
#include "GPU_draw.h"
#include "GPU_material.h"
#include "GPU_extensions.h"
#include "DNA_image_types.h"
#include "DNA_meshdata_types.h"
#include "DNA_material_types.h"
#include "DNA_scene_types.h"
#include "BKE_DerivedMesh.h"
/**
* 32x32 bit masks for vinterlace stereo mode
@@ -72,7 +81,7 @@ RAS_OpenGLRasterizer::RAS_OpenGLRasterizer(RAS_ICanvas* canvas)
m_motionblurvalue(-1.0),
m_texco_num(0),
m_attrib_num(0),
m_last_blendmode(GPU_BLEND_SOLID),
//m_last_blendmode(GPU_BLEND_SOLID),
m_last_frontface(true),
m_materialCachingInfo(0)
{
@@ -109,7 +118,8 @@ bool RAS_OpenGLRasterizer::Init()
glDisable(GL_BLEND);
glDisable(GL_ALPHA_TEST);
m_last_blendmode = GPU_BLEND_SOLID;
//m_last_blendmode = GPU_BLEND_SOLID;
GPU_set_material_blend_mode(GPU_BLEND_SOLID);
glFrontFace(GL_CCW);
m_last_frontface = true;
@@ -201,6 +211,10 @@ void RAS_OpenGLRasterizer::DisableFog()
m_fogenabled = false;
}
bool RAS_OpenGLRasterizer::IsFogEnabled()
{
return m_fogenabled;
}
void RAS_OpenGLRasterizer::DisplayFog()
@@ -275,7 +289,8 @@ bool RAS_OpenGLRasterizer::BeginFrame(int drawingmode, double time)
glDisable(GL_BLEND);
glDisable(GL_ALPHA_TEST);
m_last_blendmode = GPU_BLEND_SOLID;
//m_last_blendmode = GPU_BLEND_SOLID;
GPU_set_material_blend_mode(GPU_BLEND_SOLID);
glFrontFace(GL_CCW);
m_last_frontface = true;
@@ -703,6 +718,51 @@ void RAS_OpenGLRasterizer::IndexPrimitivesMulti(RAS_MeshSlot& ms)
IndexPrimitivesInternal(ms, true);
}
static bool current_wireframe;
static RAS_MaterialBucket *current_bucket;
static RAS_IPolyMaterial *current_polymat;
static RAS_MeshSlot *current_ms;
static RAS_MeshObject *current_mesh;
static int current_blmat_nr;
static GPUVertexAttribs current_gpu_attribs;
static int CheckMaterialDM(int matnr, void *attribs)
{
// only draw the current material
if (matnr != current_blmat_nr)
return 0;
GPUVertexAttribs *gattribs = (GPUVertexAttribs *)attribs;
if (gattribs)
memcpy(gattribs, &current_gpu_attribs, sizeof(GPUVertexAttribs));
return 1;
}
static int CheckTexfaceDM(void *mcol, int index)
{
// index is the original face index, retrieve the polygon
RAS_Polygon* polygon = (index >= 0 && index < current_mesh->NumPolygons()) ?
current_mesh->GetPolygon(index) : NULL;
if (polygon && polygon->GetMaterial() == current_bucket) {
// must handle color.
if (current_wireframe)
return 2;
if (current_ms->m_bObjectColor) {
MT_Vector4& rgba = current_ms->m_RGBAcolor;
glColor4d(rgba[0], rgba[1], rgba[2], rgba[3]);
// don't use mcol
return 2;
}
if (!mcol) {
// we have to set the color from the material
unsigned char rgba[4];
current_polymat->GetMaterialRGBAColor(rgba);
glColor4ubv((const GLubyte *)rgba);
return 2;
}
return 1;
}
return 0;
}
void RAS_OpenGLRasterizer::IndexPrimitivesInternal(RAS_MeshSlot& ms, bool multi)
{
bool obcolor = ms.m_bObjectColor;
@@ -710,6 +770,34 @@ void RAS_OpenGLRasterizer::IndexPrimitivesInternal(RAS_MeshSlot& ms, bool multi)
MT_Vector4& rgba = ms.m_RGBAcolor;
RAS_MeshSlot::iterator it;
if (ms.m_pDerivedMesh) {
// mesh data is in derived mesh,
current_bucket = ms.m_bucket;
current_polymat = current_bucket->GetPolyMaterial();
current_ms = &ms;
current_mesh = ms.m_mesh;
current_wireframe = wireframe;
MCol *mcol = (MCol*)ms.m_pDerivedMesh->getFaceDataArray(ms.m_pDerivedMesh, CD_MCOL);
if (current_polymat->GetFlag() & RAS_BLENDERGLSL) {
// GetMaterialIndex return the original mface material index,
// increment by 1 to match what derived mesh is doing
current_blmat_nr = current_polymat->GetMaterialIndex()+1;
// For GLSL we need to retrieve the GPU material attribute
Material* blmat = current_polymat->GetBlenderMaterial();
Scene* blscene = current_polymat->GetBlenderScene();
if (!wireframe && blscene && blmat)
GPU_material_vertex_attributes(GPU_material_from_blender(blscene, blmat), &current_gpu_attribs);
else
memset(&current_gpu_attribs, 0, sizeof(current_gpu_attribs));
// DM draw can mess up blending mode, restore at the end
int current_blend_mode = GPU_get_material_blend_mode();
ms.m_pDerivedMesh->drawFacesGLSL(ms.m_pDerivedMesh, CheckMaterialDM);
GPU_set_material_blend_mode(current_blend_mode);
} else {
ms.m_pDerivedMesh->drawMappedFacesTex(ms.m_pDerivedMesh, CheckTexfaceDM, mcol);
}
return;
}
// iterate over display arrays, each containing an index + vertex array
for(ms.begin(it); !ms.end(it); ms.next(it)) {
RAS_TexVert *vertex;
@@ -838,17 +926,40 @@ MT_Matrix4x4 RAS_OpenGLRasterizer::GetFrustumMatrix(
return result;
}
MT_Matrix4x4 RAS_OpenGLRasterizer::GetOrthoMatrix(
float left,
float right,
float bottom,
float top,
float frustnear,
float frustfar
){
MT_Matrix4x4 result;
double mat[16];
// stereo is meaning less for orthographic, disable it
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
glOrtho(left, right, bottom, top, frustnear, frustfar);
glGetDoublev(GL_PROJECTION_MATRIX, mat);
result.setValue(mat);
return result;
}
// next arguments probably contain redundant info, for later...
void RAS_OpenGLRasterizer::SetViewMatrix(const MT_Matrix4x4 &mat, const MT_Vector3& campos,
const MT_Point3 &, const MT_Quaternion &camOrientQuat)
void RAS_OpenGLRasterizer::SetViewMatrix(const MT_Matrix4x4 &mat,
const MT_Matrix3x3 & camOrientMat3x3,
const MT_Point3 & pos,
bool perspective)
{
m_viewmatrix = mat;
// correction for stereo
if(Stereo())
if(Stereo() && perspective)
{
MT_Matrix3x3 camOrientMat3x3(camOrientQuat);
MT_Vector3 unitViewDir(0.0, -1.0, 0.0); // minus y direction, Blender convention
MT_Vector3 unitViewupVec(0.0, 0.0, 1.0);
MT_Vector3 viewDir, viewupVec;
@@ -894,7 +1005,7 @@ void RAS_OpenGLRasterizer::SetViewMatrix(const MT_Matrix4x4 &mat, const MT_Vecto
glMatrixMode(GL_MODELVIEW);
glLoadMatrixd(glviewmat);
m_campos = campos;
m_campos = pos;
}
@@ -990,6 +1101,8 @@ void RAS_OpenGLRasterizer::DisableMotionBlur()
void RAS_OpenGLRasterizer::SetBlendingMode(int blendmode)
{
GPU_set_material_blend_mode(blendmode);
/*
if(blendmode == m_last_blendmode)
return;
@@ -1016,6 +1129,7 @@ void RAS_OpenGLRasterizer::SetBlendingMode(int blendmode)
}
m_last_blendmode = blendmode;
*/
}
void RAS_OpenGLRasterizer::SetFrontFace(bool ccw)

View File

@@ -100,7 +100,7 @@ protected:
TexCoGen m_attrib[RAS_MAX_ATTRIB];
int m_texco_num;
int m_attrib_num;
int m_last_blendmode;
//int m_last_blendmode;
bool m_last_frontface;
/** Stores the caching information for the last material activated. */
@@ -163,9 +163,9 @@ public:
virtual void SetProjectionMatrix(const MT_Matrix4x4 & mat);
virtual void SetViewMatrix(
const MT_Matrix4x4 & mat,
const MT_Vector3& campos,
const MT_Point3 &camLoc,
const MT_Quaternion &camOrientQuat
const MT_Matrix3x3 & ori,
const MT_Point3 & pos,
bool perspective
);
virtual const MT_Point3& GetCameraPosition();
@@ -190,6 +190,7 @@ public:
void DisableFog();
virtual void DisplayFog();
virtual bool IsFogEnabled();
virtual void SetBackColor(
float red,
@@ -215,6 +216,15 @@ public:
bool perspective
);
virtual MT_Matrix4x4 GetOrthoMatrix(
float left,
float right,
float bottom,
float top,
float frustnear,
float frustfar
);
virtual void SetSpecularity(
float specX,
float specY,

View File

@@ -110,6 +110,12 @@ void RAS_VAOpenGLRasterizer::IndexPrimitives(RAS_MeshSlot& ms)
RAS_MeshSlot::iterator it;
GLenum drawmode;
if (ms.m_pDerivedMesh) {
// cannot be handled here, pass to RAS_OpenGLRasterizer
RAS_OpenGLRasterizer::IndexPrimitivesInternal(ms, false);
return;
}
if(!wireframe)
glEnableClientState(GL_TEXTURE_COORD_ARRAY);
@@ -167,6 +173,12 @@ void RAS_VAOpenGLRasterizer::IndexPrimitivesMulti(RAS_MeshSlot& ms)
RAS_MeshSlot::iterator it;
GLenum drawmode;
if (ms.m_pDerivedMesh) {
// cannot be handled here, pass to RAS_OpenGLRasterizer
RAS_OpenGLRasterizer::IndexPrimitivesInternal(ms, true);
return;
}
if(!wireframe)
EnableTextures(true);

View File

@@ -5,6 +5,8 @@ sources = env.Glob('*.cpp')
incs = '. #source/kernel/gen_system #intern/string #intern/moto/include #source/gameengine/Rasterizer #source/gameengine/BlenderRoutines '
incs += ' #source/blender/gpu #extern/glew/include ' + env['BF_OPENGL_INC']
incs += ' #source/blender/gameengine/Ketsji #source/gameengine/SceneGraph #source/blender/makesdna #source/blender/blenkernel'
incs += ' #intern/guardedalloc #source/blender/blenlib'
cxxflags = []
if env['OURPLATFORM']=='win32-vc':