﻿<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="ja">
	<id>https://wiki.blender.jp/index.php?action=history&amp;feed=atom&amp;title=%E5%88%A9%E7%94%A8%E8%80%85%3AAgoose77%2FBGE_Collision_Proposal</id>
	<title>利用者:Agoose77/BGE Collision Proposal - 版の履歴</title>
	<link rel="self" type="application/atom+xml" href="https://wiki.blender.jp/index.php?action=history&amp;feed=atom&amp;title=%E5%88%A9%E7%94%A8%E8%80%85%3AAgoose77%2FBGE_Collision_Proposal"/>
	<link rel="alternate" type="text/html" href="https://wiki.blender.jp/index.php?title=%E5%88%A9%E7%94%A8%E8%80%85:Agoose77/BGE_Collision_Proposal&amp;action=history"/>
	<updated>2026-06-03T20:35:03Z</updated>
	<subtitle>このウィキのこのページに関する変更履歴</subtitle>
	<generator>MediaWiki 1.31.0</generator>
	<entry>
		<id>https://wiki.blender.jp/index.php?title=%E5%88%A9%E7%94%A8%E8%80%85:Agoose77/BGE_Collision_Proposal&amp;diff=141863&amp;oldid=prev</id>
		<title>Yamyam: 1版 をインポートしました</title>
		<link rel="alternate" type="text/html" href="https://wiki.blender.jp/index.php?title=%E5%88%A9%E7%94%A8%E8%80%85:Agoose77/BGE_Collision_Proposal&amp;diff=141863&amp;oldid=prev"/>
		<updated>2018-06-28T20:54:33Z</updated>

		<summary type="html">&lt;p&gt;1版 をインポートしました&lt;/p&gt;
&lt;table class=&quot;diff diff-contentalign-left&quot; data-mw=&quot;interface&quot;&gt;
				&lt;tr class=&quot;diff-title&quot; lang=&quot;ja&quot;&gt;
				&lt;td colspan=&quot;1&quot; style=&quot;background-color: #fff; color: #222; text-align: center;&quot;&gt;← 古い版&lt;/td&gt;
				&lt;td colspan=&quot;1&quot; style=&quot;background-color: #fff; color: #222; text-align: center;&quot;&gt;2018年6月28日 (木) 20:54時点における版&lt;/td&gt;
				&lt;/tr&gt;&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-notice&quot; lang=&quot;ja&quot;&gt;&lt;div class=&quot;mw-diff-empty&quot;&gt;(相違点なし)&lt;/div&gt;
&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;</summary>
		<author><name>Yamyam</name></author>
		
	</entry>
	<entry>
		<id>https://wiki.blender.jp/index.php?title=%E5%88%A9%E7%94%A8%E8%80%85:Agoose77/BGE_Collision_Proposal&amp;diff=141862&amp;oldid=prev</id>
		<title>2013年5月16日 (木) 19:34にwiki&gt;Agoose77による</title>
		<link rel="alternate" type="text/html" href="https://wiki.blender.jp/index.php?title=%E5%88%A9%E7%94%A8%E8%80%85:Agoose77/BGE_Collision_Proposal&amp;diff=141862&amp;oldid=prev"/>
		<updated>2013-05-16T19:34:22Z</updated>

		<summary type="html">&lt;p&gt;&lt;/p&gt;
&lt;p&gt;&lt;b&gt;新規ページ&lt;/b&gt;&lt;/p&gt;&lt;div&gt;=BGE GameObject Collision API=&lt;br /&gt;
Every time two objects collide with each other, the callbacks registered on the KX_GameObjects would be called.&lt;br /&gt;
This includes when two objects stop colliding with each other (removed from narrowphase). &lt;br /&gt;
The status attribute denotes the entry status of the collision.&lt;br /&gt;
The rest of the attributes could include impulse, face, material, normal and so on.&lt;br /&gt;
==Collision API==&lt;br /&gt;
Adding a collision callback to the KX_GameObject class:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
short KX_GameObject::addCollisionCallback(PyObjectPlus callback){&lt;br /&gt;
    m_collisionCallbacks.push_back (callback);&lt;br /&gt;
    short id = this-&amp;gt;assignCollisionID(callback);&lt;br /&gt;
    return id;&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
void KX_GameObject::removeCollisionCallback(short id){&lt;br /&gt;
    short index = this-&amp;gt;getCollisionIndex(id);&lt;br /&gt;
    m_collisionCallbacks.erase(index);&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
==Collision Object==&lt;br /&gt;
Whenever the object's collision status changes, it would call this function with the colliding object and the status of collision. See this mock-up KX_CollisionObject&lt;br /&gt;
&amp;lt;source lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
KX_CollisionObject::KX_CollisionObject(KX_GameObject* collider, MTVector3&amp;amp; impulse, bool status){&lt;br /&gt;
    m_object(object);&lt;br /&gt;
    m_impulse(impulse);&lt;br /&gt;
    m_status(status);&lt;br /&gt;
    // ...&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
PyAttributeDef KX_CollisionObject::Attributes[] = {&lt;br /&gt;
    KX_PYATTRIBUTE_BOOL_RO(&amp;quot;status&amp;quot;, KX_CollisionObject, m_status),&lt;br /&gt;
    KX_PYATTRIBUTE_BOOL_RO(&amp;quot;object&amp;quot;, KX_CollisionObject, object),&lt;br /&gt;
    KX_PYATTRIBUTE_BOOL_RO(&amp;quot;impulse&amp;quot;, KX_CollisionObject, m_impulse),&lt;br /&gt;
    //...&lt;br /&gt;
&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
== Collision Callbacks==&lt;br /&gt;
This would be passed to the callback as follows:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;python&amp;quot;&amp;gt;&lt;br /&gt;
def collision_callback(collision):&lt;br /&gt;
    # Status of collision (start or end)&lt;br /&gt;
    status = collision.status&lt;br /&gt;
    # Other collider    &lt;br /&gt;
    obj = collision.object&lt;br /&gt;
&lt;br /&gt;
    if status:&lt;br /&gt;
        print(&amp;quot;colliding with {}&amp;quot;.format(obj.name))&lt;br /&gt;
    else:&lt;br /&gt;
        print(&amp;quot;separated from {}&amp;quot;.format(obj.name))&lt;br /&gt;
&lt;br /&gt;
callback_id = object.addCollisionCallback(collision_callback)&lt;br /&gt;
#...&lt;br /&gt;
object.removeCollisionCallback(callback_id)&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
The issue I can foresee is that if the GameObject is deleted before the collision stops, this would raise some error. However, simply defaulting to None or an invalid gameobject reference would be acceptable.&lt;/div&gt;</summary>
		<author><name>wiki&gt;Agoose77</name></author>
		
	</entry>
</feed>