Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8440941
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T08:26:10+00:00 2026-06-10T08:26:10+00:00

I am generating a collection of values each frame and I would like to

  • 0

I am generating a collection of values each frame and I would like to add those values to a larger collection of values at a specific index.

This is a typical example of a collection I am generating

std::vector<glm::vec3> corners;
corners.reserve(8);
//glm::vec3 corners[8];
//std::list<glm::vec3> corners;

corners[i++] = position - hX + hY + hZ;
corners[i++] = position + hX + hY + hZ;
corners[i++] = position + hX - hY + hZ;
corners[i++] = position - hX - hY + hZ;
corners[i++] = position - hX + hY - hZ;
corners[i++] = position + hX + hY - hZ;
corners[i++] = position + hX - hY - hZ;
corners[i++] = position - hX - hY - hZ;

I then have a larger collection of glm::vec3 values that I would like to copy the values above to at a particular index.

std::vector<glm::vec3> vertices;
vertices.assign(maxVertices, 0);

The C# equivalent would be

corners.CopyTo(vertices, index);

What class type can I use to efficiently generate and copy the smaller collection across to the larger one without too much overhead of generating it each frame?

I could get away with assigning each newly generated smaller collection to the end of the larger collection so the index value could be ignored.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-10T08:26:12+00:00Added an answer on June 10, 2026 at 8:26 am

    In your code you should corners.resize(8), not corners.reserve(8).
    Besides, if i understand you correctly, it seems you have always 8 corners?
    Use array then:

    typedef std::array<glm::vec3, 8> Corners; 
    // or in pre-c++0B code use boost::array same way
    // or if neither is available then just raw glm::vec3[8] can do.
    

    Then filling can be done with initialization:

    // somehow we have position, hX, hY and hZ
    Corners corners =
    {
        position - hX + hY + hZ,
        position + hX + hY + hZ,
        position + hX - hY + hZ,
        position - hX - hY + hZ,
        position - hX + hY - hZ,
        position + hX + hY - hZ,
        position + hX - hY - hZ,
        position - hX - hY - hZ
    };
    

    Copying can be done with standard copy:

    std::vector<glm::vec3> vertices;
    // somehow it gets filled
    
    // somewhere comes index
    
    std::copy( corners.begin(), corners.end(), vertices.begin() + index );
    // with raw glm::vec3[8] std::copy( corners, corners + 8, vertices.begin() + index );
    

    If you need to insert instead of copy then use vertices.insert()

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

How would I go about generating random platforms without intersection? I think garbage collection
I'm generating a DeepZoom collection, using code from Bryant... http://bryantlikes.com/DeepZoomImageGenerationWithDeepZoomToolsDLL.aspx This generates a DeepZoom
How do I debug problems like this. I have this code: var index =
I'm generating models from my Mysql db. It generates a foreign key collection properly,
I'm generating my data contract with a command line like: svcutil /ct:System.Collections.Generic.List`1 MySchema.xsd In
Am generating a hidden fields like so: @helper.input(_form(userID), '_label-> None) { (id, name, value,
When generating models from postgresql with ColdFusion Illudium Code generator the boolean values get
Starting with a collection of strings like: (def str-coll [abcd efgh jklm]) The goal
I'm generating a c# Linq expression dynamically as below, which will (in the example
I have a table that looks like this: category category_id name category_seo_friendly_url left_id right_id

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.