branches/blender-2.47

Merge from trunk:
	Revision: 15561
	Revision: 15562
	Revision: 15563
	Revision: 15564
	Revision: 15570
	Revision: 15579
	Revision: 15589
	Revision: 15590
	Revision: 15600 (Only: * missing countall when selecting linked)
	Revision: 15602
	Revision: 15610
	Revision: 15612
This commit is contained in:
Diego Borghetti 2008-07-17 20:43:53 +00:00
parent ac450d0ee9
commit 8dc1d7809e
18 changed files with 270 additions and 255 deletions

View File

@ -60,6 +60,7 @@
#define SMALL_NUMBER 1.e-8
#define ABS(x) ((x) < 0 ? -(x) : (x))
#define SWAP(type, a, b) { type sw_ap; sw_ap=(a); (a)=(b); (b)=sw_ap; }
#define CLAMP(a, b, c) if((a)<(b)) (a)=(b); else if((a)>(c)) (a)=(c)
#if defined(WIN32) || defined(__APPLE__)
@ -3740,12 +3741,50 @@ int RayIntersectsTriangle(float p1[3], float d[3], float v0[3], float v1[3], flo
/* Adapted from the paper by Kasper Fauerby */
/* "Improved Collision detection and Response" */
static int getLowestRoot(float a, float b, float c, float maxR, float* root)
{
// Check if a solution exists
float determinant = b*b - 4.0f*a*c;
// If determinant is negative it means no solutions.
if (determinant >= 0.0f)
{
// calculate the two roots: (if determinant == 0 then
// x1==x2 but lets disregard that slight optimization)
float sqrtD = sqrt(determinant);
float r1 = (-b - sqrtD) / (2.0f*a);
float r2 = (-b + sqrtD) / (2.0f*a);
// Sort so x1 <= x2
if (r1 > r2)
SWAP( float, r1, r2);
// Get lowest root:
if (r1 > 0.0f && r1 < maxR)
{
*root = r1;
return 1;
}
// It is possible that we want x2 - this can happen
// if x1 < 0
if (r2 > 0.0f && r2 < maxR)
{
*root = r2;
return 1;
}
}
// No (valid) solutions
return 0;
}
int SweepingSphereIntersectsTriangleUV(float p1[3], float p2[3], float radius, float v0[3], float v1[3], float v2[3], float *lambda, float *ipoint)
{
float e1[3], e2[3], e3[3], point[3], vel[3], /*dist[3],*/ nor[3], temp[3], bv[3];
float a, b, c, d, e, x, y, z, t, t0, t1, radius2=radius*radius;
float a, b, c, d, e, x, y, z, radius2=radius*radius;
float elen2,edotv,edotbv,nordotv,vel2;
int embedded_in_plane=0, found_by_sweep=0;
float newLambda;
int found_by_sweep=0;
VecSubf(e1,v1,v0);
VecSubf(e2,v2,v0);
@ -3754,44 +3793,41 @@ int SweepingSphereIntersectsTriangleUV(float p1[3], float p2[3], float radius, f
/*---test plane of tri---*/
Crossf(nor,e1,e2);
Normalize(nor);
/* flip normal */
if(Inpf(nor,vel)>0.0f) VecMulf(nor,-1.0f);
a=Inpf(p1,nor)-Inpf(v0,nor);
nordotv=Inpf(nor,vel);
if ((nordotv > -0.000001) && (nordotv < 0.000001)) {
if(fabs(a)>=1.0f)
if (fabs(nordotv) < 0.000001)
{
if(fabs(a)>=radius)
{
return 0;
else{
embedded_in_plane=1;
t0=0.0f;
t1=1.0f;
}
}
else{
t0=(radius-a)/nordotv;
t1=(-radius-a)/nordotv;
/* make t0<t1 */
if(t0>t1){b=t1; t1=t0; t0=b;}
else
{
float t0=(-a+radius)/nordotv;
float t1=(-a-radius)/nordotv;
if(t0>t1)
SWAP(float, t0, t1);
if(t0>1.0f || t1<0.0f) return 0;
/* clamp to [0,1] */
t0=(t0<0.0f)?0.0f:((t0>1.0f)?1.0:t0);
t1=(t1<0.0f)?0.0f:((t1>1.0f)?1.0:t1);
}
CLAMP(t0, 0.0f, 1.0f);
CLAMP(t1, 0.0f, 1.0f);
/*---test inside of tri---*/
if(embedded_in_plane==0){
/*---test inside of tri---*/
/* plane intersection point */
VecCopyf(point,vel);
VecMulf(point,t0);
VecAddf(point,point,p1);
VecCopyf(temp,nor);
VecMulf(temp,radius);
VecSubf(point,point,temp);
point[0] = p1[0] + vel[0]*t0 - nor[0]*radius;
point[1] = p1[1] + vel[1]*t0 - nor[1]*radius;
point[2] = p1[2] + vel[2]*t0 - nor[2]*radius;
/* is the point in the tri? */
a=Inpf(e1,e1);
@ -3806,14 +3842,19 @@ int SweepingSphereIntersectsTriangleUV(float p1[3], float p2[3], float radius, f
y=e*a-d*b;
z=x+y-(a*c-b*b);
if(( ((unsigned int)z)& ~(((unsigned int)x)|((unsigned int)y)) ) & 0x80000000){
if( z <= 0.0f && (x >= 0.0f && y >= 0.0f))
{
//( ((unsigned int)z)& ~(((unsigned int)x)|((unsigned int)y)) ) & 0x80000000){
*lambda=t0;
VecCopyf(ipoint,point);
return 1;
}
}
*lambda=1.0f;
/*---test points---*/
a=vel2=Inpf(vel,vel);
@ -3821,73 +3862,42 @@ int SweepingSphereIntersectsTriangleUV(float p1[3], float p2[3], float radius, f
VecSubf(temp,p1,v0);
b=2.0f*Inpf(vel,temp);
c=Inpf(temp,temp)-radius2;
d=b*b-4*a*c;
if(d>=0.0f){
if(d==0.0f)
t=-b/2*a;
else{
z=sqrt(d);
x=(-b-z)*0.5/a;
y=(-b+z)*0.5/a;
t=x<y?x:y;
}
if(t>0.0 && t < *lambda){
*lambda=t;
VecCopyf(ipoint,v0);
found_by_sweep=1;
}
if(getLowestRoot(a, b, c, *lambda, lambda))
{
VecCopyf(ipoint,v0);
found_by_sweep=1;
}
/*v1*/
VecSubf(temp,p1,v1);
b=2.0f*Inpf(vel,temp);
c=Inpf(temp,temp)-radius2;
d=b*b-4*a*c;
if(d>=0.0f){
if(d==0.0f)
t=-b/2*a;
else{
z=sqrt(d);
x=(-b-z)*0.5/a;
y=(-b+z)*0.5/a;
t=x<y?x:y;
}
if(t>0.0 && t < *lambda){
*lambda=t;
VecCopyf(ipoint,v1);
found_by_sweep=1;
}
if(getLowestRoot(a, b, c, *lambda, lambda))
{
VecCopyf(ipoint,v1);
found_by_sweep=1;
}
/*v2*/
VecSubf(temp,p1,v2);
b=2.0f*Inpf(vel,temp);
c=Inpf(temp,temp)-radius2;
d=b*b-4*a*c;
if(d>=0.0f){
if(d==0.0f)
t=-b/2*a;
else{
z=sqrt(d);
x=(-b-z)*0.5/a;
y=(-b+z)*0.5/a;
t=x<y?x:y;
}
if(t>0.0 && t < *lambda){
*lambda=t;
VecCopyf(ipoint,v2);
found_by_sweep=1;
}
if(getLowestRoot(a, b, c, *lambda, lambda))
{
VecCopyf(ipoint,v2);
found_by_sweep=1;
}
/*---test edges---*/
VecSubf(e3,v2,v1); //wasnt yet calculated
/*e1*/
VecSubf(bv,v0,p1);
elen2 = Inpf(e1,e1);
edotv = Inpf(e1,vel);
edotbv = Inpf(e1,bv);
@ -3895,27 +3905,18 @@ int SweepingSphereIntersectsTriangleUV(float p1[3], float p2[3], float radius, f
a=elen2*(-Inpf(vel,vel))+edotv*edotv;
b=2.0f*(elen2*Inpf(vel,bv)-edotv*edotbv);
c=elen2*(radius2-Inpf(bv,bv))+edotbv*edotbv;
d=b*b-4*a*c;
if(d>=0.0f){
if(d==0.0f)
t=-b/2*a;
else{
z=sqrt(d);
x=(-b-z)*0.5/a;
y=(-b+z)*0.5/a;
t=x<y?x:y;
}
e=(edotv*t-edotbv)/elen2;
if(getLowestRoot(a, b, c, *lambda, &newLambda))
{
e=(edotv*newLambda-edotbv)/elen2;
if((e>=0.0f) && (e<=1.0f)){
if(t>0.0 && t < *lambda){
*lambda=t;
VecCopyf(ipoint,e1);
VecMulf(ipoint,e);
VecAddf(ipoint,ipoint,v0);
found_by_sweep=1;
}
if(e >= 0.0f && e <= 1.0f)
{
*lambda = newLambda;
VecCopyf(ipoint,e1);
VecMulf(ipoint,e);
VecAddf(ipoint,ipoint,v0);
found_by_sweep=1;
}
}
@ -3928,32 +3929,27 @@ int SweepingSphereIntersectsTriangleUV(float p1[3], float p2[3], float radius, f
a=elen2*(-Inpf(vel,vel))+edotv*edotv;
b=2.0f*(elen2*Inpf(vel,bv)-edotv*edotbv);
c=elen2*(radius2-Inpf(bv,bv))+edotbv*edotbv;
d=b*b-4*a*c;
if(d>=0.0f){
if(d==0.0f)
t=-b/2*a;
else{
z=sqrt(d);
x=(-b-z)*0.5/a;
y=(-b+z)*0.5/a;
t=x<y?x:y;
}
e=(edotv*t-edotbv)/elen2;
if(getLowestRoot(a, b, c, *lambda, &newLambda))
{
e=(edotv*newLambda-edotbv)/elen2;
if((e>=0.0f) && (e<=1.0f)){
if(t>0.0 && t < *lambda){
*lambda=t;
VecCopyf(ipoint,e2);
VecMulf(ipoint,e);
VecAddf(ipoint,ipoint,v0);
found_by_sweep=1;
}
if(e >= 0.0f && e <= 1.0f)
{
*lambda = newLambda;
VecCopyf(ipoint,e2);
VecMulf(ipoint,e);
VecAddf(ipoint,ipoint,v0);
found_by_sweep=1;
}
}
/*e3*/
VecSubf(e3,v2,v1);
VecSubf(bv,v0,p1);
elen2 = Inpf(e1,e1);
edotv = Inpf(e1,vel);
edotbv = Inpf(e1,bv);
VecSubf(bv,v1,p1);
elen2 = Inpf(e3,e3);
edotv = Inpf(e3,vel);
@ -3962,30 +3958,22 @@ int SweepingSphereIntersectsTriangleUV(float p1[3], float p2[3], float radius, f
a=elen2*(-Inpf(vel,vel))+edotv*edotv;
b=2.0f*(elen2*Inpf(vel,bv)-edotv*edotbv);
c=elen2*(radius2-Inpf(bv,bv))+edotbv*edotbv;
d=b*b-4*a*c;
if(d>=0.0f){
if(d==0.0f)
t=-b/2*a;
else{
z=sqrt(d);
x=(-b-z)*0.5/a;
y=(-b+z)*0.5/a;
t=x<y?x:y;
}
e=(edotv*t-edotbv)/elen2;
if(getLowestRoot(a, b, c, *lambda, &newLambda))
{
e=(edotv*newLambda-edotbv)/elen2;
if((e>=0.0f) && (e<=1.0f)){
if(t>0.0 && t < *lambda){
*lambda=t;
VecCopyf(ipoint,e3);
VecMulf(ipoint,e);
VecAddf(ipoint,ipoint,v1);
found_by_sweep=1;
}
if(e >= 0.0f && e <= 1.0f)
{
*lambda = newLambda;
VecCopyf(ipoint,e3);
VecMulf(ipoint,e);
VecAddf(ipoint,ipoint,v1);
found_by_sweep=1;
}
}
return found_by_sweep;
}
int AxialLineIntersectsTriangle(int axis, float p1[3], float p2[3], float v0[3], float v1[3], float v2[3], float *lambda)

View File

@ -451,7 +451,7 @@ void IMB_exr_begin_write(void *handle, char *filename, int width, int height, in
openexr_header_compression(&header, compress);
/* header.lineOrder() = DECREASING_Y; this crashes in windows for file read! */
header.insert ("BlenderMultiChannel", StringAttribute ("Blender V2.43"));
header.insert ("BlenderMultiChannel", StringAttribute ("Blender V2.43 and newer"));
data->ofile = new OutputFile(filename, header);
}

View File

@ -833,9 +833,7 @@ class RenderData:
def enableCropping(toggle):
"""
Enable/disable exclusion of border rendering from total image.
@type toggle: int
@param toggle: pass 1 for on / 0 for off
Deprecated: see the L{crop} attribute.
"""
def setImageType(type):

View File

@ -985,7 +985,7 @@ PyObject *RenderData_EnableCropping( void )
/* return M_Render_BitToggleInt( args, R_MOVIECROP,
&self->renderContext->mode );
*/
printf("cropping option is now default, obsolete\n");
printf("obsolete: movie cropping option is now default\n");
Py_RETURN_NONE;
}

View File

@ -3545,7 +3545,7 @@ void merge_transp_passes(RenderLayer *rl, ShadeResult *shr)
for(rpass= rl->passes.first; rpass; rpass= rpass->next) {
float *col= NULL;
int pixsize= 0;
int pixsize= 3;
switch(rpass->passtype) {
case SCE_PASS_RGBA:
@ -3580,6 +3580,10 @@ void merge_transp_passes(RenderLayer *rl, ShadeResult *shr)
col= &shr->mist;
pixsize= 1;
break;
case SCE_PASS_Z:
col= &shr->z;
pixsize= 1;
break;
case SCE_PASS_VECTOR:
{
@ -3612,14 +3616,18 @@ void merge_transp_passes(RenderLayer *rl, ShadeResult *shr)
for(samp= 1; samp<R.osa; samp++, fp+=delta) {
col[0]+= fp[0];
col[1]+= fp[1];
col[2]+= fp[2];
if(pixsize) col[3]+= fp[3];
if(pixsize>1) {
col[1]+= fp[1];
col[2]+= fp[2];
if(pixsize==4) col[3]+= fp[3];
}
}
col[0]*= weight;
col[1]*= weight;
col[2]*= weight;
if(pixsize) col[3]*= weight;
if(pixsize>1) {
col[1]*= weight;
col[2]*= weight;
if(pixsize==4) col[3]*= weight;
}
}
}
@ -3973,7 +3981,7 @@ unsigned short *zbuffer_transp_shade(RenderPart *pa, RenderLayer *rl, float *pas
/* general shader info, passes */
shade_sample_initialize(&ssamp, pa, rl);
addpassflag= rl->passflag & ~(SCE_PASS_Z|SCE_PASS_COMBINED);
addpassflag= rl->passflag & ~(SCE_PASS_COMBINED);
addzbuf= rl->passflag & SCE_PASS_Z;
if(R.osa)

View File

@ -137,36 +137,42 @@ static void load_new_sample(char *str) /* called from fileselect */
bSample *sample, *newsample;
sound = G.buts->lockpoin;
if (sound) {
// save values
sample = sound->sample;
strcpy(name, sound->sample->name);
strcpy(sound->name, str);
sound_set_sample(sound, NULL);
sound_initialize_sample(sound);
if (sound->sample->type == SAMPLE_INVALID) {
error("Not a valid sample: %s", str);
newsample = sound->sample;
// restore values
strcpy(sound->name, name);
sound_set_sample(sound, sample);
// remove invalid sample
sound_free_sample(newsample);
BLI_remlink(samples, newsample);
MEM_freeN(newsample);
}
/* No Sound or Selected the same sample as we alredy have, just ignore */
if (sound==NULL || str==sound->name)
return;
if (sizeof(sound->sample->name) < strlen(str)) {
error("Path too long: %s", str);
return;
}
// save values
sample = sound->sample;
strcpy(name, sound->sample->name);
strcpy(sound->name, str);
sound_set_sample(sound, NULL);
sound_initialize_sample(sound);
if (sound->sample->type == SAMPLE_INVALID) {
error("Not a valid sample: %s", str);
newsample = sound->sample;
// restore values
strcpy(sound->name, name);
sound_set_sample(sound, sample);
// remove invalid sample
sound_free_sample(newsample);
BLI_remlink(samples, newsample);
MEM_freeN(newsample);
return;
}
BIF_undo_push("Load new audio file");
allqueue(REDRAWBUTSSCENE, 0);
}
@ -403,7 +409,7 @@ static void sound_panel_sound(bSound *sound)
sample = sound->sample;
/* info string */
if (sound->sample && sound->sample->len) {
if (sound->sample && sound->sample->len && sound->sample->channels && sound->sample->bits) {
char *tmp;
if (sound->sample->channels == 1) tmp= "Mono";
else if (sound->sample->channels == 2) tmp= "Stereo";
@ -1174,18 +1180,18 @@ static void seq_panel_proxy()
130,140,120,19, &last_seq->flag,
0.0, 21.0, 100, 0,
"Use a custom directory to store data");
}
if (last_seq->flag & SEQ_USE_PROXY_CUSTOM_DIR) {
uiDefIconBut(block, BUT, B_SEQ_SEL_PROXY_DIR,
ICON_FILESEL, 10, 120, 20, 20, 0, 0, 0, 0, 0,
"Select the directory/name for "
"the proxy storage");
if (last_seq->flag & SEQ_USE_PROXY_CUSTOM_DIR) {
uiDefIconBut(block, BUT, B_SEQ_SEL_PROXY_DIR,
ICON_FILESEL, 10, 120, 20, 20, 0, 0, 0, 0, 0,
"Select the directory/name for "
"the proxy storage");
uiDefBut(block, TEX,
B_SEQ_BUT_RELOAD, "Dir: ",
30,120,220,20, last_seq->strip->proxy->dir,
0.0, 160.0, 100, 0, "");
uiDefBut(block, TEX,
B_SEQ_BUT_RELOAD, "Dir: ",
30,120,220,20, last_seq->strip->proxy->dir,
0.0, 160.0, 100, 0, "");
}
}
if (last_seq->flag & SEQ_USE_PROXY) {

View File

@ -5502,6 +5502,7 @@ void selectlinks(int nr)
allqueue(REDRAWDATASELECT, 0);
allqueue(REDRAWOOPS, 0);
BIF_undo_push("Select linked");
countall();
}
}

View File

@ -350,6 +350,7 @@ extern "C" void StartKetsjiShell(struct ScrArea *area,
ketsjiengine->SetPythonDictionary(dictionaryobject);
initRasterizer(rasterizer, canvas);
PyObject *gameLogic = initGameLogic(startscene);
PyDict_SetItemString(dictionaryobject, "GameLogic", gameLogic); // Same as importing the module.
initGameKeys();
initPythonConstraintBinding();
@ -417,7 +418,14 @@ extern "C" void StartKetsjiShell(struct ScrArea *area,
exitstring = ketsjiengine->GetExitString();
// when exiting the mainloop
dictionaryClearByHand(gameLogic);
// Clears the dictionary by hand:
// This prevents, extra references to global variables
// inside the GameLogic dictionary when the python interpreter is finalized.
// which allows the scene to safely delete them :)
// see: (space.c)->start_game
PyDict_Clear(PyModule_GetDict(gameLogic));
ketsjiengine->StopEngine();
exitGamePythonScripting();
networkdevice->Disconnect();
@ -611,6 +619,7 @@ extern "C" void StartKetsjiShellSimulation(struct ScrArea *area,
ketsjiengine->SetPythonDictionary(dictionaryobject);
initRasterizer(rasterizer, canvas);
PyObject *gameLogic = initGameLogic(startscene);
PyDict_SetItemString(dictionaryobject, "GameLogic", gameLogic); // Same as importing the module
initGameKeys();
initPythonConstraintBinding();

View File

@ -116,7 +116,7 @@ CValue* SCA_PythonController::GetReplica()
void SCA_PythonController::SetScriptText(const STR_String& text)
{
m_scriptText = "import GameLogic\n" + text;
m_scriptText = text;
m_bModified = true;
}
@ -365,8 +365,10 @@ SCA_PythonController::PyGetSensor(PyObject* self,
return sensor->AddRef();
}
}
PyErr_SetString(PyExc_AttributeError, "Unable to find requested sensor");
char emsg[96];
PyOS_snprintf( emsg, sizeof( emsg ), "Unable to find requested sensor \"%s\"", scriptArg );
PyErr_SetString(PyExc_AttributeError, emsg);
return NULL;
}
@ -395,8 +397,10 @@ SCA_PythonController::PyGetActuator(PyObject* self,
return actua->AddRef();
}
}
PyErr_SetString(PyExc_AttributeError, "Unable to find requested actuator");
char emsg[96];
PyOS_snprintf( emsg, sizeof( emsg ), "Unable to find requested actuator \"%s\"", scriptArg );
PyErr_SetString(PyExc_AttributeError, emsg);
return NULL;
}

View File

@ -667,7 +667,7 @@ bool GPG_Application::startEngine(void)
PyObject* dictionaryobject = initGamePlayerPythonScripting("Ketsji", psl_Lowest);
m_ketsjiengine->SetPythonDictionary(dictionaryobject);
initRasterizer(m_rasterizer, m_canvas);
PyObject *gameLogic = initGameLogic(startscene);
PyDict_SetItemString(dictionaryobject, "GameLogic", initGameLogic(startscene)); // Same as importing the module
initGameKeys();
initPythonConstraintBinding();

View File

@ -230,7 +230,10 @@ void KX_KetsjiEngine::SetRasterizer(RAS_IRasterizer* rasterizer)
}
/*
* At the moment the GameLogic module is imported into 'pythondictionary' after this function is called.
* if this function ever changes to assign a copy, make sure the game logic module is imported into this dictionary before hand.
*/
void KX_KetsjiEngine::SetPythonDictionary(PyObject* pythondictionary)
{
MT_assert(pythondictionary);

View File

@ -138,9 +138,6 @@ CValue* KX_NearSensor::GetReplica()
void KX_NearSensor::ReParent(SCA_IObject* parent)
{
SCA_ISensor::ReParent(parent);
m_client_info->m_gameobject = static_cast<KX_GameObject*>(parent);
m_client_info->m_sensors.push_back(this);
@ -154,6 +151,7 @@ void KX_NearSensor::ReParent(SCA_IObject* parent)
*/
((KX_GameObject*)GetParent())->GetSGNode()->ComputeWorldTransforms(NULL);
SynchronizeTransform();
SCA_ISensor::ReParent(parent);
}

View File

@ -862,20 +862,9 @@ PyObject* initGameLogic(KX_Scene* scene) // quick hack to get gravity hook
Py_FatalError("can't initialize module GameLogic");
}
return d;
return m;
}
void dictionaryClearByHand(PyObject *dict)
{
// Clears the dictionary by hand:
// This prevents, extra references to global variables
// inside the GameLogic dictionary when the python interpreter is finalized.
// which allows the scene to safely delete them :)
// see: (space.c)->start_game
if(dict) PyDict_Clear(dict);
}
// Python Sandbox code
// override builtin functions import() and open()

View File

@ -47,7 +47,6 @@ PyObject* initGamePlayerPythonScripting(const STR_String& progname, TPythonSecur
void exitGamePlayerPythonScripting();
PyObject* initGamePythonScripting(const STR_String& progname, TPythonSecurityLevel level);
void exitGamePythonScripting();
void dictionaryClearByHand(PyObject *dict);
void PHY_SetActiveScene(class KX_Scene* scene);
class KX_Scene* PHY_GetActiveScene();

View File

@ -93,6 +93,10 @@ CValue* KX_RadarSensor::GetReplica()
if (replica->m_physCtrl)
{
replica->m_physCtrl = replica->m_physCtrl->GetReplica();
if (replica->m_physCtrl)
{
replica->m_physCtrl->setNewClientInfo(replica->m_client_info);
}
}
//todo: make sure replication works fine!

View File

@ -503,6 +503,11 @@ KX_GameObject* KX_Scene::AddNodeReplicaObject(class SG_IObject* node, class CVal
// hierarchy that's because first ALL bricks must exist in the new
// replica of the hierarchy in order to make cross-links work properly
// !
// It is VERY important that the order of sensors and actuators in
// the replicated object is preserved: it is is used to reconnect the logic.
// This method is more robust then using the bricks name in case of complex
// group replication. The replication of logic bricks is done in
// SCA_IObject::ReParentLogic(), make sure it preserves the order of the bricks.
void KX_Scene::ReplicateLogic(KX_GameObject* newobj)
{
// also relink the controller to sensors/actuators
@ -525,37 +530,36 @@ void KX_Scene::ReplicateLogic(KX_GameObject* newobj)
for (vector<SCA_ISensor*>::iterator its = linkedsensors.begin();!(its==linkedsensors.end());its++)
{
SCA_ISensor* oldsensor = (*its);
STR_String name = oldsensor->GetName();
//find this name in the list
SCA_ISensor* newsensor = newobj->FindSensor(name);
SCA_IObject* oldsensorobj = oldsensor->GetParent();
SCA_IObject* newsensorobj = NULL;
if (newsensor)
// the original owner of the sensor has been replicated?
void **h_obj = m_map_gameobject_to_replica[oldsensorobj];
if (h_obj)
newsensorobj = (SCA_IObject*)(*h_obj);
if (!newsensorobj)
{
// relink this newsensor to the controller
m_logicmgr->RegisterToSensor(cont,newsensor);
// no, then the sensor points outside the hierachy, keep it the same
m_logicmgr->RegisterToSensor(cont,oldsensor);
}
else
{
// it can be linked somewhere in the hierarchy or...
for (vector<KX_GameObject*>::iterator git = m_logicHierarchicalGameObjects.begin();
!(git==m_logicHierarchicalGameObjects.end());++git)
{
newsensor = (*git)->FindSensor(name);
if (newsensor)
break;
}
// yes, then the new sensor has the same position
SCA_SensorList& sensorlist = oldsensorobj->GetSensors();
SCA_SensorList::iterator sit;
SCA_ISensor* newsensor = NULL;
int sensorpos;
if (newsensor)
for (sensorpos=0, sit=sensorlist.begin(); sit!=sensorlist.end(); sit++, sensorpos++)
{
// relink this newsensor to the controller somewhere else within this
// hierarchy
m_logicmgr->RegisterToSensor(cont,newsensor);
}
else
{
// must be an external sensor, so...
m_logicmgr->RegisterToSensor(cont,oldsensor);
if ((*sit) == oldsensor)
{
newsensor = newsensorobj->GetSensors().at(sensorpos);
break;
}
}
assert(newsensor != NULL);
m_logicmgr->RegisterToSensor(cont,newsensor);
}
}
@ -563,38 +567,38 @@ void KX_Scene::ReplicateLogic(KX_GameObject* newobj)
for (vector<SCA_IActuator*>::iterator ita = linkedactuators.begin();!(ita==linkedactuators.end());ita++)
{
SCA_IActuator* oldactuator = (*ita);
STR_String name = oldactuator->GetName();
//find this name in the list
SCA_IActuator* newactuator = newobj->FindActuator(name);
if (newactuator)
SCA_IObject* oldactuatorobj = oldactuator->GetParent();
SCA_IObject* newactuatorobj = NULL;
// the original owner of the sensor has been replicated?
void **h_obj = m_map_gameobject_to_replica[oldactuatorobj];
if (h_obj)
newactuatorobj = (SCA_IObject*)(*h_obj);
if (!newactuatorobj)
{
// relink this newsensor to the controller
m_logicmgr->RegisterToActuator(cont,newactuator);
newactuator->SetUeberExecutePriority(m_ueberExecutionPriority);
// no, then the sensor points outside the hierachy, keep it the same
m_logicmgr->RegisterToActuator(cont,oldactuator);
}
else
{
// it can be linked somewhere in the hierarchy or...
for (vector<KX_GameObject*>::iterator git = m_logicHierarchicalGameObjects.begin();
!(git==m_logicHierarchicalGameObjects.end());++git)
{
newactuator= (*git)->FindActuator(name);
if (newactuator)
break;
}
// yes, then the new sensor has the same position
SCA_ActuatorList& actuatorlist = oldactuatorobj->GetActuators();
SCA_ActuatorList::iterator ait;
SCA_IActuator* newactuator = NULL;
int actuatorpos;
if (newactuator)
for (actuatorpos=0, ait=actuatorlist.begin(); ait!=actuatorlist.end(); ait++, actuatorpos++)
{
// relink this actuator to the controller somewhere else within this
// hierarchy
m_logicmgr->RegisterToActuator(cont,newactuator);
newactuator->SetUeberExecutePriority(m_ueberExecutionPriority);
}
else
{
// must be an external actuator, so...
m_logicmgr->RegisterToActuator(cont,oldactuator);
if ((*ait) == oldactuator)
{
newactuator = newactuatorobj->GetActuators().at(actuatorpos);
break;
}
}
assert(newactuator != NULL);
m_logicmgr->RegisterToActuator(cont,newactuator);
newactuator->SetUeberExecutePriority(m_ueberExecutionPriority);
}
}
}

View File

@ -291,7 +291,8 @@ PyObject* KX_SoundActuator::PyGetFilename(PyObject* self, PyObject* args, PyObje
char* name = objectname.Ptr();
if (!name) {
Py_Return; /* internal error */
PyErr_SetString(PyExc_RuntimeError, "Unable to get sound filename");
return NULL;
} else
return PyString_FromString(name);
}

View File

@ -40,6 +40,9 @@ CPPFLAGS += -I$(NAN_STRING)/include
CPPFLAGS += -I$(NAN_MOTO)/include
CPPFLAGS += -I../../kernel/gen_system
CPPFLAGS += -I../BlenderRoutines
CPPFLAGS += -I../Expressions
CPPFLAGS += -I$(NAN_PYTHON)/include/python$(NAN_PYTHON_VERSION)
ifeq ($(OS),darwin)
CPPFLAGS += -fpascal-strings