Thread: OCTree problems...

  1. #1
    Registered User
    Join Date
    Sep 2005
    Posts
    40

    OCTree problems...

    So im trying to implement an octree for a 3d world. But im having some issues with "new" and pointers.

    first problem is:
    i can make a tree and i can print the contents of each node to the screen, but then if i try to go through the tree looking for what node a certain point is it crashes.

    im using gcc v4. something on windows vista

    attached is the code for the tree.

    Any and all help is greatly appreciated.

  2. #2
    pwning noobs Zlatko's Avatar
    Join Date
    Jun 2009
    Location
    The Great White North
    Posts
    132
    Adam, if you provide me with a main program that creates the octree and reproduces the problem, I'll try to debug it. I need to be able to compile it, so I need VECTOR, TRIANGLE, and CVec3 (as far as I know).

    Best regards.

  3. #3
    Registered User
    Join Date
    Sep 2005
    Posts
    40
    Ok here are the files. (AFAIK, they dont have anything special to link to...) TextureManager isnt needed.

    Thanks for your help.

  4. #4
    pwning noobs Zlatko's Avatar
    Join Date
    Jun 2009
    Location
    The Great White North
    Posts
    132
    Adam, the files in the last post don't compile.

    Code:
    1>Compiling...
    1>main.cpp
    1>octree\main.cpp(15) : error C2039: 'getTriangleList' : is not a member of 'C3DWorld'
    1>        octree\c3dworld.h(36) : see declaration of 'C3DWorld'
    1>C3DWorld.cpp
    1>octree\c3dworld.cpp(26) : error C2679: binary '>>' : no operator found which takes a right-hand operand of type 'std::string' (or there is no acceptable conversion)
    and there is no map.txt.

    I'll have a read through the OC tree code if I get some time.

    Good luck.

  5. #5
    Registered User
    Join Date
    Sep 2005
    Posts
    40
    i didnt include map.txt cause i can only upload 5 files at a time. Not sure why its giving you that error, it doesnt on my computer.
    Last edited by Adamkromm; 08-29-2009 at 06:53 PM.

  6. #6
    pwning noobs Zlatko's Avatar
    Join Date
    Jun 2009
    Location
    The Great White North
    Posts
    132
    Adam:
    One source of memory corruption is that you've copied OCTree.h into OCTree.cpp and then changed struct OCTreeNode. In OCTree.h, OCTreeNode has int* polys. In OCTree.cpp, it has int polys[50]. The mismatch in structure sizes has caused problems long before map.txt is even opened.

    In loadWorld, you define
    SECTOR* tsect[numsect];

    which is on the stack.
    It should be on the heap
    SECTOR* tsect = new SECTOR[numsect];

    I removed the OCTree.h contents from OCTree.cpp and defined OCTreeNode in OCTree.h with int polys[50] and I made the tsect on the heap.

    That allowed the program to run with no visible errors.

    I suppose you want to allocate polys on the heap, and the polys[50] was just for testing.

    Attached is the output. I did not try to interpret the output. It's up to you to check it.

    Best regards.
    Last edited by Zlatko; 08-31-2009 at 07:55 PM.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. No clue how to make a code to solve problems!
    By ctnzn in forum C Programming
    Replies: 8
    Last Post: 10-16-2008, 02:59 AM
  2. Linked list / Octree deletion
    By DrSnuggles in forum C++ Programming
    Replies: 2
    Last Post: 08-03-2008, 05:57 AM
  3. Rendering problems (DirectX?)
    By OnionKnight in forum Tech Board
    Replies: 0
    Last Post: 08-17-2006, 12:17 PM
  4. contest problems on my site
    By DavidP in forum Contests Board
    Replies: 4
    Last Post: 01-10-2004, 09:19 PM
  5. DJGPP problems
    By stormswift in forum C Programming
    Replies: 2
    Last Post: 02-26-2002, 04:35 PM