Skip to content

Commit

Permalink
Work on player cell size and physics matching bacteria by Dak2896
Browse files Browse the repository at this point in the history
starting cell bacteria

grab render node of cell

cell size update

- starting cell is like other prokaryotic
- micorbe use compund physics instead spheres
- size of player species change from prokaryotic to eukariotic cell

Update setup.as

Update organelle.as

restore * 2 in organelle physics

Update microbe_editor.as

remove space

Update organelle.as

remove useless space

RunCodeFormatting

Offset for physic organelles shape

- Each organelle has different physics depending if species is bacteria or not

Update organelle physycis functions

- hexSize and translation depending on presence or not of nucleus

RunCodeFormatting

- update physics render size and translation parameter

- all microbe fit with organelle instead having a sphere
- player cell start as microbe
- add nucleus upgrade render and physics to same of other eurayotic

RunCodeFormatting

update all

- remove useless restoreOrganelleLayout call
- render of offset is no more divided
-  translation is not divide

Fix blank line

style fix

style fix

fix species parameter
  • Loading branch information
Dak2896 authored and hhyyrylainen committed Mar 15, 2019
1 parent b68fcfa commit 68def4e
Show file tree
Hide file tree
Showing 4 changed files with 34 additions and 18 deletions.
2 changes: 1 addition & 1 deletion scripts/microbe_stage/configs.as
Original file line number Diff line number Diff line change
Expand Up @@ -360,7 +360,7 @@ const dictionary STARTER_MICROBES = {
OrganelleTemplatePlaced("cytoplasm", 0, 0, 0)
},
Float4(1, 1, 1, 1),
false,
true,
MEMBRANE_TYPE::MEMBRANE)
}
};
Expand Down
20 changes: 19 additions & 1 deletion scripts/microbe_stage/microbe_editor/microbe_editor.as
Original file line number Diff line number Diff line change
Expand Up @@ -940,9 +940,12 @@ class MicrobeEditor{
} else if(type == "MicrobeEditorExited"){
LOG_INFO("MicrobeEditor: applying changes to player Species");

auto world = GetThriveGame().getCellStage();
auto player = GetThriveGame().playerData().activeCreature();

// We need to grab the player's species
SpeciesComponent@ playerSpecies = MicrobeOperations::getSpeciesComponent(
GetThriveGame().getCellStage(), GetThriveGame().playerData().activeCreature());
world, player);

assert(playerSpecies !is null, "didn't find edited species");

Expand All @@ -960,6 +963,21 @@ class MicrobeEditor{

templateOrganelles = newOrganelles;

// Grab render of player cell
auto node = world.GetComponent_RenderNode(player);

//! Change player species cell size depending on presence or not of nucleus
if(checkIsNucleusPresent()) {
playerSpecies.isBacteria = false;
node.Scale = Float3(1.0, 1.0, 1.0);
node.Marked = true;
}
else {
playerSpecies.isBacteria = true;
node.Scale = Float3(0.5, 0.5, 0.5);
node.Marked = true;
}

LOG_INFO("MicrobeEditor: updated organelles for species: " + playerSpecies.name);
return 1;
} else if (type == "SymmetryClicked"){
Expand Down
16 changes: 2 additions & 14 deletions scripts/microbe_stage/microbe_operations.as
Original file line number Diff line number Diff line change
Expand Up @@ -834,6 +834,7 @@ ObjectID spawnMicrobe(CellStageWorld@ world, Float3 pos, const string &in specie
return NULL_OBJECT;
}

// Create microbeEntity with correct template, physics and species name
auto microbeEntity = _createMicrobeEntity(world, aiControlled, speciesName,
// in_editor
false);
Expand All @@ -859,15 +860,8 @@ ObjectID spawnMicrobe(CellStageWorld@ world, Float3 pos, const string &in specie
// TODO: Why is this here with the separate spawnBacteria function existing?
// Bacteria get scaled to half size
if(species.isBacteria){
// TODO: wow, this is a big hack and no way guarantees that
// the physics size matches the rendered size
node.Scale = Float3(0.5, 0.5, 0.5);
node.Marked = true;
// This call is also not the cheapest. So would be much better
// if the physics generation actually did the right then when
// species.isBacteria is true
physics.ChangeShape(world.GetPhysicalWorld(),
world.GetPhysicalWorld().CreateSphere(HEX_SIZE/2.0f));
}

return microbeEntity;
Expand All @@ -893,6 +887,7 @@ ObjectID spawnBacteria(CellStageWorld@ world, Float3 pos, const string &in speci
return NULL_OBJECT;
}

// Create microbeEntity with correct template, physics and species name
auto microbeEntity = _createMicrobeEntity(world, aiControlled, speciesName,
// in_editor
false);
Expand All @@ -912,15 +907,8 @@ ObjectID spawnBacteria(CellStageWorld@ world, Float3 pos, const string &in speci
node.Node.setPosition(pos);

// Bacteria get scaled to half size
// TODO: wow, this is a big hack and no way guarantees that
// the physics size matches the rendered size
node.Scale = Float3(0.5, 0.5, 0.5);
node.Marked = true;
// This call is also not the cheapest. So would be much better
// if the physics generation actually did the right then when
// species.isBacteria is true
physics.ChangeShape(world.GetPhysicalWorld(),
world.GetPhysicalWorld().CreateSphere(HEX_SIZE/2.0f));

// Need to set bacteria spawn and it needs to be squared like it
// is in the spawn system. code, if part of colony but not
Expand Down
14 changes: 12 additions & 2 deletions scripts/microbe_stage/organelle.as
Original file line number Diff line number Diff line change
Expand Up @@ -683,11 +683,21 @@ class PlacedOrganelle : SpeciesStoredOrganelleType{
auto species = MicrobeOperations::getSpeciesComponent(world, microbeEntity);
if (species !is null){
this.speciesColour = species.colour;
}
}
// Our coordinates are already set when this is called
// so just cache this
this.cartesianPosition = Hex::axialToCartesian(q, r);

// Calculate hexSize depending if species is baceteria or not
// Scaling parameters that we need to scale
double hexSize = 0;
if(species.isBacteria) {
this.cartesianPosition /= 2;
hexSize = 0.375;
}
else
hexSize = HEX_SIZE;

assert(organelleEntity == NULL_OBJECT, "PlacedOrganelle already had an entity");

Float3 offset = organelle.calculateCenterOffset();
Expand Down Expand Up @@ -733,7 +743,7 @@ class PlacedOrganelle : SpeciesStoredOrganelleType{
// Create the matrix with the offset
Ogre::Matrix4 hexFinalOffset(translation);

PhysicsShape@ hexCollision = world.GetPhysicalWorld().CreateSphere(HEX_SIZE * 2);
PhysicsShape@ hexCollision = world.GetPhysicalWorld().CreateSphere(hexSize * 2);

if(hexCollision is null)
assert(false, "Failed to create Sphere for hex");
Expand Down

0 comments on commit 68def4e

Please sign in to comment.