Giter Site home page Giter Site logo

Comments (2)

LOUKOUKOU avatar LOUKOUKOU commented on July 18, 2024

I think I've narrowed down the issue to 2 things.

Firstly, if you look at the boxcast function, you'll see that it reuses the same _boxcast_box variable to measure all its collisions.

This is done for optimization reasons, there is, however, a problem here. There are some properties, I think something to do with the look_at function, that persist between boxcast calls. This makes it so that subsequent calls are affected by previous ones.

In the boxcasts function, I changed line 24 from _boxcast_box.look_at(origin + direction) to _boxcast_box.lookAt(origin + direction), and it seemed to fix it. The lookAt function, is a panda3d function that the Entity class inherited. This isn't a final fix, just a possible indicator that the problem might lie in the look_at function.

There is also a broader issue, that has to do with coding standards. The issue is that the boxcast function isn't pure, which is a problem if it's a static function. I would suggest 2 approaches to fixing this from a best practices point of view. The first would to be just simply make boxcast a class, and then create an instance for ray you want to cast, and have the memory be properly managed within the class. The second would be to have the boxcast function recreate the _boxcast_box variable inside its function scope each time, and give the programmer the option to pass in their own _boxcast_box variable, that is reused, if they wished to save memory.

from ursina.

LOUKOUKOU avatar LOUKOUKOU commented on July 18, 2024

I think there might be some unforeseen consequences when calling the boxcast function
Here you call the look_at, but you don't pass an up parameter in.

ursina/ursina/boxcast.py

Lines 23 to 25 in c587be2

_boxcast_box.look_at(origin + direction)
hit_info = _boxcast_box.intersects(traverse_target=traverse_target, ignore=ignore)

In the function, it then uses the entities up, instead of a passed in up

ursina/ursina/entity.py

Lines 943 to 946 in c587be2

up_axis = self.up
if up:
up_axis = up
self.lookAt(target, up_axis)

from ursina.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.