Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Index: src/scenes/critterding/entities/bodypart.cpp
- ===================================================================
- --- src/scenes/critterding/entities/bodypart.cpp (revision 849)
- +++ src/scenes/critterding/entities/bodypart.cpp (working copy)
- @@ -10,10 +10,15 @@
- shape = new btBoxShape( dimensions );
- + cerr << "Bodypart dimensions: " << dimensions.x() << ":" << dimensions.y() << ":" << dimensions.z() << endl;
- btVector3 localInertia(0,0,0);
- - if (weight != 0.f) // weight of non zero = dynamic
- - shape->calculateLocalInertia(weight,localInertia);
- + if (weight == 0.f) // weight of non zero = dynamic
- + {
- + cerr << "Danger, static bodypart." << endl;
- + }
- + shape->calculateLocalInertia(weight,localInertia);
- +
- myMotionState = new btDefaultMotionState(offset*transform);
- btRigidBody::btRigidBodyConstructionInfo rbInfo(weight,myMotionState,shape,localInertia);
- @@ -40,29 +45,9 @@
- void Bodypart::changeScale(float scale)
- {
- - m_ownerWorld->getBroadphase()->getOverlappingPairCache()->cleanProxyFromPairs(body->getBroadphaseHandle(),m_ownerWorld->getDispatcher());
- - m_ownerWorld->removeRigidBody(body);
- - delete body;
- -
- shape->setLocalScaling(btVector3(scale,scale,scale));
- -
- - btVector3 localInertia(0,0,0);
- - if (weight != 0.f) // weight of non zero = dynamic
- - shape->calculateLocalInertia(weight,localInertia);
- -
- -
- - btRigidBody::btRigidBodyConstructionInfo rbInfo(weight,myMotionState,shape,localInertia);
- - body = new btRigidBody(rbInfo);
- const btBoxShape* boxShape = static_cast<const btBoxShape*>(shape);
- halfExtent = boxShape->getHalfExtentsWithMargin();
- -
- - // Has to be cast to Entity* for RTTI to continue to allow dynamic_cast<>
- - body->setUserPointer(dynamic_cast<Entity*>(this));
- - body->setDamping(0.05, 0.85);
- - body->setDeactivationTime(0.001);
- - body->setSleepingThresholds(1.6, 2.5);
- -
- - m_ownerWorld->addRigidBody(body);
- }
- Bodypart::~Bodypart()
- Index: src/scenes/critterding/entities/worldb.cpp
- ===================================================================
- --- src/scenes/critterding/entities/worldb.cpp (revision 849)
- +++ src/scenes/critterding/entities/worldb.cpp (working copy)
- @@ -112,6 +112,7 @@
- m_dynamicsWorld->getSolverInfo().m_solverMode = SOLVER_USE_WARMSTARTING | SOLVER_SIMD | SOLVER_ENABLE_FRICTION_DIRECTION_CACHING;
- m_dynamicsWorld->getSolverInfo().m_numIterations = 8;
- + m_dynamicsWorld->setGravity( btVector3(0.0f, -1.0f * (float)settings->getCVar("gravity"), 0.0f) );
- // raycast
- raycast = new Raycast(m_dynamicsWorld);
- @@ -297,7 +298,9 @@
- void WorldB::childPositionOffset(btVector3* v)
- {
- - v->setY(insertHight);
- + float worldscalefactor = (float)Settings::Instance()->getCVar("worldscalefactor");
- + float wsf_inv = worldscalefactor / 1000.0f;
- + v->setY(insertHight / wsf_inv);
- }
- void WorldB::procreate( CritterB* c )
- @@ -656,7 +659,12 @@
- btVector3 WorldB::findPosition()
- {
- - return btVector3( (float)randgen->Instance()->get( 0, 100**worldsizeX ) / 100, insertHight, (float)randgen->Instance()->get( 0, 100**worldsizeY ) / 100 );
- + float worldscalefactor = (float)Settings::Instance()->getCVar("worldscalefactor");
- + float wsf_inv = worldscalefactor / 1000.0f;
- + float sX = *worldsizeX / wsf_inv;
- + float sY = *worldsizeY / wsf_inv;
- +
- + return btVector3( (float)randgen->Instance()->get( 0, 100*sX ) / 100, insertHight/wsf_inv, (float)randgen->Instance()->get( 0, 100*sY ) / 100 );
- }
- void WorldB::removeCritter(unsigned int cid)
- @@ -882,11 +890,16 @@
- void WorldB::resetCamera()
- {
- - unsigned int biggest = *worldsizeX;
- - if ( *worldsizeY > biggest )
- - biggest = 1.4f**worldsizeY;
- + float worldscalefactor = (float)Settings::Instance()->getCVar("worldscalefactor");
- + float wsf_inv = worldscalefactor / 1000.0f;
- + float sX = *worldsizeX / wsf_inv;
- + float sY = *worldsizeY / wsf_inv;
- - m_sceneNodeCamera.setOrigin( btVector3( 0.5f**worldsizeX, 1.3f*biggest, 0.5f**worldsizeY) );
- + unsigned int biggest = sX;
- + if ( sY > biggest )
- + biggest = 1.4f * sY;
- +
- + m_sceneNodeCamera.setOrigin( btVector3( 0.5f * sX, 1.3f * biggest, 0.5f * sY) );
- // camera.position.setRotation(btQuaternion(btVector3(1, 0, 0), btScalar(90)));
- m_sceneNodeCamera.pitch( -SIMD_HALF_PI ); // 1.5707f (float)*energy/10
- @@ -1015,15 +1028,21 @@
- }
- }
- + float worldscalefactor = (float)Settings::Instance()->getCVar("worldscalefactor");
- // Wall Constants
- - float WallWidth = 0.5f;
- + float WallWidth = 500.0f / worldscalefactor;
- + float WallHeight = 2000.0f * (float)Settings::Instance()->getCVar("worldsizeZ") / worldscalefactor;
- float WallHalfWidth = WallWidth/2.0f;
- - float WallHeight = 2.0f;
- float WallHalfHeight = WallHeight/2.0f;
- + float wsf_inv = worldscalefactor / 1000.0f;
- // Ground Floor
- - btVector3 position( *worldsizeX/2.0f, -WallHalfWidth, *worldsizeY/2.0f );
- - Wall* w = new Wall( *worldsizeX, WallWidth, *worldsizeY, position, m_dynamicsWorld, BeColor(0.3f,0.2f,0.1f,0.0f));
- +
- + float sX = *worldsizeX / wsf_inv;
- + float sY = *worldsizeY / wsf_inv;
- + //float sZ = *worldsizeZ / wsf_inv;
- + btVector3 position( sX/2.0f, -WallHalfWidth, sY/2.0f );
- + Wall* w = new Wall( sX, WallWidth, sY, position, m_dynamicsWorld, BeColor(0.3f,0.2f,0.1f,0.0f));
- entities.push_back(w);
- if ( settings->getCVar("worldwalls") )
- @@ -1035,20 +1054,20 @@
- wc.a=0.0f;
- // Left Wall
- - position = btVector3 ( 0.0f-WallHalfWidth, WallHalfHeight-WallWidth, *worldsizeY/2.0f );
- - w = new Wall( WallWidth, WallHeight, *worldsizeY, position, m_dynamicsWorld, wc );
- + position = btVector3 ( 0.0f-WallHalfWidth, WallHalfHeight-WallWidth, sY/2.0f );
- + w = new Wall( WallWidth, WallHeight, sY, position, m_dynamicsWorld, wc );
- entities.push_back(w);
- // Right Wall
- - position = btVector3 ( *worldsizeX+WallHalfWidth, WallHalfHeight-WallWidth, *worldsizeY/2.0f );
- - w = new Wall( WallWidth, WallHeight, *worldsizeY, position, m_dynamicsWorld, wc );
- + position = btVector3 ( sX+WallHalfWidth, WallHalfHeight-WallWidth, sY/2.0f );
- + w = new Wall( WallWidth, WallHeight, sY, position, m_dynamicsWorld, wc );
- entities.push_back(w);
- // Top Wall
- - position = btVector3 ( *worldsizeX/2.0f, WallHalfHeight-WallWidth, 0.0f-WallHalfWidth );
- - w = new Wall( *worldsizeX+(WallWidth*2), WallHeight, WallWidth, position, m_dynamicsWorld, wc );
- + position = btVector3 ( sX/2.0f, WallHalfHeight-WallWidth, 0.0f-WallHalfWidth );
- + w = new Wall( sX+(WallWidth*2), WallHeight, WallWidth, position, m_dynamicsWorld, wc );
- entities.push_back(w);
- // Bottom Wall
- - position = btVector3 ( *worldsizeX/2.0f, WallHalfHeight-WallWidth, *worldsizeY+WallHalfWidth );
- - w = new Wall( *worldsizeX+(WallWidth*2), WallHeight, WallWidth, position, m_dynamicsWorld, wc );
- + position = btVector3 ( sX/2.0f, WallHalfHeight-WallWidth, sY+WallHalfWidth );
- + w = new Wall( sX+(WallWidth*2), WallHeight, WallWidth, position, m_dynamicsWorld, wc );
- entities.push_back(w);
- }
- }
- Index: src/scenes/critterding/entities/body.cpp
- ===================================================================
- --- src/scenes/critterding/entities/body.cpp (revision 849)
- +++ src/scenes/critterding/entities/body.cpp (working copy)
- @@ -91,22 +91,25 @@
- transform.setIdentity();
- transform.setOrigin( btVector3( 0.0f, 0.0f, 0.0f ) );
- + float worldscalefactor = (float)Settings::Instance()->getCVar("worldscalefactor");
- + float densityscalefactor = (float)Settings::Instance()->getCVar("densityscalefactor");
- +
- for ( unsigned int i=0; i < bodyArch->archBodyparts.size(); i++ )
- {
- archBodypart *bp = &bodyArch->archBodyparts[i];
- // calculate weight
- - float weight = ((bp->x*bp->y*bp->z)/1000) * 0.001f; // FIXME 0.001 is density of material
- + float weight = ((bp->x*bp->y*bp->z)/worldscalefactor) * 0.001f * densityscalefactor; // FIXME 0.001 is density of material
- totalWeight += weight;
- Bodypart *b = NULL;
- if ( bp->type == archBodypart::DEFAULT )
- {
- - b = new Bodypart(m_ownerWorld, owner, btVector3( bp->x/1000, bp->y/1000, bp->z/1000 ), weight, offset, transform, bodycolor, CRITTER);
- + b = new Bodypart(m_ownerWorld, owner, btVector3( bp->x/worldscalefactor, bp->y/worldscalefactor, bp->z/worldscalefactor ), weight, offset, transform, bodycolor, CRITTER);
- b->addColor(speciescolor);
- }
- else if ( bp->type == archBodypart::HEAD )
- - b = new Mouth(m_ownerWorld, owner, btVector3( bp->x/1000, bp->y/1000, bp->z/1000 ), weight, offset, transform, BeColor(1.0f,0.0f,0.0f,0.0f));
- + b = new Mouth(m_ownerWorld, owner, btVector3( bp->x/worldscalefactor, bp->y/worldscalefactor, bp->z/worldscalefactor ), weight, offset, transform, BeColor(1.0f,0.0f,0.0f,0.0f));
- bodyparts.push_back( b );
- @@ -118,13 +121,15 @@
- {
- archConstraint *co = &bodyArch->archConstraints[i];
- + float wsf_inv = 1000/worldscalefactor;
- +
- localA.setIdentity();
- localA.getBasis().setEulerZYX( co->rot_x_1, co->rot_y_1, co->rot_z_1 );
- - localA.setOrigin( btVector3(co->pos_x_1, co->pos_y_1, co->pos_z_1) );
- + localA.setOrigin( btVector3(co->pos_x_1*wsf_inv, co->pos_y_1*wsf_inv, co->pos_z_1*wsf_inv) );
- localB.setIdentity();
- localB.getBasis().setEulerZYX( co->rot_x_2, co->rot_y_2, co->rot_z_2 );
- - localB.setOrigin( btVector3(co->pos_x_2, co->pos_y_2, co->pos_z_2) );
- + localB.setOrigin( btVector3(co->pos_x_2*wsf_inv, co->pos_y_2*wsf_inv, co->pos_z_2*wsf_inv) );
- // find the ID's to connect
- int bpID_1 = bodyArch->findBodypart( co->id_1 );
- Index: src/scenes/critterding/entities/constraint.cpp
- ===================================================================
- --- src/scenes/critterding/entities/constraint.cpp (revision 849)
- +++ src/scenes/critterding/entities/constraint.cpp (working copy)
- @@ -80,7 +80,7 @@
- hinge->setMaxMotorImpulse(*maximumimpulse);
- }
- else
- - hinge->enableAngularMotor(true, (f1 + f2 - 10)*10, *maximumimpulse);
- + hinge->enableAngularMotor(true, (f1 + f2 - 10)*100, *maximumimpulse);
- }
- Constraint::~Constraint()
- Index: src/scenes/critterding/entities/food.cpp
- ===================================================================
- --- src/scenes/critterding/entities/food.cpp (revision 849)
- +++ src/scenes/critterding/entities/food.cpp (working copy)
- @@ -11,7 +11,7 @@
- color.r = 0.0f;
- color.g = 0.5f;
- color.b = 0.0f;
- - color.a = 0.5f;
- + color.a = 0.0f;
- body.m_ownerWorld = m_dynamicsWorld;
- @@ -21,7 +21,9 @@
- btTransform transform; transform.setIdentity();
- transform.setOrigin( btVector3(0.0f, 0.10f, 0.0f) );
- - body.addBodyPart_Box(this, (float)*food_size/1000, (float)*food_size/1000, (float)*food_size/1000, 1.0f, offset, transform, color, FOOD);
- + float worldscalefactor = (float)Settings::Instance()->getCVar("worldscalefactor");
- + body.addBodyPart_Box(this, (float)*food_size/worldscalefactor, (float)*food_size/worldscalefactor, (float)*food_size/worldscalefactor,
- + Settings::Instance()->getCVar("densityscalefactor"), offset, transform, color, FOOD);
- myMotionState = (btDefaultMotionState*)body.bodyparts[0]->body->getMotionState();
- boxShape = static_cast<btBoxShape*>(body.bodyparts[0]->shape);
- Index: src/common/be_mouse_picker.cpp
- ===================================================================
- --- src/common/be_mouse_picker.cpp (revision 849)
- +++ src/common/be_mouse_picker.cpp (working copy)
- @@ -18,8 +18,8 @@
- // create constraint and add it to bulletworld
- constraint = new btPoint2PointConstraint(*pickedBody,localPivot);
- - constraint->m_setting.m_impulseClamp = 30.f;
- - constraint->m_setting.m_tau = 0.1f;
- + //constraint->m_setting.m_impulseClamp = 500000.f;
- + //constraint->m_setting.m_tau = 0.1f;
- btDynWorld->addConstraint(constraint);
- oldPickingDist = (attachPosition - rayFrom).length();
- Index: src/critterding.cpp
- ===================================================================
- --- src/critterding.cpp (revision 849)
- +++ src/critterding.cpp (working copy)
- @@ -57,8 +57,11 @@
- settings->registerCVar("camerasensitivity", 20, 1, 1000, false, "sensitivity of the camera");
- settings->registerCVar("maximumimpulse", 5000, 0, 1000000, false, "maximum impulse per-tick");
- - settings->registerCVar("absolutemotorneurons", 0, 0, 1, true, "muscle neurons determine angle + dt directly");
- - settings->registerCVar("selfcollisions", 1, 0, 1, true, "critters can exploit physics glitches");
- + settings->registerCVar("absolutemotorneurons", 0, 0, 1, true, "muscle neurons determine angle + dt directly");
- + settings->registerCVar("selfcollisions", 0, 0, 1, true, "critters can exploit physics glitches");
- + settings->registerCVar("worldscalefactor", 1000, 1, 1000, false, "all world sizes reduced by a factor of");
- + settings->registerCVar("densityscalefactor", 1, 1, 1000000, false, "all world densities increased by a factor of");
- + settings->registerCVar("gravity", 10, 1, 1000, false, "force of gravity");
- settings->registerCVar("colormode", 0, 0, 1, true, "colors genetically exact critters identically");
- settings->registerCVar("exit_if_empty", 0, 0, 1, true, "exit simulation if there are no critters");
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement