View previous topic :: View next topic |
Author |
Message |
clayasaurus
Joined: 21 May 2004 Posts: 857
|
Posted: Thu Oct 12, 2006 2:30 pm Post subject: custom holder class (draw order fixing)... |
|
|
Here is a thread dedicated to the implementation of the custom holder class Sequoh mentioned. With a very basic understanding, I'd imagine it would work something like...
Code: |
class ObjectHolder
{
void handle()// or process()
{
// draw planets first
while (!planet.last) {}
// draw space rock
while (!asteroids.last) {}
// particles next
while (!particle.last) {}
// ships last
while (!ship.last) {}
}
private:
linkedlist ship;
linkedlist particle;
linkedlist planet;
linkedlist asteroids;
}
|
Just thought I'd kick-start this thread, nothing much that I have to contribute to it yet. |
|
Back to top |
|
|
ChristianK
Joined: 26 Sep 2006 Posts: 159 Location: Berlin, Germany
|
Posted: Fri Oct 13, 2006 4:05 am Post subject: |
|
|
Yeah, very much like that.
I'm highly in favour of allowing to use foreach to iterate over the contents. I'd also add the required functionality to dlinkedlist, so this is possible:
Code: |
foreach(o; object_holder)
o.draw(); // typeof(o) is FU_OBJECT
foreach(ship; object_holder.ships)
ship.process_ai(); // typeof(o) is FU_SHIP
|
A rough implementation
Code: |
// struct since I doubt we need inheritance or even multiple instances
struct ObjectHolder
{
dlinkedlist!(FU_SHIP) ships;
dlinkedlist!(FU_PARTICLE) particles;
// ...
// for foreach
int opApply(some delegate param dg);
{
// iterate over linked lists in display order
}
// for easy serialization
void describe(T)(T ar)
{
ar.describe(ships);
ar.describe(particles);
// ...
}
}
|
While the linked lists certainly could be private, I think it'll just add overhead for this particular struct, since it's only an aggregation of data with no real internal state you could mess up. |
|
Back to top |
|
|
clayasaurus
Joined: 21 May 2004 Posts: 857
|
Posted: Fri Oct 13, 2006 8:48 am Post subject: |
|
|
I think classes with private and public are better form, but really what type of class/struct we use is a non-issue as we can easily change it whenever. |
|
Back to top |
|
|
ChristianK
Joined: 26 Sep 2006 Posts: 159 Location: Berlin, Germany
|
Posted: Fri Oct 13, 2006 10:24 am Post subject: |
|
|
Quote: | I think classes with private and public are better form |
I agree, but there are instances where it just doesn't make sense to me. I mean in the case of the object holder class, the minimal public interface for just four linked lists would be
add_ship
add_planet
add_particle
add_asteroid
remove_ship
remove_planet
remove_asteroid
remove_particle
someiteration_ship
someiteration_planet
someiteration_asteroid
someiteration_particle
Which are basically just 'pass through' functions. And from the user perspective, I think object_holder.add_sprite(..) has no advantage over object_holder.sprite.add(..).
It just feels like making the data public for this class makes sense. (also why I argued the same with Point - simply feels like a value type to me) Feel free to disagree though |
|
Back to top |
|
|
clayasaurus
Joined: 21 May 2004 Posts: 857
|
Posted: Fri Oct 13, 2006 11:28 am Post subject: |
|
|
phr00t - i need your help on this one
Alright. My first experiment with this ObjectHolder class, trying to put the space rocks inside of the object holder class instead of the spaceobject linked list...
A few details
1) Global object holder class named GameObjects
2) 3 files involved, hander.d, generator.d, and objectholder.d
3) I am keeping the SpaceObjects global alive until everything is converted from the huge list to small bitsized chunks, this saves a huge amount of time.
4) I am initializing the GameObjects in init.d
Now, for some reason, even though I use the exact same codes, when I moved the space rocks from the giant linked list into a seperate one, it causes the object to not appear in the game, and I have no idea why (maybe you do?)
objectholder.d
Code: |
module classes.objectholder;
private import classes.particle;
private import arc.templates.dlinkedlist;
private import classes.fu_object;
private import classes.item;
private import classes.ship;
private import classes.projectile;
private import space.hud;
private import space.stars;
private import init.init;
private import derelict.sdl.keysym;
private import space.generation;
private import space.storms;
public {
dlinkedlist!(FU_OBJECT) SpaceObjects;
dlinkedlist!(FU_PARTICLE) SpaceParticles;
}
/// FreeUniverse's object hander, all game objects are put in here
class ObjectHolder
{
public:
/// construct all game objects
this()
{
SpaceObjects = new dlinkedlist!(FU_OBJECT);
SpaceParticles = new dlinkedlist!(FU_PARTICLE);
spaceRocks = new dlinkedlist!(FU_OBJECT);
}
/// clear all game objects
void clear()
{
SpaceObjects.clear();
SpaceParticles.clear();
spaceRocks.clear();
}
/// handle the space particles
void handleParticles()
{
SpaceParticles.reset();
while(!SpaceParticles.first()) {
if( SpaceParticles.data.draw() == false ) {
SpaceParticles.remove();
}
}
}
/// handle the space rocks!
void handleRocks()
{
spaceRocks.reset();
while(!spaceRocks.last())
{
switch( spaceRocks.data.getType() )
{
case OBJECT_TYPE.NULL:
spaceRocks.backup();
spaceRocks.remove();
spaceRocks.restore();
break;
case OBJECT_TYPE.ROCK:
spaceRocks.data.handle_object();
if( autoSelection == AUTO_SELECT.ALL ) tryAutoSelect(spaceRocks.data);
break;
}
}
}
/// add rock to the space objects
void addRock(FU_OBJECT argRock)
{
spaceRocks.add(argRock);
}
private:
void tryAutoSelect(FU_OBJECT tryObj) {
if( objectExists(tryObj) == false ) return;
if( tryObj is PlayerShip ) return;
if( distance( tryObj.getX(), tryObj.getY(), PlayerShip.getX(), PlayerShip.getY() ) > MAX_TARGETABLE ) return;
if( tryObj.getType() == OBJECT_TYPE.SHIP && canSee(PlayerShip, cast(FU_SHIP)tryObj) == false ) return;
float angDis = angleDistance( pointAtAngle( PlayerShip.getX(), PlayerShip.getY(), tryObj.getX(), tryObj.getY() ),
PlayerShip.getRotation() );
if( angDis < nearestSelected && PlayerShip.getTarget() !is tryObj ) {
nearestSelected = angDis;
PlayerShip.setTarget(tryObj);
if( PlayerShip.getAIAction() == AI_ACTION.ATTACKING ) PlayerShip.updateAction(AI_ACTION.WANDERING);
}
}
private:
// big linked list of all loaded space objects
dlinkedlist!(FU_OBJECT) spaceRocks;
}
|
hander.d
Code: |
GameObjects.handleParticles();
// why doesn't this work!?
GameObjects.handleRocks();
last_shipCount = shipCount;
shipCount = 0;
SpaceObjects.reset();
while(!SpaceObjects.last()) {
switch( SpaceObjects.data.getType() ) {
case OBJECT_TYPE.NULL:
SpaceObjects.backup();
SpaceObjects.remove();
SpaceObjects.restore();
break;
case OBJECT_TYPE.ROCK:
// (cast(FU_OBJECT)SpaceObjects.data).handle_object();
// if( autoSelection == AUTO_SELECT.ALL ) tryAutoSelect(SpaceObjects.data);
break;
case OBJECT_TYPE.SHIP:
shipCount++;
(cast(FU_SHIP)SpaceObjects.data).handle_object();
drawSensorObject(playerSensor, SpaceObjects.data, 20, 120, 255);
switch( autoSelection ) {
case AUTO_SELECT.NULL:
case AUTO_SELECT.DOCK:
case AUTO_SELECT.ITEM:
break;
case AUTO_SELECT.ALL:
case AUTO_SELECT.SHIP:
tryAutoSelect(SpaceObjects.data);
break;
case AUTO_SELECT.ENEMY:
if( (cast(FU_SHIP)SpaceObjects.data).getTarget() is PlayerShip &&
(cast(FU_SHIP)SpaceObjects.data).getAIAction() == AI_ACTION.ATTACKING ) {
tryAutoSelect(SpaceObjects.data);
}
break;
}
break;
case OBJECT_TYPE.STATION:
(cast(FU_OBJECT)SpaceObjects.data).handle_object();
drawSensorObject(playerSensor, SpaceObjects.data, 20, 255, 255);
if( last_shipCount < MAX_SHIPS && rand()?1000==0 ) MainGenerator.spawnShip(SpaceObjects.data);
if( autoSelection == AUTO_SELECT.ALL || autoSelection == AUTO_SELECT.DOCK )
tryAutoSelect(SpaceObjects.data);
break;
case OBJECT_TYPE.PLANET:
(cast(FU_OBJECT)SpaceObjects.data).handle_object();
drawSensorObject(playerSensor, SpaceObjects.data, 255, 20, 20);
if( last_shipCount < MAX_SHIPS && rand()?500==0 ) MainGenerator.spawnShip(SpaceObjects.data);
if( autoSelection == AUTO_SELECT.ALL || autoSelection == AUTO_SELECT.DOCK )
tryAutoSelect(SpaceObjects.data);
break;
case OBJECT_TYPE.TELEGATE:
(cast(FU_OBJECT)SpaceObjects.data).handle_object();
drawSensorObject(playerSensor, SpaceObjects.data, 255, 20, 255);
if( last_shipCount < MAX_SHIPS && rand()?750==0 ) MainGenerator.spawnShip(SpaceObjects.data);
if( autoSelection == AUTO_SELECT.ALL || autoSelection == AUTO_SELECT.DOCK )
tryAutoSelect(SpaceObjects.data);
break;
case OBJECT_TYPE.TRANSPATH:
(cast(FU_OBJECT)SpaceObjects.data).handle_object();
drawSensorObject(playerSensor, SpaceObjects.data, 255, 255, 20);
if( autoSelection == AUTO_SELECT.ALL || autoSelection == AUTO_SELECT.DOCK )
tryAutoSelect(SpaceObjects.data);
break;
case OBJECT_TYPE.PROJECTILE:
(cast(FU_PROJECTILE)SpaceObjects.data).handle_object();
break;
case OBJECT_TYPE.ITEM:
(cast(FU_OBJECT)SpaceObjects.data).handle_object();
drawSensorObject(playerSensor, SpaceObjects.data, 20, 255, 20);
if( autoSelection == AUTO_SELECT.ALL || autoSelection == AUTO_SELECT.ITEM )
tryAutoSelect(SpaceObjects.data);
break;
}
}
|
generator.d
Code: |
void spawnRock() {
double newX, newY;
do {
newX = getCellAreaX();
newY = getCellAreaY();
} while( PlayerShip !is null && distance(newX, newY, PlayerShip.getX(), PlayerShip.getY() ) < 1500 )
FU_OBJECT newRock = new FU_OBJECT(OBJECT_TYPE.ROCK, TEXTURES.ROCK );
newRock.setPosition(newX, newY);
newRock.setFaction(factionIndex);
// make x_speed be rotation speed
newRock.setRotationSpeed( random_range(-5,5) );
newRock.addWeight(10);
newRock.setMaxArmor(100 + (level-1) * 10);
newRock.setArmor(newRock.getMaxArmor());
// add rock to game objects instead of huge list
GameObjects.addRock(newRock);
//SpaceObjects.add(newRock);
}
|
honestly I have no clue why this code shouldn't behave as expected, handling the rocks just like it did before.
instead what happens is the rocks don't get drawn in the game, and space ships shoot as space rocks that are not there!
:help: |
|
Back to top |
|
|
ChristianK
Joined: 26 Sep 2006 Posts: 159 Location: Berlin, Germany
|
Posted: Fri Oct 13, 2006 12:14 pm Post subject: |
|
|
I've no clue either.
I was working on the same thing. You are further in your efforts though, so I'll stop what I've done and revert. The next thing I'll do is the camera & zooming. |
|
Back to top |
|
|
clayasaurus
Joined: 21 May 2004 Posts: 857
|
Posted: Fri Oct 13, 2006 12:47 pm Post subject: |
|
|
Yea, I really don't want to work on zooming issues
The only thing I can imagine is wrong with my code is that there is some extra processing of the spaceobjects somewhere ? Maybe phr00t can suggest debugging techniques. hrm... |
|
Back to top |
|
|
clayasaurus
Joined: 21 May 2004 Posts: 857
|
Posted: Fri Oct 13, 2006 1:41 pm Post subject: |
|
|
I figured it out, folks!
I realized that nothing was being added to the spaceRocks list.
Then I realized the rocks were being loaded from a save, so I did some work and got the rocks to load from the save. But when I restarted the rocks dissapeared.
Then I realized that it loaded the rocks from the data, but it didn't save the rocks back...
So I had to find and delete the cell data and now I have loading, saving, and generating of the rocks. The rocks are in their own linked list now!
---------------------------
I also figured out that I could create a generic 'add' function for my object holder.
Code: |
/// add right object into correct list
void add(inout FU_OBJECT newObj)
{
switch(newObj.getType)
{
case OBJECT_TYPE.ROCK:
spaceRocks.add(newObj);
break;
default:
SpaceObjects.add(newObj);
}
}
|
not to mention we don't need casts anymore.
yay! |
|
Back to top |
|
|
ChristianK
Joined: 26 Sep 2006 Posts: 159 Location: Berlin, Germany
|
Posted: Sat Oct 14, 2006 5:35 am Post subject: |
|
|
Nice! Good work! |
|
Back to top |
|
|
Phr00t
Joined: 03 Mar 2006 Posts: 203
|
Posted: Sat Oct 14, 2006 8:36 am Post subject: |
|
|
Sorry I couldn't get to these posts earlier -- I rarely have time to work on FreeUniverse during the week -- busy with work! However, on weekends I should have some time, like today
Great job Clay! I'm going to start working on something from the "ideas" thread... let's see... |
|
Back to top |
|
|
clayasaurus
Joined: 21 May 2004 Posts: 857
|
Posted: Sat Oct 14, 2006 9:16 am Post subject: |
|
|
Alright, I am almost done, but there are two functions that worry me that I did not implement them correctly , therefore, I want you too to look them over to make sure they are good or not.
#1) classes.ship.FU_SHIP.searchForTargets()
Code: |
// search for targets
void searchForTargets() {
GameObjects.backupResetAll();
FU_OBJECT[] nearObjects;
while (!GameObjects.spaceRocks.last)
{
if (canSee(this, cast(FU_SHIP)GameObjects.spaceRocks.data) == false ) continue;
if( distance(GameObjects.spaceRocks.data.getX(), GameObjects.spaceRocks.data.getY(), getX(), getY()) < MAX_TARGETABLE ) {
nearObjects ~= GameObjects.spaceRocks.data;
}
}
while (!GameObjects.items.last)
{
if (canSee(this, cast(FU_SHIP)GameObjects.items.data) == false ) continue;
if( distance(GameObjects.items.data.getX(), GameObjects.items.data.getY(), getX(), getY()) < MAX_TARGETABLE ) {
nearObjects ~= GameObjects.items.data;
}
}
while (!GameObjects.ships.last)
{
if(GameObjects.ships.data is this) continue;
if (AIClass == AI_CLASS.TRAVELER) continue;
if (canSee(this, cast(FU_SHIP)GameObjects.ships.data) == false ) continue;
if( distance(GameObjects.ships.data.getX(), GameObjects.ships.data.getY(), getX(), getY()) < MAX_TARGETABLE ) {
nearObjects ~= GameObjects.ships.data;
}
}
while (!GameObjects.planets.last)
{
if (AIClass == AI_CLASS.TRAVELER) continue;
if (canSee(this, cast(FU_SHIP)GameObjects.planets.data) == false ) continue;
if( distance(GameObjects.planets.data.getX(), GameObjects.planets.data.getY(), getX(), getY()) < MAX_TARGETABLE ) {
nearObjects ~= GameObjects.planets.data;
}
}
while (!GameObjects.stations.last)
{
if (AIClass == AI_CLASS.TRAVELER) continue;
if (canSee(this, cast(FU_SHIP)GameObjects.stations.data) == false ) continue;
if( distance(GameObjects.stations.data.getX(), GameObjects.stations.data.getY(), getX(), getY()) < MAX_TARGETABLE ) {
nearObjects ~= GameObjects.stations.data;
}
}
if( nearObjects.length > 0 ) {
setTarget(nearObjects[rand()?nearObjects.length]);
setAIAction(defaultAction());
}
GameObjects.restoreAll();
}
|
#2) space.generation.trimSpaceObjects()
Code: |
void trimSpaceObjects(bool dockMode = false) {
bool questObject;
carryOver.length = 0;
GameObjects.resetAll();
while (!GameObjects.spaceRocks.last)
{
// make note if this is a questing object
questObject = false;
if( PlayerShip.getCurrentJob() !is null ) {
foreach(FU_OBJECTIVE jO; PlayerShip.getCurrentJob().jobObjective) {
if( jO.isTarget(GameObjects.spaceRocks.data) == true ) questObject = true;
}
}
if( dockMode == true ) {
// do not remove certain things on docking
if( questObject == true) continue;
}
else if( questObject == true ||
distance(GameObjects.spaceRocks.data.getX(), GameObjects.spaceRocks.data.getY(), PlayerShip.getX(), PlayerShip.getY()) < MAX_SENSOR_RANGE ) {
// save certain things on cell change
carryOver ~= GameObjects.spaceRocks.data;
}
GameObjects.spaceRocks.remove();
}
while (!GameObjects.items.last)
{
// make note if this is a questing object
questObject = false;
if( PlayerShip.getCurrentJob() !is null ) {
foreach(FU_OBJECTIVE jO; PlayerShip.getCurrentJob().jobObjective) {
if( jO.isTarget(GameObjects.items.data) == true ) questObject = true;
}
}
if( dockMode == true ) {
// do not remove certain things on docking
continue;
} else if( questObject == true ||
distance(GameObjects.items.data.getX(), GameObjects.items.data.getY(), PlayerShip.getX(), PlayerShip.getY()) < MAX_SENSOR_RANGE ) {
// save certain things on cell change
carryOver ~= GameObjects.items.data;
}
GameObjects.items.remove();
}
while (!GameObjects.ships.last)
{
if (cast(FU_SHIP)GameObjects.ships.data is PlayerShip) continue;
// make note if this is a questing object
questObject = false;
if( PlayerShip.getCurrentJob() !is null ) {
foreach(FU_OBJECTIVE jO; PlayerShip.getCurrentJob().jobObjective) {
if( jO.isTarget(GameObjects.ships.data) == true ) questObject = true;
}
}
if( dockMode == true ) {
// do not remove certain things on docking
continue;
} else if( questObject == true ||
distance(GameObjects.ships.data.getX(), GameObjects.ships.data.getY(), PlayerShip.getX(), PlayerShip.getY()) < MAX_SENSOR_RANGE ) {
// save certain things on cell change
carryOver ~= GameObjects.ships.data;
}
GameObjects.ships.remove();
}
while (!GameObjects.planets.last)
{
// make note if this is a questing object
questObject = false;
if( PlayerShip.getCurrentJob() !is null ) {
foreach(FU_OBJECTIVE jO; PlayerShip.getCurrentJob().jobObjective) {
if( jO.isTarget(GameObjects.planets.data) == true ) questObject = true;
}
}
if( dockMode == true ) {
// do not remove certain things on docking
if( questObject == true) continue;
} else if( questObject == true ||
distance(GameObjects.planets.data.getX(), GameObjects.planets.data.getY(), PlayerShip.getX(), PlayerShip.getY()) < MAX_SENSOR_RANGE ) {
// save certain things on cell change
carryOver ~= GameObjects.planets.data;
}
GameObjects.planets.remove();
}
while (!GameObjects.stations.last)
{
// make note if this is a questing object
questObject = false;
if( PlayerShip.getCurrentJob() !is null ) {
foreach(FU_OBJECTIVE jO; PlayerShip.getCurrentJob().jobObjective) {
if( jO.isTarget(GameObjects.stations.data) == true ) questObject = true;
}
}
if( dockMode == true ) {
// do not remove certain things on docking
if( questObject == true) continue;
} else if( questObject == true ||
distance(GameObjects.stations.data.getX(), GameObjects.stations.data.getY(), PlayerShip.getX(), PlayerShip.getY()) < MAX_SENSOR_RANGE ) {
// save certain things on cell change
carryOver ~= GameObjects.stations.data;
}
GameObjects.stations.remove();
}
while (!GameObjects.projectiles.last)
{
// make note if this is a questing object
questObject = false;
if( PlayerShip.getCurrentJob() !is null ) {
foreach(FU_OBJECTIVE jO; PlayerShip.getCurrentJob().jobObjective) {
if( jO.isTarget(GameObjects.projectiles.data) == true ) questObject = true;
}
}
if( dockMode == true ) {
// do not remove certain things on docking
if( questObject == true) continue;
} else if( questObject == true ||
distance(GameObjects.projectiles.data.getX(), GameObjects.projectiles.data.getY(), PlayerShip.getX(), PlayerShip.getY()) < MAX_SENSOR_RANGE ) {
// save certain things on cell change
carryOver ~= GameObjects.projectiles.data;
}
GameObjects.projectiles.remove();
}
while (!GameObjects.transpaths.last)
{
// make note if this is a questing object
questObject = false;
if( dockMode == true ) {
// do not remove certain things on docking
if( questObject == true) continue;
} else if( questObject == true ||
distance(GameObjects.transpaths.data.getX(), GameObjects.transpaths.data.getY(), PlayerShip.getX(), PlayerShip.getY()) < MAX_SENSOR_RANGE ) {
// save certain things on cell change
carryOver ~= GameObjects.transpaths.data;
}
GameObjects.transpaths.remove();
}
while (!GameObjects.telegates.last)
{
// make note if this is a questing object
questObject = false;
if( dockMode == true ) {
// do not remove certain things on docking
if( questObject == true) continue;
} else if( questObject == true ||
distance(GameObjects.telegates.data.getX(), GameObjects.telegates.data.getY(), PlayerShip.getX(), PlayerShip.getY()) < MAX_SENSOR_RANGE ) {
// save certain things on cell change
carryOver ~= GameObjects.telegates.data;
}
GameObjects.telegates.remove();
}
PlayerShip.setTarget(null);
std.gc.fullCollect();
}
|
I bet I implemented these ones wrong because I kind of rushed it. I just need to know what is wrong.. hrm.. |
|
Back to top |
|
|
Phr00t
Joined: 03 Mar 2006 Posts: 203
|
Posted: Sat Oct 14, 2006 9:57 am Post subject: |
|
|
These kinds of huge functions is what I feared when splitting up objects into their own lists. If this is what it takes to support it, I don't know if I like the idea afterall? It seems inefficient and bloated... if this is just to fix draw order, there must be a better way (handling order of objects placed into the SpaceObjects linked list)?
Make sure you test this code plenty before submitting it to the SVN. You have to make sure that AI ships find targets and react to them correctly. Also, when you dock or change zones, that objects are "trimmed" correctly, and that all questing items still exist. There are a few things you could do to improve these functions -- for instance, rocks are never (currently) questing items. Also, many AI classes (e.g. police) never target rocks, so you could cut the search of the "rocks" list if the ship is a police AI class... I think AI_TRAVELER are suppose to see planets / stations? You seem to be skipping them currently?
I'm not so sure I can just look at the code and find whats wrong...? Just have to put it through some testing...
I am going to try and fix the draw order now, starting with the space particles using the suggestion I had earlier. I think the only other problem with draw order comes from quest objects? I'll look into it...
[ edit ] I just commited a change in the SVN to fix particle draw order, small change that fixed it... |
|
Back to top |
|
|
ChristianK
Joined: 26 Sep 2006 Posts: 159 Location: Berlin, Germany
|
Posted: Sat Oct 14, 2006 11:02 am Post subject: |
|
|
I also don't like very long functions. Possible fix:
Add (I wrote this from memory, so no guarantee for bug-freeness)
Code: | int opApply(int delegate(inout FU_OBJECT) dg)
{
int result = 0;
backupResetAll();
while(!spaceRocks.last)
{
result = dg(spaceRocks.data);
if(result) return result;
}
// next while(...)
...
} |
This will be moderately large, but allow
Code: | void searchForTargets() {
FU_OBJECT[] nearObjects;
foreach(object; GameObjects_instance)
{
if (canSee(this, cast(FU_SHIP) object) == false ) continue;
if( distance(object.getX(), object.getY(), getX(), getY()) < MAX_TARGETABLE ) {
nearObjects ~= object;
}
} |
Lastly, those cast(FU_SHIP) things seem like bugs to me. Asteroids are plain FU_OBJECTs, and planets too, probably. The casts should return null. |
|
Back to top |
|
|
clayasaurus
Joined: 21 May 2004 Posts: 857
|
Posted: Sat Oct 14, 2006 11:21 am Post subject: |
|
|
sequoh - of course, if I have an iterator for gameobjects then I barely have to change the code from the original plus it will trim the code down a lot. I'll take that approach then.
I'm not very experienced writing opApply iterators, guess I will have to find the docs and read about them then. |
|
Back to top |
|
|
Phr00t
Joined: 03 Mar 2006 Posts: 203
|
Posted: Sat Oct 14, 2006 11:39 am Post subject: |
|
|
I just want to stress efficiency... I don't want a bunch of huge / bloated / inefficient code placed to fix a few small bugs. I am also not very familure with opApply etc., so its use / benefits are up for you guys to decide. However, I want the solution to be rather clean... I'd rather have a rare draw-order bug than have a constant 2x/3x performance overhead... keep in mind, all SpaceObjects parsing currently done would have to be changed to this foreach process?
In that opApply function, can you describe what objects you want to search through, and then only go through those lists (e.g. only look through ships and rocks)? Because that would be a cool feature -- certain AI behaviors would only need to iterate through lists they are interested in.
- Jeremy |
|
Back to top |
|
|
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
Powered by phpBB © 2001, 2005 phpBB Group
|