forked from bartvdbraak/blender
fix BGE bug #8869: Added objects are not lit correctly
The current layer information is now stored in KX_GameObject and inherited from the parent object when dynamically added. This information is used during the rendering the select the lamps. As the selected lamps are always coming from active layers, their position and orientation are correct.
This commit is contained in:
parent
93ba2dd6a1
commit
3a430c33d2
@ -91,6 +91,10 @@ int KX_BlenderRenderTools::ProcessLighting(int layer)
|
||||
{
|
||||
if (m_clientobject)
|
||||
{
|
||||
if (layer == RAS_LIGHT_OBJECT_LAYER)
|
||||
{
|
||||
layer = static_cast<KX_GameObject*>(m_clientobject)->GetLayer();
|
||||
}
|
||||
if (applyLights(layer))
|
||||
{
|
||||
EnableOpenGLLights();
|
||||
|
@ -1680,8 +1680,11 @@ static KX_GameObject *gameobject_from_blenderobject(
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (gameobj)
|
||||
if (gameobj)
|
||||
{
|
||||
gameobj->SetPhysicsEnvironment(kxscene->GetPhysicsEnvironment());
|
||||
gameobj->SetLayer(ob->lay);
|
||||
}
|
||||
return gameobj;
|
||||
}
|
||||
|
||||
|
@ -137,6 +137,10 @@ int GPC_RenderTools::ProcessLighting(int layer)
|
||||
{
|
||||
if (m_clientobject)
|
||||
{
|
||||
if (layer == RAS_LIGHT_OBJECT_LAYER)
|
||||
{
|
||||
layer = static_cast<KX_GameObject*>(m_clientobject)->GetLayer();
|
||||
}
|
||||
if (applyLights(layer))
|
||||
{
|
||||
EnableOpenGLLights();
|
||||
|
@ -74,6 +74,7 @@ KX_GameObject::KX_GameObject(
|
||||
) :
|
||||
SCA_IObject(T),
|
||||
m_bDyna(false),
|
||||
m_layer(0),
|
||||
m_bSuspendDynamics(false),
|
||||
m_bUseObjectColor(false),
|
||||
m_bVisible(true),
|
||||
@ -479,6 +480,22 @@ KX_GameObject::SetVisible(
|
||||
m_bVisible = v;
|
||||
}
|
||||
|
||||
void
|
||||
KX_GameObject::SetLayer(
|
||||
int l
|
||||
)
|
||||
{
|
||||
m_layer = l;
|
||||
}
|
||||
|
||||
int
|
||||
KX_GameObject::GetLayer(
|
||||
void
|
||||
)
|
||||
{
|
||||
return m_layer;
|
||||
}
|
||||
|
||||
// used by Python, and the actuatorshould _not_ be misused by the
|
||||
// scene!
|
||||
void
|
||||
|
@ -70,6 +70,7 @@ protected:
|
||||
KX_ClientObjectInfo* m_pClient_info;
|
||||
STR_String m_name;
|
||||
STR_String m_text;
|
||||
int m_layer;
|
||||
std::vector<RAS_MeshObject*> m_meshes;
|
||||
|
||||
bool m_bSuspendDynamics;
|
||||
@ -571,6 +572,22 @@ public:
|
||||
bool b
|
||||
);
|
||||
|
||||
/**
|
||||
* Change the layer of the object (when it is added in another layer
|
||||
* than the original layer)
|
||||
*/
|
||||
void
|
||||
SetLayer(
|
||||
int l
|
||||
);
|
||||
|
||||
/**
|
||||
* Get the object layer
|
||||
*/
|
||||
int
|
||||
GetLayer(
|
||||
void
|
||||
);
|
||||
|
||||
/**
|
||||
* @section Logic bubbling methods.
|
||||
|
@ -650,6 +650,8 @@ SCA_IObject* KX_Scene::AddReplicaObject(class CValue* originalobject,
|
||||
for (git = m_logicHierarchicalGameObjects.begin();!(git==m_logicHierarchicalGameObjects.end());++git)
|
||||
{
|
||||
(*git)->Relink(&m_map_gameobject_to_replica);
|
||||
// add the object in the layer of the parent
|
||||
(*git)->SetLayer(parentobj->GetLayer());
|
||||
}
|
||||
|
||||
// now replicate logic
|
||||
|
@ -61,6 +61,10 @@ public:
|
||||
RAS_TEXT_PADDED,
|
||||
RAS_TEXT_MAX
|
||||
};
|
||||
enum RAS_LIGHT_MODE {
|
||||
RAS_LIGHT_NONE = -1,
|
||||
RAS_LIGHT_OBJECT_LAYER = 0
|
||||
};
|
||||
|
||||
RAS_IRenderTools(
|
||||
) :
|
||||
|
@ -189,7 +189,7 @@ bool RAS_MaterialBucket::ActivateMaterial(const MT_Transform& cameratrans, RAS_I
|
||||
}
|
||||
else
|
||||
{
|
||||
rendertools->ProcessLighting(m_material->GetLightLayer());
|
||||
rendertools->ProcessLighting(RAS_IRenderTools::RAS_LIGHT_OBJECT_LAYER/*m_material->GetLightLayer()*/);
|
||||
}
|
||||
|
||||
drawmode = (rasty->GetDrawingMode() < RAS_IRasterizer::KX_SOLID ?
|
||||
@ -204,7 +204,6 @@ void RAS_MaterialBucket::RenderMeshSlot(const MT_Transform& cameratrans, RAS_IRa
|
||||
if (!ms.m_bVisible)
|
||||
return;
|
||||
|
||||
rendertools->SetClientObject(ms.m_clientObj);
|
||||
m_material->ActivateMeshSlot(ms, rasty);
|
||||
|
||||
/* __NLA Do the deformation */
|
||||
@ -317,15 +316,12 @@ void RAS_MaterialBucket::Render(const MT_Transform& cameratrans,
|
||||
|
||||
//rasty->SetMaterial(*m_material);
|
||||
|
||||
if (m_meshSlots.size() >0)
|
||||
{
|
||||
rendertools->SetClientObject((*m_meshSlots.begin()).m_clientObj);
|
||||
}
|
||||
|
||||
int drawmode;
|
||||
for (T_MeshSlotList::const_iterator it = m_meshSlots.begin();
|
||||
! (it == m_meshSlots.end()); ++it)
|
||||
{
|
||||
rendertools->SetClientObject((*it).m_clientObj);
|
||||
while (ActivateMaterial(cameratrans, rasty, rendertools, drawmode))
|
||||
RenderMeshSlot(cameratrans, rasty, rendertools, *it, drawmode);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user